-
Jul 26th, 2014, 02:25 PM
#1
Thread Starter
Hyperactive Member
Catching PsExec exit codes, most of the time weird/random exit codes.
So I am using PsExec to run remote scripts, packages and programs on certain workgroup computers.
I implemented it simply this way:
vb Code:
psexecprocess.Start()
psexecprocess.WaitForExit()
Dim exitcode As Integer = psexecprocess.ExitCode
If Not exitcode = 0 Then
sbU("PsExec returned exit code: " & exitcode, red, Corp)
If exitcode = 5 Then
sbU("[ " & UserName & " ] doesn't have admin privilages, cannot execute PsExec", red, Corp)
End If
Else
sbU("Finished remotely copying and executing CCleaner package", blue)
End If
sbU is just a function that updates a status bar and writes to a log.
So 5 is an easy one I implemented (the account used does not have remote admin privilages). Everything should be 0 if it's fine so I go else... BUT... it keeps churning out random junk exit codes.
PCAnywhere does it, a deployment script/package for installing/executing portable Teamviewer does it, A script I wrote to run extended cleanmgr (disk cleaner) does it, everything seems to do it.
I am using the method to connect by adding network share $IPC then using psexec commandlines (not passing user/pass directly through psexec -- after reading some security forensics on psexec). This shouldn't matter at all, everything connects and runs fine.
Essentially lets say I run my Extended CleanmGR VBScript it's:
[highlight =vb]psexecprocess.StartInfo.Arguments = "\\" & remoteIP & " -s -i -d /accepteula wscript.exe /nologo C:\SWSetup\CleanerMGR\CleanMGR.vbs"
[/highlight]
The script detects OS, adds the proper registry entries (to preselect extended cleanmgr options) and shell.exec cleanmgr.exe /sagerun (from within the script)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|