Jump to content

How to run msi file via msiexec with specific parameter


Recommended Posts

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

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.0 - WIN 8.1 X64 - Other Example Scripts

Link to comment
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

Link to comment
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

Link to comment
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
Link to comment
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

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...