P
Paul
Hi,
I'm trying to add a button to an asp.net page that when clicked will
run a batch file on the server. My code which gets executed on the
click event of my button is as follows
Dim ProcessStartInfo As New System.Diagnostics.ProcessStartInfo()
ProcessStartInfo.FileName = "C:\Inetpub\wwwroot\myapp\do.bat"
ProcessStartInfo.WorkingDirectory = "C:\Inetpub\wwwroot\myapp\"
ProcessStartInfo.UseShellExecute = True
ProcessStartInfo.CreateNoWindow = True
System.Diagnostics.Process.Start(ProcessStartInfo)
The batch file unzips a file which is located in the working directory
into the same directory. The executable that is called by the batch
file (which does the unzipping) is also in this directory. I've tested
my batch file by running it in a DOS window and it does what is
expected. However when I execute the code from the asp.net page
nothing works but I don't get an error. (I know that the code is
getting executed because I have stepped through it and when I change
the FileName property to a fictitious value I get an error). I've
tried various combinations of the above i.e. trying to running cmd.exe
passing in the bat file name as ProcessStartInfo.Arguments value,
setting various values for the ProcessStartInfo.WindowStyle etc. I've
given aspnet_wp account full control permissions on all directories I
think may be necessary (e.g. the working directory above, my windows
installation directory when I tried calling cmd.exe etc.). I'm still
sure it has something to do with permissions. If somebody could help
me out I'd be grateful. I know that executing something on the server
is not a good idea and believe me when I say this is not my preferred
approach but I just want to get it working at this stage.
Thanks,
Paul
I'm trying to add a button to an asp.net page that when clicked will
run a batch file on the server. My code which gets executed on the
click event of my button is as follows
Dim ProcessStartInfo As New System.Diagnostics.ProcessStartInfo()
ProcessStartInfo.FileName = "C:\Inetpub\wwwroot\myapp\do.bat"
ProcessStartInfo.WorkingDirectory = "C:\Inetpub\wwwroot\myapp\"
ProcessStartInfo.UseShellExecute = True
ProcessStartInfo.CreateNoWindow = True
System.Diagnostics.Process.Start(ProcessStartInfo)
The batch file unzips a file which is located in the working directory
into the same directory. The executable that is called by the batch
file (which does the unzipping) is also in this directory. I've tested
my batch file by running it in a DOS window and it does what is
expected. However when I execute the code from the asp.net page
nothing works but I don't get an error. (I know that the code is
getting executed because I have stepped through it and when I change
the FileName property to a fictitious value I get an error). I've
tried various combinations of the above i.e. trying to running cmd.exe
passing in the bat file name as ProcessStartInfo.Arguments value,
setting various values for the ProcessStartInfo.WindowStyle etc. I've
given aspnet_wp account full control permissions on all directories I
think may be necessary (e.g. the working directory above, my windows
installation directory when I tried calling cmd.exe etc.). I'm still
sure it has something to do with permissions. If somebody could help
me out I'd be grateful. I know that executing something on the server
is not a good idea and believe me when I say this is not my preferred
approach but I just want to get it working at this stage.
Thanks,
Paul