Use process class to run batch file in web server

G

Guest

I use the following code to run a batch file on the server side but it not working. The code is working fine on a c# window console program. Can anyone help me?

Process myProcess = new Process()
myProcess.StartInfo.FileName = "C:\\mapDrv.bat"
myProcess.StartInfo.CreateNoWindow = true
myProcess.Start();
 
E

Eric Lawrence [MSFT]

It's very unlikely that the ASPNET worker progress has execute permissions
on that batch file. Are you impersonating the caller?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

Z0gS said:
I use the following code to run a batch file on the server side but it not
working. The code is working fine on a c# window console program. Can anyone
help me?
 
G

Guest

Yes I do impersonate an admin account. It can run a exe file but no batch fil

----- Eric Lawrence [MSFT] wrote: ----

It's very unlikely that the ASPNET worker progress has execute permission
on that batch file. Are you impersonating the caller

--
Thanks

Eric Lawrenc
Program Manage
Assistance and Worldwide Service

This posting is provided "AS IS" with no warranties, and confers no rights

Z0gS said:
I use the following code to run a batch file on the server side but it no
working. The code is working fine on a c# window console program. Can anyon
help me
 
E

Eric Lawrence [MSFT]

Perhaps try running @"cmd /k C:\batch.bat" instead of just the batch file
alone?

Z0gS said:
Yes I do impersonate an admin account. It can run a exe file but no batch file

----- Eric Lawrence [MSFT] wrote: -----

It's very unlikely that the ASPNET worker progress has execute permissions
on that batch file. Are you impersonating the caller?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

Z0gS said:
I use the following code to run a batch file on the server side but
it not
working. The code is working fine on a c# window console program. Can anyone
help me?
myProcess.StartInfo.FileName = "C:\\mapDrv.bat";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
 
G

Guest

I got an error, cannot find specific file

----- Eric Lawrence [MSFT] wrote: -----

Perhaps try running @"cmd /k C:\batch.bat" instead of just the batch file
alone?

Z0gS said:
Yes I do impersonate an admin account. It can run a exe file but no batch file
----- Eric Lawrence [MSFT] wrote: -----
It's very unlikely that the ASPNET worker progress has execute
permissions
on that batch file. Are you impersonating the caller?
-- Thanks,
Eric Lawrence
Program Manager
Assistance and Worldwide Services
This posting is provided "AS IS" with no warranties, and confers no rights.
I use the following code to run a batch file on the server side but
it not
working. The code is working fine on a c# window console program. Can anyone
help me?
myProcess.StartInfo.FileName = "C:\\mapDrv.bat";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
 
G

Guest

Try setting permissions for the .bat file to allow the ASPNET_WP account full access in Windows. This solved the problems that I had (Similar to yours.) Obviously it is not a desirable fix.... But it works. I am curious why impersonating didn't work. If you were running with admin privileges, then this ?shouldn’t? have changed anything.
 

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

Top