Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

WScript problem running command prompt

Posted on 2007-10-03
11
Medium Priority
?
274 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:Big Monty
  • 6
  • 5
11 Comments
 
LVL 34

Author Comment

by:Big Monty
ID: 20009478
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
 
LVL 16

Expert Comment

by:golfDoctor
ID: 20009531
"and c:\a.txt does not appear.. ":

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

0
 
LVL 16

Expert Comment

by:golfDoctor
ID: 20009546
And have you tried ---> , 1, true
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Author Comment

by:Big Monty
ID: 20009731
ya that was a typo, sorry about that.

i did try changing it to a 1 but got the same result.
0
 
LVL 16

Expert Comment

by:golfDoctor
ID: 20009753
OK, what if you try a folder within the site root that has modify permissions for IUSR?
0
 
LVL 34

Author Comment

by:Big Monty
ID: 20009783
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
 
LVL 16

Expert Comment

by:golfDoctor
ID: 20009804
"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
 
LVL 16

Accepted Solution

by:
golfDoctor earned 2000 total points
ID: 20009835
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
 
LVL 34

Author Comment

by:Big Monty
ID: 20009885
i see what you're saying. i'll give it a shot and let you know.
0
 
LVL 34

Author Comment

by:Big Monty
ID: 20010177
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
 
LVL 16

Expert Comment

by:golfDoctor
ID: 20010360
great
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Screencast - Getting to Know the Pipeline
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question