Dex,
Your code is giving me the following error
Object doesn't support this property or method: 'exec'
Also in my code i dont see the test.txt file physically.
IUSR also has the permission
RG
Main Topics
Browse All TopicsHi
I was trying to run a WScript.Shell command on the server so that i can zip the files in a folder. But to test it out i was trying to just do a simple command
<%
set wshell = server.createobject("wscri
intReturn = wshell.run ("cmd.exe dir *.* > c:\test.txt")
Response.Write(intReturn) ' This returns 0
set wshell = nothing
%>
I have set the permissions of the web folder to Read/Write and also Script Access/Executables
RG
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
@rgarimella:
> I still dont understand why my code did not work. What is the difference
Your Line: intReturn = wshell.run ("cmd.exe dir *.* > c:\test.txt")
Mine Line: intReturn = wshell.run ("%comspec% /c dir *.* > c:\test.txt", 0, True)
1) In mine, I use the environmental COMSPEC, which will contain the full path to the CMD.EXE. Like C:\Winnt\system32\cmd.exe ... It might not work because it can't find cmd.exe.
2) I also added the /c, which tells CMD to run the command, and then exit. Without it, you might end up with a bunch of cmd.exe running on your server with no way to kill them.
3) I also set the last parameter to Run to be "True", which tells it to wait until the program exits before continuning. That way, if there is a delay creating that file, you won't miss it.
HTH,
Dex*
The user must set internet secury preferences to allow scripting on activeX control nor marked as "safe"
The easy way to solve this is including your web site in the "safe zone", and relax the security restrictions on that zone
Another tip, the run method is available from JScript 5.6, and Win2K comes by default with JScript 5.5. So if you want the run method works, you must either update the browser to IE6 or the JScript runtime standalone.
Business Accounts
Answer for Membership
by: DexstarPosted on 2003-12-11 at 11:24:04ID: 9922536
@rgarimella:
pt.shell")
> I was trying to run a WScript.Shell command on the server so that i can zip
> the files in a folder. But to test it out i was trying to just do a simple command
I don't see a question or problem here. The 0 indicates it executed successfully. Also, the IUSR_ is going to need to have write access on the file C:\Test.txt.
What were you expecting?
Try this:
<%
Dim wshell, proc
set wshell = server.createobject("wscri
set proc = wshell.exec("%comspec% /c dir *.*")
' Wait the process to finish
Do While proc.Status = 0
WScript.Sleep 100
Loop
Response.Write proc.StdOut.ReadAll
set wshell = nothing
%>
Hope That Helps,
Dex*