LancIT Posted February 24, 2015 Share Posted February 24, 2015 (edited) Hi guys, I'm trying to run a simple .MSI file as our Domain Admin account to install something. I'm totally new to this and my scripting skills are... Poor, so any help really appreciated. I've tried reading up, but so far I'm stuck. Here's my script - Don't laugh! ; Script Start - Add your code below here Local $sUserName = "account" Local $sPassword = "password" Local $sDomain = "domain" RunAsWait($sUserName, $sDomain, $sPassword, 0, ("msiexec /i "C:FileInstaller.msi"")) i get this error: Line 6 (File "C:File.au3"): RunAsWait($sUserName, $sDomain, $sPassword, 0, ("msiexec /i "C:FileInstaller.msi"")) RunAsWait($sUserName, £sDomain, $sPassword, 0, ("msiexec /i "C:^ ERROR Error: Unable to parse line. I've tried many different variations, but it still keeps failing... Tell me I'm missing something really silly, or the script is just totally wrong?? Edited February 24, 2015 by LancIT Link to comment Share on other sites More sharing options...
SadBunny Posted February 24, 2015 Share Posted February 24, 2015 (edited) Hi, and welcome to the forum. If you want to use doublequotes inside a string delimited by doublequotes, you need to double the doublequotes (autoit's way of "escaping", many other languages do it by placing a backslash in front of them). So instead of "this string contains " a doublequote", you write: "this string contains "" a doublequote". Because you did not, your string is terminated after the "/i " part and the rest C:...blah... is interpreted as AutoIt language instead of as the rest of your string. As it is not valid AutoIt language, the procedure fails. Also, it should not be necessary to put the file inside of parentheses. Try: RunAsWait($sUserName, $sDomain, $sPassword, 0, "msiexec /i ""C:\File\Installer.msi""") Note that at the end, there are three doublequotes. The first two to make one doublequote in the string, and the third to end the string. AutoIt also supports 'single quotes' as string delimiters, which makes life easier in these situations, because it eliminates the need to double the doublequotes (though you'd have to double the single quotes - luckily you don't need them in this particular string ): RunAsWait($sUserName, $sDomain, $sPassword, 0, 'msiexec /i "C:\File\Installer.msi"') /edit: Why would anyone laugh at you? You actually took the time and effort to formulate your question well. Can't say that for every first post... Edited February 24, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
TheDcoder Posted February 24, 2015 Share Posted February 24, 2015 RunAsWait($sUserName, $sDomain, $sPassword, 0, ("msiexec /i "C:FileInstaller.msi"")) The Highlighted quote is ending the string, so use this: RunAsWait($sUserName, $sDomain, $sPassword, 0, ('msiexec /i "C:FileInstaller.msi"')) EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
LancIT Posted February 24, 2015 Author Share Posted February 24, 2015 Hi, and welcome to the forum. If you want to use doublequotes inside a string delimited by doublequotes, you need to double the doublequotes (autoit's way of "escaping", many other languages do it by placing a backslash in front of them). So instead of "this string contains " a doublequote", you write: "this string contains "" a doublequote". Because you did not, your string is terminated after the "/i " part and the rest C:...blah... is interpreted as AutoIt language instead of as the rest of your string. As it is not valid AutoIt language, the procedure fails. Also, it should not be necessary to put the file inside of parentheses. Try: RunAsWait($sUserName, $sDomain, $sPassword, 0, "msiexec /i ""C:\File\Installer.msi""") Note that at the end, there are three doublequotes. The first two to make one doublequote in the string, and the third to end the string. AutoIt also supports 'single quotes' as string delimiters, which makes life easier in these situations, because it eliminates the need to double the doublequotes (though you'd have to double the single quotes - luckily you don't need them in this particular string ): RunAsWait($sUserName, $sDomain, $sPassword, 0, 'msiexec /i "C:\File\Installer.msi"') /edit: Why would anyone laugh at you? You actually took the time and effort to formulate your question well. Can't say that for every first post... Hi, and welcome to the forum. If you want to use doublequotes inside a string delimited by doublequotes, you need to double the doublequotes (autoit's way of "escaping", many other languages do it by placing a backslash in front of them). So instead of "this string contains " a doublequote", you write: "this string contains "" a doublequote". Because you did not, your string is terminated after the "/i " part and the rest C:...blah... is interpreted as AutoIt language instead of as the rest of your string. As it is not valid AutoIt language, the procedure fails. Also, it should not be necessary to put the file inside of parentheses. Try: RunAsWait($sUserName, $sDomain, $sPassword, 0, "msiexec /i ""C:\File\Installer.msi""") Note that at the end, there are three doublequotes. The first two to make one doublequote in the string, and the third to end the string. AutoIt also supports 'single quotes' as string delimiters, which makes life easier in these situations, because it eliminates the need to double the doublequotes (though you'd have to double the single quotes - luckily you don't need them in this particular string ): RunAsWait($sUserName, $sDomain, $sPassword, 0, 'msiexec /i "C:\File\Installer.msi"') /edit: Why would anyone laugh at you? You actually took the time and effort to formulate your question well. Can't say that for every first post... Thanks guys, I'm going to test this now. Much appriciated! I'm a heavy forum user, So I know how to setup first posts, luckily! Nothing more annoying than "Help... It won't work" style posts TheDcoder 1 Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted February 24, 2015 Share Posted February 24, 2015 Not too often would I have a file that the user would run where I need to put the Admin permissions in the file, usually I as an administrator would run it. On the occasion I do need them to run a file, I personally would not feel comfortable putting the credentials right in the script like that. There are a few Autoit only ways to do it safer, but the easiest for me was to use a free download called RunAsSPC http://www.robotronic.de/runasspcEn.html Its not perfect in its own right but it worked for me. I embed the needed files with FileInstall and invoke RunAsSPC silently via CMD so that the files are run as an admin. The other way to put credentials in the code and make it a bit more safe is with the crypt/decrypt functions, but it could still be reversed easier than the RunAsSPC encrypted certificate. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now