Link to home
Start Free TrialLog in
Avatar of ezsas
ezsasFlag for Canada

asked on

Windows Shell script in ASP.

Hi,

On our web server, we have an application which was running windows shell commands from ASP page. The syntax we have was
******************************************
Dim WshShell
Set WshShell = Server.CreateObject("WScript.Shell")

ret= WshShell.Run( "c:\windows\system32\find.exe", 1, true)
**************************************************

As the hardware failed on the server, we had to change the physical server. Since then our windows shell commands are not working. We keep getting value for 'ret'=2 with in fraction of second. It looks to me some setting or service needs to be started on the server. If anyone have any clue, why it is not functioning,  please let me know ASAP.

Thanks
Ez
Avatar of Praveen Kumar Chandrashekatr
Praveen Kumar Chandrashekatr
Flag of India image

give us more details like what is the new OS in the new server and also give us the extact error which you are getting.

Also let us know that can you able to use command prompt or ipconfig ...
Avatar of ezsas

ASKER

Only the hardware changed. OS remained same (win Server 2003). The command is something like this ( we have our commands instead of "fine.exe" in the sample line below).

ret= WshShell.Run( "c:\windows\system32\find.exe", 1, true)

There is no error message the return value of 'ret' variable is always 2. Which means error has occured, but it doesn't say what the error is.

The Command is running in fraction of second, which should not be the case
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

c:\windows\system32\find.exe  by itself with no parameters returns a 2 and a usage statement:  FIND: Parameter format not correct

From a command prompt:
c:\windows\system32\find.exe
echo %ERRORLEVEL%

You should see "2"

If you actually find something:
c:\windows\system32\find.exe "Some text string" *.txt
echo %ERRORLEVEL%

You should see a 1.


There is an arguments property where you can add parameters for the find:
http://msdn.microsoft.com/en-us/library/yf7kaky2%28v=vs.84%29.aspx

If the script didn't change, these must have been set somewhere else on the old server.

What is it you are trying to 'find'?
Avatar of ezsas

ASKER

I am sorry. my question was not clear. I know 'find.exe' needs parameters. I have my own command , which will not make any sense to you, so I replaced with some generic command to explain the point. I have some long command which works very well when I issue it from the command prompt but not thru the ASP winshell script. I am printing the winshell command by using 'response.write' and I am just copying the command on the prompt and it works perfectly this way. When the same command is issued thru ASP I think the command is not at all getting executed and is returning the value '2'.

My feeling is there is something (or service) that  I have to set on the server which I am not recollecting.

Hope I made it more  clear now.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial