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 MontyWeb Ninja at largeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeAuthor 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
golfDoctorCommented:
"and c:\a.txt does not appear.. ":

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

golfDoctorCommented:
And have you tried ---> , 1, true
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Big MontyWeb Ninja at largeAuthor Commented:
ya that was a typo, sorry about that.

i did try changing it to a 1 but got the same result.
golfDoctorCommented:
OK, what if you try a folder within the site root that has modify permissions for IUSR?
Big MontyWeb Ninja at largeAuthor 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.
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.
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! :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big MontyWeb Ninja at largeAuthor Commented:
i see what you're saying. i'll give it a shot and let you know.
Big MontyWeb Ninja at largeAuthor 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.
golfDoctorCommented:
great
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.