ASP.NET site hangs when schtasks /v switch is invoked

P

persillade

I have an ASP.NET website in which if a certain button is clicked, it
will enumerate the scheduled tasks on a certain server. I use psexec to
call "schtasks /query /fo list" on a remote server and this runs fine.
However, when I tack on a /v switch to the end of that, the site hangs
up completely, we start getting HTTP 403.9 errors (with only 1
connection to the site), and I eventually have to do an IISRESET to get
everything going again. Below is the code for the btnClick event:

private void btnTasks_Click(object sender, System.EventArgs e)
{
Process p = new Process();
p.StartInfo.FileName = @"C:\windows\system32\psexec.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.Arguments = " \\\\10.20.70.20 schtasks /query /fo list";
p.Start();
p.WaitForExit();;

if ( p.ExitCode != 0 )
{

Response.Write(p.StandardError.ToString());


}
else
{

SkipLines();

Response.Write("<b>Scheduled Tasks<br>");
Response.Write("---------------------------<br></b>");

for (i=1;i<100;i++)
{
string outputline = p.StandardOutput.ReadLine();
Response.Write(outputline + "<br>");

}
}
}


This of course as I said runs fine but just tack on a "/v" switch so
that it reads "p.StartInfo.Arguments = " \\\\10.20.70.20 schtasks
/query /fo list /v" and then we will hang forever. The /v switch runs
fine from a command prompt against remote servers so it is something to
do with ASP.NET possibly and how it handles the redirected output
perhaps? (just guessing here)

Please no posts about using Win32_ScheduledJobs instead of my method as
that only enumerates jobs filed with the "AT" command.

Help much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,056
Messages
2,570,443
Members
47,089
Latest member
Bobby2025b

Latest Threads

Top