Sign in to follow this  
Followers 0
scottlong

How to run msi file via msiexec with specific parameter

13 posts in this topic

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" /qb

How to auto install it via autoit script?

Thanks!

Share this post


Link to post
Share on other sites



ShellExecuteWait('msiexec', '/L*v "%TEMP%\install.msi.log" /i "install.Msi" TRANSFORMS="install.mst" /qb')

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

$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

Share this post


Link to post
Share on other sites

$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

Share this post


Link to post
Share on other sites

Is this all your code? Maybe you put it in a loop?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

That is because you now open notepad.

And the second IF bypasses the Runas.

RUNAS is never executed

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0