myk3 Posted April 28, 2011 Posted April 28, 2011 (edited) I finally figured out how to remotely install software (patches) on a remote host,with the help of a friend.. However I am having trouble retrieving the return value of the app that was installed. I can get the return value of the process.. but I have no idea if the app was actually installed or not. here is my current code.. expandcollapse popup#RequireAdmin #Include <Array.au3> $message = "Pick the file you wish to install" $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $i = 1 while $i =1 $strComputer = InputBox("Computer","What computer would you like to install software on?","arfj") if $strComputer = "" Then $error = MsgBox(5,"Error!", "You have entered an invalid computer name") if $error = 2 then exit Else $i += 1 EndIf wend $file = FileOpenDialog($message,@ScriptDir, "ALL (*.*)", 1) If @error Then MsgBox(4096,"","No File(s) chosen") exit Else $file = StringReplace($file, "|", @CRLF) EndIf $var = Ping($strComputer) if $var then _FileCopy($file,"\\" & $strComputer & "\admin$\") $rlocation = StringSplit($file,"\",1) $extension = Stringright($file,3) Select case $extension = "exe" $def = "" case $extension = "msi" $def = "/quiet /norestart" case $extension = "msu" $def = "/quiet /norestart" EndSelect $switches = InputBox("Switches","any switches?",$def) if @error then exit if $switches = "" Then $war = MsgBox(1,"WARNING!","No switches have been defined. The process may hang if not ran silent") Select case $war = 1 ContinueCase case $war = 2 exit EndSelect EndIf $file1 = $rlocation[UBound($rlocation)-1] $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $objProcess = $objWMIService.Get("Win32_Process") $Error = $objProcess.Create($file & " " & $Switches) MsgBox(0,"",$Error) $d = 1 while $d = 1 if FileExists("\\" & $strComputer & "\admin$\" & $file1) Then FileDelete("\\" & $strComputer & "\admin$\" & $file1) Else $d += 1 EndIf wend Else MsgBox(0,"","Unable to ping system") EndIf Func _FileCopy($fromFile,$tofile) Local $FOF_RESPOND_YES = 16 Local $FOF_SIMPLEPROGRESS = 256 $winShell = ObjCreate("shell.application") $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES) EndFunc Edited April 28, 2011 by myk3
myk3 Posted April 28, 2011 Author Posted April 28, 2011 (edited) It appears if I use the "Win32_Product" and then use .install I can get the completion return code.. but this only work for .msi edit: I found another problem.. I can not copy and run a batch / cmd file remotely. Edited April 28, 2011 by myk3
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