[thelist] using wscript.shell to run commands

Luther, Ron Ron.Luther at Compaq.com
Fri Jun 18 14:41:56 CDT 2004

Joel D Canfield asked:

>>I'm experimenting with wscript.shell for some automation. This code
>>returns no errors, but it doesn't do anything, either 

>>Anyway, does the code look right?
Dim wshell, intReturn
set wshell = server.createobject("wscript.shell")
intReturn = wshell.run("%comspec% /k cd\ & dir *.*", 1, False)
Response.Write( intReturn )
set wshell = nothing
	<title>Testing WScript.Shell Object</title>

Hi Joel,

A few ideas:

(1) Try moving the Response.Write inside the body tag.

<% Response.Write(junk) %>

(2) I've never tried it that way ... do you have to set up an 
object first? (Kinda like writing the 'dir' command to a record 
set ... and then looping through the rs?)

(3) I'm guessing this is a test case and what you really want to do 
is a lot trickier ... otherwise I'd suggest just grabbing the 
filesystemobject and looping through the files.



More information about the thelist mailing list