|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with Shell Command From ASP
Hi all
I am trying to create and then run a Batch file which is held on the server. this is a simplified version of my code Set objTextFile = objFSO.CreateTextFile(("C:\test.bat")) objTextFile.WriteLine "net use " objTextFile.WriteLine "Exit" Set objTextFile = Nothing DIM objShell Set objShell = Server.CreateObject("WSCRIPT.SHELL") set WSX = objShell.Run("C:\Test.bat") set ReturnCode = WSX.StdErr set Output = WSX.stdOut strErrorLog = "C:\NetUseErrors.txt" strLog = "C:\NetUseLog.txt" Set objFile = objFSO.OpenTextFile( strErrorLog, 2, True ) objFile.Write( ReturnCode.ReadAll() ) objFile.Close() Set objFile = objFSO.OpenTextFile( strLog, 2, True ) objFile.Write( Output.ReadAll() ) objFile.Close() set objFSO = nothing set objFile = nothing The batch file is created fine and when executed from the server it runs fine. The problem in my code seems to be when i use the shell command, can anybody please help. Thank you |
|
#2
|
|||
|
|||
|
Probably the web server user account doesn't have execute permissions to the batch file or whatever the batch file does.
|
|
#3
|
|||
|
|||
|
Make sure that your IIS user has access to the test.bat file as well, and if you are really accessing a file on the root of your file system you would need to give access to your IIS user. Howerver, this is a VERY, VERY bad idea. There is no reason a web account should have access to the root of your hard drive, it is just uncalled for. Generally, it is good practice to keep your web application confined to the directory in which it is running, whether that be a Virtual Directory or wwwroot. In the rare occassions that you need to access files outside of your file system, be cautions and make sure you've enable parent path's in the IIS site properties dialog.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Help with Shell Command From ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|