Using WshShell.Run to launch console app 
Author Message
 Using WshShell.Run to launch console app

I'm trying to run a console app from a WSH script on Win95.  Both
cscript.exe and wscript.exe have the version number 5.0.531.7.

Here's the line:

iResult = WshShell.Run("sed -e ""/^$/q"" test.ngp > temp.txt",_
        1, True)

If I were attempting to execute this in a DOS batch file or directly
at the console prompt, it would look like this:

        sed -e "/^$/q" test.ngp > temp.txt

When the script runs, a console prompt flashes on the screen, but I
can't tell what is happening.  The file temp.txt is not being created,
so I know that something is failing.  The return value is 0 and no VB
error is raised.  The command works perfectly from a batch file or
console prompt.

I've also tried using fully qualified path names:

iResult = WshShell.Run("c:\bat\usr\local\wbin\sed -e ""/^$/q""
D:\Temp3\test.ngp > D:\Temp3\temp.txt", 1, True)

That doesn't help.

What am I doing wrongly?

--
Charles Calvert             |  Software Design/Development
Celtic Wolf, Inc.           |  Project Management
http://www.*-*-*.com/ ;|  Technical Writing
(703) 580-0210              |  Research



Wed, 21 Jan 2004 03:47:14 GMT  
 Using WshShell.Run to launch console app

Quote:
> I'm trying to run a console app from a WSH script on Win95.  Both
> cscript.exe and wscript.exe have the version number 5.0.531.7.

> Here's the line:

> iResult = WshShell.Run("sed -e ""/^$/q"" test.ngp > temp.txt",_
> 1, True)

> If I were attempting to execute this in a DOS batch file or directly
> at the console prompt, it would look like this:

> sed -e "/^$/q" test.ngp > temp.txt

> When the script runs, a console prompt flashes on the screen, but I
> can't tell what is happening.  The file temp.txt is not being created,
> so I know that something is failing.  The return value is 0 and no VB
> error is raised.  The command works perfectly from a batch file or
> console prompt.

Try iResult = WshShell.Run("command /c sed -e ""/^$/q"" test.ngp >
temp.txt", 1, True)

Best regards
Johnny Nielsen



Wed, 21 Jan 2004 17:14:39 GMT  
 Using WshShell.Run to launch console app
On Sat, 4 Aug 2001 11:14:39 +0200, "Johnny Nielsen"


Quote:


>> I'm trying to run a console app from a WSH script on Win95.  Both
>> cscript.exe and wscript.exe have the version number 5.0.531.7.

>> Here's the line:

>> iResult = WshShell.Run("sed -e ""/^$/q"" test.ngp > temp.txt",_
>> 1, True)

>> If I were attempting to execute this in a DOS batch file or directly
>> at the console prompt, it would look like this:

>> sed -e "/^$/q" test.ngp > temp.txt

>> When the script runs, a console prompt flashes on the screen, but I
>> can't tell what is happening.  The file temp.txt is not being created,
>> so I know that something is failing.  The return value is 0 and no VB
>> error is raised.  The command works perfectly from a batch file or
>> console prompt.

>Try iResult = WshShell.Run("command /c sed -e ""/^$/q"" test.ngp >
>temp.txt", 1, True)

That worked, thank you.  "command" is clearly command.com.  %comspec%
appears to work just as well.  What does the "/c" argument do?

--
Charles Calvert             |  Software Design/Development
Celtic Wolf, Inc.           |  Project Management
http://www.celticwolf.com/  |  Technical Writing
(703) 580-0210              |  Research



Thu, 22 Jan 2004 10:05:09 GMT  
 Using WshShell.Run to launch console app

Quote:
> That worked, thank you.  "command" is clearly command.com.  %comspec%
> appears to work just as well.  What does the "/c" argument do?

C:\>command /?
Starts a new instance of the MS-DOS command interpreter.

COMMAND [[drive:]path] [device] [/E:nnnnn] [/P] [/C string] [/MSG]

  [drive:]path    Specifies the directory containing COMMAND.COM file.
  device          Specifies the device to use for command input and output.
  /E:nnnnn        Sets the initial environment size to nnnnn bytes.
  /P              Makes the new command interpreter permanent (can't exit).
  /C string       Carries out the command specified by string, and then stops.
  /MSG            Specifies that all error messages be stored in memory. You
                  need to specify /P with this switch.



Thu, 22 Jan 2004 12:31:33 GMT  
 Using WshShell.Run to launch console app

Quote:
> >Try iResult = WshShell.Run("command /c sed -e ""/^$/q"" test.ngp >
> >temp.txt", 1, True)
> That worked, thank you.  "command" is clearly command.com.  %comspec%
> appears to work just as well.  What does the "/c" argument do?

Strictly speaking %COMSPEC% IS the right way to do it ;-)

There are some situations though where you have to ask for COMMAND. Certain
DOS and DOS/OS2 mixed mode executables malfunction if you try to run them
under CMD (some of the selfextracting Compaq support programs which is
DOS-based is a good example).

The '/C' makes the command interpreter terminate when the command is
finished.

Best regards
Johnny Nielsen



Thu, 22 Jan 2004 20:37:31 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. running console app in same console

2. launch an app using file returned from cgi

3. Launched apps using WSH are invisible!

4. WshShell.Run vs WshShell.Exec

5. runas with WshShell.Exec versus WshShell.Run

6. Using variables in WshShell.Run ("....")

7. using DIR with wshshell.run

8. using DIR with wshshell.run

9. Using a variable within WshShell object and Run method (newbie at work)

10. using DIR with wshshell.run

11. using DIR with wshshell.run

12. Using WshShell.Run with a shortcut

 

 
Powered by phpBB® Forum Software