using WshShell.Exec 
Author Message
 using WshShell.Exec

When using WshShell.Exec or WshShell.run I have a strange
problem where I can use it to do something like:

execSTR = "xcopy " & srcfolderspec & "\*.WAV" & " " & Path
WshShell.run execSTR,0,true                    

and that works but then if I issue:

execSTR = "del " & srcfolderspec & "\*.WAV"
WshShell.run execSTR,0,true

It throws an error. I can pop a msgbox and see the whole
string and then type that string myself into a command
prompt window and it works fine. What is the difference
bettween the wshshell doing the execute and my self doing
it from the command line?



Tue, 11 Oct 2005 22:35:10 GMT  
 using WshShell.Exec
The difference is that Xcopy.exe is an executable, while DEL is an
intrinsic command processor statement.  That is, it is a command for
the Cmd.exe (or Command.com) program.  Therefore, the command
processor needs to be invoked explicitly when using the Run method.
(The command processor is automatically invoked when it hosts the
'command line' console.)

Therefore, it must be use when using .Run as ...

  execSTR = "%comspec% /c del " & srcfolderspec & "\*.WAV"
  WshShell.run execSTR,0,true

or just to be safe, include the comspec in the Run statement ...

  execSTR = "del " & srcfolderspec & "\*.WAV"
  WshShell.run "%comspec% /c " & execSTR,0,true

Then you don't need to 'know' whether it's an intrinsic command or an
executable.

Tom Lavedas
===========

Quote:

> When using WshShell.Exec or WshShell.run I have a strange
> problem where I can use it to do something like:

> execSTR = "xcopy " & srcfolderspec & "\*.WAV" & " " & Path
> WshShell.run execSTR,0,true                        

> and that works but then if I issue:

> execSTR = "del " & srcfolderspec & "\*.WAV"
> WshShell.run execSTR,0,true

> It throws an error. I can pop a msgbox and see the whole
> string and then type that string myself into a command
> prompt window and it works fine. What is the difference
> bettween the wshshell doing the execute and my self doing
> it from the command line?



Wed, 12 Oct 2005 03:40:25 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problem using WshShell.Exec

2. WshShell.Run vs WshShell.Exec

3. runas with WshShell.Exec versus WshShell.Run

4. How to wait for termination of program started with WshShell.Exec

5. - WSHSHELL.EXEC error in ASP Web Page

6. WshShell.Exec Passing Invalid Argument to CL App

7. WshShell.Exec what is wrong?

8. WSH 5.6 WshShell.Exec - Minimized Window?

9. Basic WshShell.Exec problem

10. WshShell.Exec: reaping return codes and waiting for termination

11. q: asynch piping of WshShell.Exec.StdOut

12. WshShell.Exec without command prompt window?

 

 
Powered by phpBB® Forum Software