Calling a batch file from web application
-
Greetings... I'm currently working with IIS 5.1, developing a web app using C#, and testing on win xp pro. One of the functions of the web app is to map a drive letter to a network resource. The way I'm going about this is calling a batch file from the application: System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = @"C:\tmp\testBat.bat"; proc.Start(); The batch file contains the following: copy "C:\tmp\src\test.txt" "C:\tmp\dst\testcopy4.txt" net use X: I've setup impersonation in web.config, and am only using Integrated Windows Authentication in the web app. I also mapped the .bat extension to cmd.exe. When I click the button that's associated with calling the batch file, I can see that the file copy works, but nothing happens with the drive mapping command. (this is accomplished by checking whether the directory exists elsewhere in the code). Any ideas? I hope I posted this to the right place. I'm wondering if it has something to do the particular executable...
-
Greetings... I'm currently working with IIS 5.1, developing a web app using C#, and testing on win xp pro. One of the functions of the web app is to map a drive letter to a network resource. The way I'm going about this is calling a batch file from the application: System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = @"C:\tmp\testBat.bat"; proc.Start(); The batch file contains the following: copy "C:\tmp\src\test.txt" "C:\tmp\dst\testcopy4.txt" net use X: I've setup impersonation in web.config, and am only using Integrated Windows Authentication in the web app. I also mapped the .bat extension to cmd.exe. When I click the button that's associated with calling the batch file, I can see that the file copy works, but nothing happens with the drive mapping command. (this is accomplished by checking whether the directory exists elsewhere in the code). Any ideas? I hope I posted this to the right place. I'm wondering if it has something to do the particular executable...
alchong wrote:
net use X:
Well do you have drive X mapped? what do get if run
net use command
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
alchong wrote:
net use X:
Well do you have drive X mapped? what do get if run
net use command
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
Hi Yusuf, I didn't realize that the rest of the "net use X:" line got hidden because the editor thought it was html because I placed it between brackets. What I meant to say is: net use X: <some network resource path> I didn't review my post closely enough. Apologies! and update of my troubleshooting, when I look at the task manager on my computer, I see that when the batch file executes, cmd.exe and net.exe run under the ASPNET user name. I'm not sure why this is, since I set up impersonation, perhaps I'm missing something in my configuration?
modified on Thursday, April 9, 2009 12:03 PM
-
Hi Yusuf, I didn't realize that the rest of the "net use X:" line got hidden because the editor thought it was html because I placed it between brackets. What I meant to say is: net use X: <some network resource path> I didn't review my post closely enough. Apologies! and update of my troubleshooting, when I look at the task manager on my computer, I see that when the batch file executes, cmd.exe and net.exe run under the ASPNET user name. I'm not sure why this is, since I set up impersonation, perhaps I'm missing something in my configuration?
modified on Thursday, April 9, 2009 12:03 PM
what do you get if you run your batch file manually on the server.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
what do you get if you run your batch file manually on the server.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
When I run the batch file manually it works. Also I edited my last message, but if you didn't catch it, when the batch runs from the web application, I noted that cmd.exe and net.exe run under the ASPNET user name, and do not seem to terminate. Is this something to do with my configuration? I thought I setup impersonation properly.
-
When I run the batch file manually it works. Also I edited my last message, but if you didn't catch it, when the batch runs from the web application, I noted that cmd.exe and net.exe run under the ASPNET user name, and do not seem to terminate. Is this something to do with my configuration? I thought I setup impersonation properly.
alchong wrote:
I noted that cmd.exe and net.exe run under the ASPNET user name, and do not seem to terminate.
You need to set the flag to terminate the command window. I don't remember since it has been very long time. run
cmd /?
and you will figure it out.alchong wrote:
Is this something to do with my configuration? I thought I setup impersonation properly.
I don't know. may be asp.net account can not perform network actions. again this is a guess, I have no proof for that.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
alchong wrote:
I noted that cmd.exe and net.exe run under the ASPNET user name, and do not seem to terminate.
You need to set the flag to terminate the command window. I don't remember since it has been very long time. run
cmd /?
and you will figure it out.alchong wrote:
Is this something to do with my configuration? I thought I setup impersonation properly.
I don't know. may be asp.net account can not perform network actions. again this is a guess, I have no proof for that.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
-
Hi Yusuf, /C was the flag. I guess I'll need to figure out if I can configure impersonation properly to run net.exe & cmd.exe under the web application user credentials instead of the ASPNET account.
Good luck. Let us know your finding. We can all learn from your work. Thanks
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]