jp10558 Posted September 20, 2006 Posted September 20, 2006 I'm trying to just dump a cmd window's output to a log file, however the file's coming up blank. The code I have is: $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"',@WorkingDir,@SW_HIDE,2) FileWrite(@YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt", StdoutRead($stIO)) Anyidea what I'm doing incorrect? Also - Scite doesn't seem to recognize the StdoutRead/write/error functions.
jvanegmond Posted September 20, 2006 Posted September 20, 2006 (edited) The output is buffered as the program is being run. You will have to constantly poll StdoutRead, instead of just once right after the program started. $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"',@WorkingDir,@SW_HIDE,2) While 1 $var = StdoutRead($stIO) If @error Then ExitLoop FileWrite("temp.txt", $var) Wend FileMove("temp.txt", @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt") Edited September 20, 2006 by Manadar github.com/jvanegmond
PsaltyDS Posted September 20, 2006 Posted September 20, 2006 (edited) The output is buffered as the program is being run. You will have to constantly poll StdoutRead, instead of just once right after the program started. $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"',@WorkingDir,@SW_HIDE,2) While 1 $var = StdoutRead($stIO) If @error Then ExitLoop FileWrite("temp.txt", $var) Wend FileMove("temp.txt", @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt") oÝ÷ Ûú®¢×®éÜ)h¢H§Î¶ayø¥y©Ý¥yêm¢Þ½éíõ#ji¢ëÉ«¢+ØÀÌØíÍÑ% Edit: Tweak to open/close file correctly. Edited September 20, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
jp10558 Posted September 20, 2006 Author Posted September 20, 2006 Mmmm, I'm still not getting anything - here's what I've got now: $logname = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt"; set up logfile FileWrite($logname,"Log for installing " & $program) $file = FileOpen($logname,1); Open the logfile for appending #cs Do the install one machine at a time. This is not necessarily efficient if it doesn't actually fail to copy the first time. I should add a file exists at some point before the second try. #ce For $counter = 0 to $length - 1; ;MsgBox(0,"Status","Starting file copy") $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); have to try twice - I think the first time authenticates but does nothing Sleep(1000) $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); second time copies the installer, if it worked the first time, it just overwrites. ;MsgBox(0,"Status","File Copy finished " & $temp2) $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"',@WorkingDir,@SW_HIDE,2); run the program using psexec.exe #cs Now we try and write the log file. Actually, the above ,2 at the end tells it to return a handle to STDIO for reading and place the handle in $stIO. Usually a Run() doesn't return anything. The below is some help from the support forums - how to actually use StdoutRead(). We poll the IO and buffer in $var. Then I append to the opened file. #ce $var = "";buffer for input output While 1 $var &= StdoutRead($stIO) If @error Then ExitLoop Sleep(100) WEnd FileWrite($file, $var) ;MsgBox(0,"Status","Running psexec.exe") Next FileClose($file) I get the first line from the initial setup, but none of the output. Will this actually get all the output that shows in the DOS window?
PsaltyDS Posted September 20, 2006 Posted September 20, 2006 (edited) Mmmm, I'm still not getting anything - here's what I've got now: $logname = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt"; set up logfile FileWrite($logname,"Log for installing " & $program) $file = FileOpen($logname,1); Open the logfile for appending #cs Do the install one machine at a time. This is not necessarily efficient if it doesn't actually fail to copy the first time. I should add a file exists at some point before the second try. #ce For $counter = 0 to $length - 1; ;MsgBox(0,"Status","Starting file copy") $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); have to try twice - I think the first time authenticates but does nothing Sleep(1000) $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); second time copies the installer, if it worked the first time, it just overwrites. ;MsgBox(0,"Status","File Copy finished " & $temp2) $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"',@WorkingDir,@SW_HIDE,2); run the program using psexec.exe #cs Now we try and write the log file. Actually, the above ,2 at the end tells it to return a handle to STDIO for reading and place the handle in $stIO. Usually a Run() doesn't return anything. The below is some help from the support forums - how to actually use StdoutRead(). We poll the IO and buffer in $var. Then I append to the opened file. #ce $var = "";buffer for input output While 1 $var &= StdoutRead($stIO) If @error Then ExitLoop Sleep(100) WEnd FileWrite($file, $var) ;MsgBox(0,"Status","Running psexec.exe") Next FileClose($file) I get the first line from the initial setup, but none of the output. Will this actually get all the output that shows in the DOS window? For one thing, open the file in write mode before writing to it, and use the handle, not the file name once you open it: $logname = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt"; set up logfile $file = FileOpen($logname, 1); Open the logfile for appending FileWrite($file, "Log for installing " & $program) oÝ÷ ØôÂ¥u©l¢Z ¶ºw(f§vX§z;¬¶ÚzË«y©Ý~í®ë!¢b n®,zÆ®¶sbb33c´WD6ÖBÒ6öÕ7V2fײgV÷C²ö2gV÷C²fײb33²gV÷C·6WV2æWRb3#²b3#²b33²fײb33c¶Æ7E²b33c¶6÷VçFW%ÒfײgV÷C²×23¢b3#µDTÕb3#²gV÷C²fײb33c·&öw&Òfײb33²gV÷C²b33°¤fÆUw&FRb33c¶fÆRÂgV÷Cµ'Vææær6öÖÖæC¢gV÷C²fײb33c´WD6ÖB¢b33c·7DòÒ'Vâb33c´WD6ÖBÂv÷&¶ætF"Â5uôDRÂ"²'VâFR&öw&ÒW6ær6WV2æW Edited September 20, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
MHz Posted September 20, 2006 Posted September 20, 2006 Looks like one big switch being passed to @ComSpec. You may need to break your parameters up into separate parameters. I consider I ironed out the issue. $logname = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt"; set up logfile FileWrite($logname,"Log for installing " & $program) $file = FileOpen($logname,1); Open the logfile for appending #cs Do the install one machine at a time. This is not necessarily efficient if it doesn't actually fail to copy the first time. I should add a file exists at some point before the second try. #ce For $counter = 0 to $length - 1; ;MsgBox(0,"Status","Starting file copy") $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); have to try twice - I think the first time authenticates but does nothing Sleep(1000) $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); second time copies the installer, if it worked the first time, it just overwrites. ;MsgBox(0,"Status","File Copy finished " & $temp2) $stIO = Run(@ComSpec & ' /c psexec.exe "\\' & $list[$counter] & '" -s "C:\TEMP\' & $program & '"', @WorkingDir, @SW_HIDE, 2); run the program using psexec.exe #cs Now we try and write the log file. Actually, the above ,2 at the end tells it to return a handle to STDIO for reading and place the handle in $stIO. Usually a Run() does'nt return anything. The below is some help from the support forums - how to actually use StdoutRead(). We poll the IO and buffer in $var. Then I append to the opened file. #ce $var = "";buffer for input output Do $var &= StdoutRead($stIO) Until @error FileWrite($file, $var) ;MsgBox(0,"Status","Running psexec.exe") Next FileClose($file)
jp10558 Posted September 20, 2006 Author Posted September 20, 2006 (edited) For one thing, open the file in write mode before writing to it, and use the handle, not the file name once you open it: $logname = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt"; set up logfile $file = FileOpen($logname, 1); Open the logfile for appending FileWrite($file, "Log for installing " & $program) oÝ÷ ØôÂ¥u©l¢Z ¶ºw(f§vX§z;¬¶ÚzË«y©Ý~í®ë!¢b n®,zÆ®¶sbb33c´WD6ÖBÒ6öÕ7V2fײgV÷C²ö2gV÷C²fײb33²gV÷C·6WV2æWRb3#²b3#²b33²fײb33c¶Æ7E²b33c¶6÷VçFW%ÒfײgV÷C²×23¢b3#µDTÕb3#²gV÷C²fײb33c·&öw&Òfײb33²gV÷C²b33°¤fÆUw&FRb33c¶fÆRÂgV÷Cµ'Vææær6öÖÖæC¢gV÷C²fײb33c´WD6ÖB¢b33c·7DòÒ'Vâb33c´WD6ÖBÂv÷&¶ætF"Â5uôDRÂ"²'VâFR&öw&ÒW6ær6WV2æWWill that create the file though? I thought the only way to create the file was to use the filename to quickly open and close the file, and then reopen normally for more writing. For logging the run command it shouldn't be necessary, the psexec.exe from sysinternals is very verbose in it's output, which if I could log to the file I could then see everything it did or failed to do. It's not necessary to log the run command as I put the file $program in at the top, and the rest stays the same all the time. Edited September 20, 2006 by jp10558
PsaltyDS Posted September 20, 2006 Posted September 20, 2006 Will that create the file though? I thought the only way to create the file was to use the filename to quickly open and close the file, and then reopen normally for more writing.For logging the run command it shouldn't be necessary, the psexec.exe from sysinternals is very verbose in it's output, which if I could log to the file I could then see everything it did or failed to do. It's not necessary to log the run command as I put the file $program in at the top, and the rest stays the same all the time.FileOpen() will create the file (quoting help file):mode Mode (read or write) to open the file in.Can be a combination of the following: 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) 4 = Read raw mode 8 = Create directory structure if it doesn't exist (See Remarks).Both write modes will create the file if it does not already exist. The folder path must already exist (except using mode '8' - See Remarks).How (and how much) to log are just personal preferences. I like to err on the "/rv" (ridiculously verbose) side. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
jp10558 Posted September 20, 2006 Author Posted September 20, 2006 FileOpen() will create the file (quoting help file):How (and how much) to log are just personal preferences. I like to err on the "/rv" (ridiculously verbose) side. Thanks. It looks like I've wasted my time here though, SAV decided just now that all my installer scripts this was going to deploy are trojans, and deletes them on sight.
PsaltyDS Posted September 20, 2006 Posted September 20, 2006 Thanks. It looks like I've wasted my time here though, SAV decided just now that all my installer scripts this was going to deploy are trojans, and deletes them on sight.What version of AutoIT are you running? The latest production version is 3.2.0.1 and it digitally signs its files, which may help with that. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
jp10558 Posted September 20, 2006 Author Posted September 20, 2006 What version of AutoIT are you running? The latest production version is 3.2.0.1 and it digitally signs its files, which may help with that. I have 3.2.01. If it uses the same keyfile for everyone, it really doesn't prove anything. Is there any way we could use our own signing cert?
PsaltyDS Posted September 20, 2006 Posted September 20, 2006 (edited) I have 3.2.01. If it uses the same keyfile for everyone, it really doesn't prove anything. Is there any way we could use our own signing cert?That's not the problem I was thinking of, where it just asks if you really want to run that. Sounds like you're getting an actual false positive. There's another report in a newer thread already. P.S. ...and another. Edited September 20, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
jp10558 Posted September 21, 2006 Author Posted September 21, 2006 (edited) Cool, it's been fixed by symantec.Anyway, I still can't seem to figure out why I'm not getting any output. Does anyone know if psexec.exe's command line output isn't stout? Is there anyway to capture the output and write it to a log file?I still don't get anything, this is what I have now:$logname = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt"; set up logfile $file = FileOpen($logname,1); Open the logfile for appending FileWrite($file,"Log for installing " & $program) #cs Do the install one machine at a time. This is not necessarily efficient if it doesn't actually fail to copy the first time. I should add a file exists at some point before the second try. #ce For $counter = 0 to $length - 1; ;MsgBox(0,"Status","Starting file copy") $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); have to try twice - I think the first time authenticates but does nothing Sleep(1000) $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); second time copies the installer, if it worked the first time, it just overwrites. $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"',@WorkingDir,@SW_HIDE,2); run the program using psexec.exe #cs Now we try and write the log file. Actually, the above ,2 at the end tells it to return a handle to STDIO for reading and place the handle in $stIO. Usually a Run() doesn't return anything. The below is some help from the support forums - how to actually use StdoutRead(). We poll the IO and buffer in $var. Then I append to the opened file. #ce $var = "";buffer for input output While 1 $var &= StdoutRead($stIO) If @error Then ExitLoop Sleep(100) WEnd FileWrite($file, $var) ;MsgBox(0,"Status","Running psexec.exe") Next FileClose($file) Edited September 21, 2006 by jp10558
PsaltyDS Posted September 21, 2006 Posted September 21, 2006 Cool, it's been fixed by symantec. Anyway, I still can't seem to figure out why I'm not getting any output. Does anyone know if psexec.exe's command line output isn't stout? Is there anyway to capture the output and write it to a log file? I still don't get anything, this is what I have now: $logname = @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "h_" & @MIN & "m_" & @SEC & "s_" & "InstallLog.txt"; set up logfile $file = FileOpen($logname,1); Open the logfile for appending FileWrite($file,"Log for installing " & $program) #cs Do the install one machine at a time. This is not necessarily efficient if it doesn't actually fail to copy the first time. I should add a file exists at some point before the second try. #ce For $counter = 0 to $length - 1; ;MsgBox(0,"Status","Starting file copy") $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); have to try twice - I think the first time authenticates but does nothing Sleep(1000) $temp2 = FileCopy( $path, "\\" & $list[$counter] & "\C$\TEMP", 9); second time copies the installer, if it worked the first time, it just overwrites. $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"',@WorkingDir,@SW_HIDE,2); run the program using psexec.exe #cs Now we try and write the log file. Actually, the above ,2 at the end tells it to return a handle to STDIO for reading and place the handle in $stIO. Usually a Run() doesn't return anything. The below is some help from the support forums - how to actually use StdoutRead(). We poll the IO and buffer in $var. Then I append to the opened file. #ce $var = "";buffer for input output While 1 $var &= StdoutRead($stIO) If @error Then ExitLoop Sleep(100) WEnd FileWrite($file, $var) ;MsgBox(0,"Status","Running psexec.exe") Next FileClose($file) You can get StdErr also by running with: $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"', @WorkingDir, @SW_HIDE, 2+4) ; 2+4 = get handles to StdOut and StdErroÝ÷ Ø Ý¶§æx"·«¢+Ø$ÀÌØí=ÕÑYÈôÅÕ½ÐìÅÕ½ÐììÕȽÈMÑ=ÕнÕÑÁÕÐ($ÀÌØíÉÉYÈôÅÕ½ÐìÅÕ½ÐììÕȽÈÉÉ=ÕнÕÑÁÕÐ(%]¡¥±Ä($$ÀÌØí=ÕÑYȵÀìôMѽÕÑI ÀÌØíÍÑ% See what gets written from $var that way... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
jp10558 Posted September 21, 2006 Author Posted September 21, 2006 You can get StdErr also by running with: $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"', @WorkingDir, @SW_HIDE, 2+4) ; 2+4 = get handles to StdOut and StdErroÝ÷ Ø Ý¶§æx"·«¢+Ø$ÀÌØí=ÕÑYÈôÅÕ½ÐìÅÕ½ÐììÕȽÈMÑ=ÕнÕÑÁÕÐ($ÀÌØíÉÉYÈôÅÕ½ÐìÅÕ½ÐììÕȽÈÉÉ=ÕнÕÑÁÕÐ(%]¡¥±Ä($$ÀÌØí=ÕÑYȵÀìôMѽÕÑI ÀÌØíÍÑ% See what gets written from $var that way... Thanks, I had tried stderr already by itself, and that was always 0 - even when on the open command line box (set to show the cmd box) there was info saying program failed to find foo to run.
jp10558 Posted September 22, 2006 Author Posted September 22, 2006 (edited) You can get StdErr also by running with: $stIO = Run(@ComSpec & " /c " & '"psexec.exe \\' & $list[$counter] & " -s C:\TEMP\" & $program & '"', @WorkingDir, @SW_HIDE, 2+4) ; 2+4 = get handles to StdOut and StdErroÝ÷ Ø Ý¶§æx"·«¢+Ø$ÀÌØí=ÕÑYÈôÅÕ½ÐìÅÕ½ÐììÕȽÈMÑ=ÕнÕÑÁÕÐ($ÀÌØíÉÉYÈôÅÕ½ÐìÅÕ½ÐììÕȽÈÉÉ=ÕнÕÑÁÕÐ(%]¡¥±Ä($$ÀÌØí=ÕÑYȵÀìôMѽÕÑI ÀÌØíÍÑ% See what gets written from $var that way... I tried that - I also have a msgbox popping up for the handle - it's getting a random #, which I would guess is the handle. But both in the var dialog, and file, are blank. Is there any other way to capture data from the windows CLI other than stout? Edited September 22, 2006 by jp10558
jp10558 Posted September 22, 2006 Author Posted September 22, 2006 I tried that - I also have a msgbox popping up for the handle - it's getting a random #, which I would guess is the handle. But both in the var dialog, and file, are blank.Is there any other way to capture data from the windows CLI other than stout?It actually looks like my script may be exiting before the info get's written to stdout. In the read loop - I get the msgbox with the supposed stdout in it - blank, but on a longer run of psexec - the cmd box for debug is still open with psexec still running when the script stops running. . .When does @error get set? Maybe it's getting set before anything is written. Too bad that we can't do a runwait with this... Any ideas?
PeteW Posted September 27, 2006 Posted September 27, 2006 Hello jp10558, I'm in the process of amending my 'Remote Updater' util to get it to restart a list of servers. I see you've posted a comment (thanks) - sorry for the lack of response; after 7 months & no feedback I assumed nobody was interested! When I've time, I'll upload an update. Anyway, I too found PSExec (BTW, I'm using 1.72), wasn't providing useful results: STDOUT empty & STDERR gave 'C:\Program not found'. I'm executing PSExec from a longfilename path, passing PSExec a working dir enclosed in quotes and also using quotes in the command PSExec is executing - a 2003 server shutdown comment: C:\WINDOWS\system32\cmd.exe /c "C:\Program Files\Utils\_RUpdater\psexec.exe" \\server -i -n 120 -w "\\server\Admin$\Temp" shutdown.exe /f /r /c "Restart following critical update..." /d p:2:18 I later checked 'cmd /?' i.e. RTFM If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters: 1. If all of the following conditions are met, then quote characters on the command line are preserved: - no /S switch - exactly two quote characters - no special characters between the two quote characters, where special is one of: &<>()@^| - there are one or more whitespace characters between the the two quote characters - the string between the two quote characters is the name of an executable file.Found 2 ways round this - there maybe better methods: 1) Instead of Run(@Comspec " /c " $psexec), use Run($psexec) - this gives what PSExec outputs to the console in STDERR. 2) More simply, convert the $psexec filepath to a shortfilename - allowing you to ignore it's surrounding quotes. The Run() command is now:C:\WINDOWS\system32\cmd.exe /c C:\Progra~1\Utils\_RUpdater\psexec.exe \\server -i -n 120 -w "\\server\Admin$\Temp" shutdown.exe /f /r /c "Restart following critical update..." /d p:2:18 Assuming PSExec ran the command, you should get STDERR text which includes "'command' exited on 'server' with error code 'n'." I use this to obtain success/failure results. Not sure if you've similar problems, but hope the above helps/makes sense! Cheers, Pete
jp10558 Posted September 27, 2006 Author Posted September 27, 2006 Hello jp10558, I'm in the process of amending my 'Remote Updater' util to get it to restart a list of servers. I see you've posted a comment (thanks) - sorry for the lack of response; after 7 months & no feedback I assumed nobody was interested! When I've time, I'll upload an update. Anyway, I too found PSExec (BTW, I'm using 1.72), wasn't providing useful results: STDOUT empty & STDERR gave 'C:\Program not found'. I'm executing PSExec from a longfilename path, passing PSExec a working dir enclosed in quotes and also using quotes in the command PSExec is executing - a 2003 server shutdown comment: C:\WINDOWS\system32\cmd.exe /c "C:\Program Files\Utils\_RUpdater\psexec.exe" \\server -i -n 120 -w "\\server\Admin$\Temp" shutdown.exe /f /r /c "Restart following critical update..." /d p:2:18 I later checked 'cmd /?' i.e. RTFM Found 2 ways round this - there maybe better methods: 1) Instead of Run(@Comspec " /c " $psexec), use Run($psexec) - this gives what PSExec outputs to the console in STDERR. 2) More simply, convert the $psexec filepath to a shortfilename - allowing you to ignore it's surrounding quotes. The Run() command is now:C:\WINDOWS\system32\cmd.exe /c C:\Progra~1\Utils\_RUpdater\psexec.exe \\server -i -n 120 -w "\\server\Admin$\Temp" shutdown.exe /f /r /c "Restart following critical update..." /d p:2:18 Assuming PSExec ran the command, you should get STDERR text which includes "'command' exited on 'server' with error code 'n'." I use this to obtain success/failure results. Not sure if you've similar problems, but hope the above helps/makes sense! Cheers, PeteThanks, that's very helpful. I already worked around the issue by just using a cli redirect e.g. 2>>log.txt with a little more logic, and probably more opening + closing of the file handle than was necessary, but hey, it works now, and I'm mostly happy. I think your program would be a lot more versitile - but I would need better documentation of the ini file, OR a ini file creator to really use it.
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