Some Shell commands don't work 
Author Message
 Some Shell commands don't work

There are several commands which not work if you put them in a VBScript.
Such as sort don't work and why is that am I doing something wrong.


Sat, 27 Mar 2004 20:16:05 GMT  
 Some Shell commands don't work
Hi

Sort.exe works from .Run

Could you post your code (and the path\file names you use)? It is much easier to
help then.

Regards,
Torgeir


Quote:
> There are several commands which not work if you put them in a vbScript.
> Such as sort don't work and why is that am I doing something wrong.



Sat, 27 Mar 2004 21:12:31 GMT  
 Some Shell commands don't work
I have found that adding cmd.exe in from of the command you want to execute
will help in these situations.  For example:

Shell.Run("cmd.exe /c notepad")

A few more details

- The /c switch will execute the argument, and close the window
- The /k switch will execute the argument, and keep the window open.  (I
often use this to help debug shell.run problems
- You really should use %comspec% instead of cmd.exe, in case someone is
using a non-default command interpreter.

Hope this helps.


Quote:
> Hi

> Sort.exe works from .Run

> Could you post your code (and the path\file names you use)? It is much
easier to
> help then.

> Regards,
> Torgeir


> > There are several commands which not work if you put them in a vbScript.
> > Such as sort don't work and why is that am I doing something wrong.



Sat, 27 Mar 2004 21:27:50 GMT  
 Some Shell commands don't work
This is the code that I used:

Dim objShell
Set objShell=CreateObject("Wscript.Shell")
objShell.Run "sort <c:\schijven.txt> c:\vijg.txt"
Set objShell = Nothing

Thank you for your support.

Teun.


Quote:
> Hi

> Sort.exe works from .Run

> Could you post your code (and the path\file names you use)? It is much
easier to
> help then.

> Regards,
> Torgeir


> > There are several commands which not work if you put them in a vbScript.
> > Such as sort don't work and why is that am I doing something wrong.



Sat, 27 Mar 2004 21:34:25 GMT  
 Some Shell commands don't work
Hi

You must use "cmd.exe /c" (wnt\w2k) or "command.com /c" (w9x) in friont of DOS
commands. The best thing is to use %comspec% to obtain OS version independency.

You also should use ", 1, True" or  ", 0, True" behind the run statement, or
else your script will not wait for yor command to be finished before continuing!

Description on 0\1 on the line above: 1 will give you a flashing DOS box as the
DOS command is run, 0 will make it invisible.

This should work for you:

Dim objShell
Set objShell=CreateObject("Wscript.Shell")
objShell.Run "%comspec% /c sort <c:\schijven.txt> c:\vijg.txt", 0, True
Set objShell = Nothing

Regards,
Torgeir


Quote:
> This is the code that I used:

> Dim objShell
> Set objShell=CreateObject("Wscript.Shell")
> objShell.Run "sort <c:\schijven.txt> c:\vijg.txt"
> Set objShell = Nothing

> Thank you for your support.

> Teun.



> > Hi

> > Sort.exe works from .Run

> > Could you post your code (and the path\file names you use)? It is much
> easier to
> > help then.

> > Regards,
> > Torgeir


> > > There are several commands which not work if you put them in a vbScript.
> > > Such as sort don't work and why is that am I doing something wrong.



Sat, 27 Mar 2004 22:07:19 GMT  
 Some Shell commands don't work


(snip)

Quote:
> Dim objShell
> Set objShell=CreateObject("Wscript.Shell")
> objShell.Run "%comspec% /c [CMD LINE HERE]", 0, True
> Set objShell = Nothing

(snip)

Nice generic run-and-continue CMD  wrapper - thanks, Torgeir.



Mon, 29 Mar 2004 10:32:46 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Kill/Name function don't work after shell commands

2. Cursor keys don't work in the command window when debugging

3. VB Basic Draw Commands Don't work.

4. MovePrevious don't work but the MoveNext work's fine

5. Shell command doesn't work under WinNT

6. Why doesn't this Shell command work?

7. Script works, script don't work

8. Ghostscript's ps2ascii don't work

9. some time's it works, some time it don't

10. I've programmed a game that don't work Help

11. 'history' command doesn't work

12. Question about 'shell'-command

 

 
Powered by phpBB® Forum Software