scottlong Posted August 27, 2010 Share Posted August 27, 2010 How to run msi file via msiexec with specific parameter?I create a dos script .cmd file, add following sentence:msiexec /L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qbHow to auto install it via autoit script?Thanks! Link to comment Share on other sites More sharing options...
JFX Posted August 27, 2010 Share Posted August 27, 2010 ShellExecuteWait('msiexec', '/L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qb') Link to comment Share on other sites More sharing options...
scottlong Posted August 27, 2010 Author Share Posted August 27, 2010 Thanks for your help, I tested but failure via normal user, I think maybe have not right for installation. Could you tell me how to use RunAs together with ShellExecuteWait? or how to RunAs a .cmd file switch to another user? I know RunAs help, but I do not know how to excute .cmd file via RunAs. Link to comment Share on other sites More sharing options...
wakillon Posted August 27, 2010 Share Posted August 27, 2010 (edited) Try this too... $_MsiFilePath = @ScriptDir & '\install.Msi' $_LogFilePath = @TempDir & '\install.msi.log' $_MstFilePath = @ScriptDir & '\install.Mst' $_Run = 'msiexec /L*v "' & $_LogFilePath & '" /i "' & $_MsiFilePath & '" TRANSFORMS="' & $_MstFilePath & '" /qb' ConsoleWrite ( "$_Run : " & $_Run & @Crlf ) RunWait ( $_Run ) Edited August 27, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Danny35d Posted August 27, 2010 Share Posted August 27, 2010 RunAs program in network map drive AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
scottlong Posted August 30, 2010 Author Share Posted August 30, 2010 ShellExecuteWait('msiexec', '/L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qb')This sentence run with the current user login account, How can I run it with another admin user? Link to comment Share on other sites More sharing options...
Juvigy Posted August 30, 2010 Share Posted August 30, 2010 $sUserName = 'Login Name' $sPassword = 'Login Password' $sDomain = 'The domain to authenticate against.' RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe, @SystemDir, @SW_HIDE) ShellExecuteWait('msiexec', '/L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qb') Which will run the whole script as the user you want and the you can run the shellexecute Link to comment Share on other sites More sharing options...
krispoet Posted August 30, 2010 Share Posted August 30, 2010 $sUserName = 'Login Name' $sPassword = 'Login Password' $sDomain = 'The domain to authenticate against.' RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe, @SystemDir, @SW_HIDE) ShellExecuteWait('msiexec', '/L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qb') Which will run the whole script as the user you want and the you can run the shellexecute Hi Juvigy Do you know why when i try to run RunAs($AdminAccount, @ComputerName, $AdminPassword, 0, @AutoItExe, @SystemDir, @SW_HIDE) ShellExecuteWait("cmd.exe") exit I have new command prompts pops up every 10 seconds? Anything i need to add? Thanks Link to comment Share on other sites More sharing options...
Juvigy Posted August 30, 2010 Share Posted August 30, 2010 Is this all your code? Maybe you put it in a loop? Link to comment Share on other sites More sharing options...
Danny35d Posted August 30, 2010 Share Posted August 30, 2010 Hi Juvigy Do you know why when i try to run RunAs($AdminAccount, @ComputerName, $AdminPassword, 0, @AutoItExe, @SystemDir, @SW_HIDE) ShellExecuteWait("cmd.exe") exit I have new command prompts pops up every 10 seconds? Anything i need to add? Thanks Because your script keep processing RunAS(), the next process start another RunAS(), so on and so on creating an infinite loop. Try it: $sUserName = 'Login Name' $sPassword = 'Login Password' $sDomain = 'The domain to authenticate against.' If $CMDLine[0] = 0 Then RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe & ' /RunAs', @SystemDir, @SW_HIDE) Exit EndIf ShellExecuteWait('msiexec', '/L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qb') AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
krispoet Posted September 1, 2010 Share Posted September 1, 2010 Because your script keep processing RunAS(), the next process start another RunAS(), so on and so on creating an infinite loop. Try it: $sUserName = 'Login Name' $sPassword = 'Login Password' $sDomain = 'The domain to authenticate against.' If $CMDLine[0] = 0 Then RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe & ' /RunAs', @SystemDir, @SW_HIDE) Exit EndIf ShellExecuteWait('msiexec', '/L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qb') If Not IsAdmin() Then IF $CMDLine [0] =0 Then RunAs($AdminAccount, @ComputerName, $AdminPassword, 0,@AutoItExe & ' /RunAs', @SystemDir, @SW_HIDE) ShellExecute('notepad.exe') Exit EndIf EndIf Hi Danny35d The code above didn't work Notepad did show up, but it is runas original user instead of intended Admin user Link to comment Share on other sites More sharing options...
Juvigy Posted September 1, 2010 Share Posted September 1, 2010 That is because you now open notepad. And the second IF bypasses the Runas. RUNAS is never executed Link to comment Share on other sites More sharing options...
Danny35d Posted September 2, 2010 Share Posted September 2, 2010 Use either isAdmin() or CMDLine[0] no both of them. Use RunAs() only when current login don't have admin credentials: $sUserName = 'Login Name' $sPassword = 'Login Password' $sDomain = 'The domain to authenticate against.' If Not IsAdmin() Then RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe, @SystemDir, @SW_HIDE) Exit EndIf ShellExecuteWait('notepad.exe') No matter, what kind of credetials the current login has? Always use RunAs(): $sUserName = 'Login Name' $sPassword = 'Login Password' $sDomain = 'The domain to authenticate against.' If $CMDLine[0] = 0 Then RunAs($sUserName, $sDomain, $sPassword, 0, @AutoItExe & ' /RunAs', @SystemDir, @SW_HIDE) Exit EndIf ShellExecuteWait('notepad.exe') AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line 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