Is there any alternative utility to replace PsExec? If I mostly use batch script for automation work. Due to instability of psexec, like hanging/ not responding, I may need another solution. Can the community advise, thanks.
EDIT:
I have 2 particular issues with psexec.
-
https://superuser.com/questions/168706/cant-start-program-by-psexec-on-windows-server-2003-64-bit
-
I have a ASP.NET web service which only invoking psexec from remote SOAP API calls. Everyday when I check, I can see 10-20 psexec hanging in task manager. During the peak time, the web server receives about 1-5 requests, but it probably lasts for only 5 minutes. Below is my code.
Process psexecProcess = new Process();
ProcessStartInfo psi = new ProcessStartInfo("PsExec.exe");
string psexecArg = "-u " + GetRemoteAccount(serverType)
+ " -p " + GetRemotePW(serverType)
+ " \\\\" + GetManagementServerIP(serverType)
+ " C:\\MyBatchScript.bat " + username;
//set process options
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.CreateNoWindow = true;
psi.Arguments = psexecArg; //set psExec command
psexecProcess.StartInfo = psi;
psexecProcess.Start(); //run PsExec
StreamReader reader1 = psexecProcess.StandardError;
string result1 = reader1.ReadToEnd();
StreamReader reader2 = psexecProcess.StandardOutput;
string result2 = reader1.ReadToEnd();
psexecProcess.WaitForExit();
So that why I feel so frustrated with psexec.Can the community help me find anything wrong with both of these issues? Please advise, thanks.
EDIT2:
I also need an alternative for 64-bit servers (for Windows Server 2003 64-bit).
Best Answer
PowerShell 2 has the ability to do remote execution of files.