objWshell.run "%COMSPEC% /C d:\rd teste", 0, TRUE ????

  • Thread starter news.microsoft.com
  • Start date
N

news.microsoft.com

Hi folks,

I got samples on http://www.aspfaq.com/show.asp?id=2059 and runs ok to dir
ms-dos command, but to others commands like del, rd, deltree, etc... it has
not had any effect, even it has not returned errors.
ANY secret??
Using batch file is possible, but and using "%COMSPEC% /C ??
I read all help from ms-dos to "%COMSPEC% , but untill now I could not find
solution!
thanks!

Set objWshell = CreateObject("WScript.Shell")

objWshell.run "%COMSPEC% /C d:\rd teste", 0, TRUE '»»it has no effect.
objWshell.run "%COMSPEC% /C dir *.txt d:\ > d:\dir.txt", 0, TRUE '»»here
runs OK

Set objWshell = nothing
 
A

Aaron Bertrand - MVP

I got samples on http://www.aspfaq.com/show.asp?id=2059 and runs ok to dir
ms-dos command, but to others commands like del, rd, deltree, etc... it has
not had any effect, even it has not returned errors.

Probably a permissions issue. Try forcing windows authentication in IIS,
and authenticating against the web page with credentials of a user that has
the ability to do those things, and see if the results are different.
 
R

Ray at

news.microsoft.com said:
Hi folks,

I got samples on http://www.aspfaq.com/show.asp?id=2059 and runs ok to dir
ms-dos command, but to others commands like del, rd, deltree, etc... it has
not had any effect, even it has not returned errors.
ANY secret??
Using batch file is possible, but and using "%COMSPEC% /C ??
I read all help from ms-dos to "%COMSPEC% , but untill now I could not find
solution!
thanks!

Set objWshell = CreateObject("WScript.Shell")

objWshell.run "%COMSPEC% /C d:\rd teste", 0, TRUE '»»it has no effect.

With that line, you aren't doing anything. If you want to rd a directory,
use "rd D:\teste."

objWshell.run "%COMSPEC% /C dir *.txt d:\ > d:\dir.txt", 0, TRUE '»»here

That line will execute two separate dir commands. One for *.txt and one for
D:\. Is that what you want? Or do you really want:

dir D:\*.txt

After you get the probable permissions issues fixed as Aarons suggested, you
should delete the spaces before and after the > redirect character.

D:\*.txt>D:\dir.txt

for example.

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top