WScript problem running command prompt

Hi all,
I have the following code I'm trying to call from an asp script:

      dim shellCommand
      shellCommand = "cmd.exe /c dir > c:\temp\a.txt"
      
      dim i
      i = oScript.Run (shellCommand, 0, True)

The value for i is always 1, indicating an error, although no error messages appear, and c:\a.txt does not appear.. I've set up full permissions to the IUSR account on c:\temp and also gave full permissions to the IUSR account on cmd.exe. cmd.exe is in my system path, and if i omit the /c switch (which closes the cmd window once its done), I see the cmd.exe in the task manager so i know its running.

Any ideas?
B.D.
LVL 34
Big MontySenior Web Developer / CEO of ExchangeTree.org Asked:
Who is Participating?
 
golfDoctorCommented:
The fact is, there is nothing wrong with this code directly from command line:

cmd.exe /c dir > c:\temp\a.txt

However, you are having problems with that call from VBScript.  Odds are its permissions related, so you need to test cmd.exe from location within the "root", not c:\ that you are sure IUSR has MODIFY permissions on.  Just try it! :)
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Author Commented:
i can also just run:

cmd.exe /c dir

and i get the proper return code (which is 0) so it has something to do with writing a file to c:\temp
0
 
golfDoctorCommented:
"and c:\a.txt does not appear.. ":

Are yoiu checking the right folder?  Forgot \temp\.  Was that a typo?

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
golfDoctorCommented:
And have you tried ---> , 1, true
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Author Commented:
ya that was a typo, sorry about that.

i did try changing it to a 1 but got the same result.
0
 
golfDoctorCommented:
OK, what if you try a folder within the site root that has modify permissions for IUSR?
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Author Commented:
earlier on on the script i am writing to a temp file in the same directory so i know i can write to it.
0
 
golfDoctorCommented:
"earlier on on the script i am writing to a temp file in the same directory so i know i can write to it."

Yes, but not using command prompt, right?  command calls with vbscript and FSO are not the same.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Author Commented:
i see what you're saying. i'll give it a shot and let you know.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Author Commented:
thanks for that, it worked!

i just assumed that since i had FSO permissions, I would be able to have execute (modify) permissions, since I had full control checked off in the security properties. anyways, i'll just a use a folder within my website to do whats needed.

Thx again!
B.D.
0
 
golfDoctorCommented:
great
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.