WScript.Shell Run Doesn't Work??? 
Author Message
 WScript.Shell Run Doesn't Work???

The following code is used to run command-line Winzip:

    Set oWiSH = CreateObject("WScript.Shell")
    iZipErrCode = oWiSH.Run(sCmd, 1, True)

This works fine after I build sCmd to match the Zip command-line syntax.
One of the options that Winzip allows is a "List" command, which will
display the contents of a zip archive.

From a command-window I can "pipe" the listing to a text-file; the "pipe"
character is ">".  So, the following text, if pasted into a command-window,
will create a textfile called ZipListFile.txt and everything is great:

"E:\WinZip\wzunzip.exe" -vbf "C:\Test.zip">"C:\Temp\ZipListFile.txt"

But if I run it from VB it doesn't do anything.  I'm sure the problem has to
do with the pipe character/command, since the Unzip sub runs fine for all
other operations.  Does anyone know how to get this to work?  Is there some
object besides WScript.Shell I can instantiate to run command-line stuff?

Thanks in advance!



Tue, 03 Feb 2004 22:27:09 GMT  
 WScript.Shell Run Doesn't Work???
I think you can't use redirection outside the command line. You should
prefixe your sCmd variable with "%COMSPEC% /C " in order to run it and close
the shell.

Jean-Luc Antoine.



Quote:
> The following code is used to run command-line Winzip:

>     Set oWiSH = CreateObject("WScript.Shell")
>     iZipErrCode = oWiSH.Run(sCmd, 1, True)

> This works fine after I build sCmd to match the Zip command-line syntax.
> One of the options that Winzip allows is a "List" command, which will
> display the contents of a zip archive.

> From a command-window I can "pipe" the listing to a text-file; the "pipe"
> character is ">".  So, the following text, if pasted into a
command-window,
> will create a textfile called ZipListFile.txt and everything is great:

> "E:\WinZip\wzunzip.exe" -vbf "C:\Test.zip">"C:\Temp\ZipListFile.txt"

> But if I run it from VB it doesn't do anything.  I'm sure the problem has
to
> do with the pipe character/command, since the Unzip sub runs fine for all
> other operations.  Does anyone know how to get this to work?  Is there
some
> object besides WScript.Shell I can instantiate to run command-line stuff?

> Thanks in advance!



Wed, 04 Feb 2004 00:26:57 GMT  
 WScript.Shell Run Doesn't Work???
Hi

This one was a little tricky to run with the possibility to have spaces in all
the file name/paths ;-)

Also you must execute under the command processer to use redirection!

set oWshShell = WScript.CreateObject("WScript.Shell")

sComSpec = "%comspec% /c "
sZipExe = """E:\WinZip\wzunzip.exe"""
sZipExeParam = "-yp -vbf"    ' remove -yp to get rid of the "press any key to
continue" msg.
sZipFile = """C:\Test.zip"""
sZipListFile = """C:\Temp\ZipListFile.txt"""

sCmd = sComSpec & """" & sZipExe & " " & sZipFile & " " & sZipExeParam & ">" &
sZipListFile & """"

Return = oWshShell.Run(sCmd,1,True)

Regards,
Torgeir

Quote:

> The following code is used to run command-line Winzip:

>     Set oWiSH = CreateObject("WScript.Shell")
>     iZipErrCode = oWiSH.Run(sCmd, 1, True)

> This works fine after I build sCmd to match the Zip command-line syntax.
> One of the options that Winzip allows is a "List" command, which will
> display the contents of a zip archive.

> From a command-window I can "pipe" the listing to a text-file; the "pipe"
> character is ">".  So, the following text, if pasted into a command-window,
> will create a textfile called ZipListFile.txt and everything is great:

> "E:\WinZip\wzunzip.exe" -vbf "C:\Test.zip">"C:\Temp\ZipListFile.txt"

> But if I run it from VB it doesn't do anything.  I'm sure the problem has to
> do with the pipe character/command, since the Unzip sub runs fine for all
> other operations.  Does anyone know how to get this to work?  Is there some
> object besides WScript.Shell I can instantiate to run command-line stuff?

> Thanks in advance!



Wed, 04 Feb 2004 02:01:03 GMT  
 WScript.Shell Run Doesn't Work???

Quote:
> set oWshShell = WScript.CreateObject("WScript.Shell")

> sComSpec = "%comspec% /c "
> sZipExe = """E:\WinZip\wzunzip.exe"""
> sZipExeParam = "-yp -vbf"    ' remove -yp to get rid of the "press any key
to
> continue" msg.
> sZipFile = """C:\Test.zip"""
> sZipListFile = """C:\Temp\ZipListFile.txt"""

> sCmd = sComSpec & """" & sZipExe & " " & sZipFile & " " & sZipExeParam &
">" &
> sZipListFile & """"

> Return = oWshShell.Run(sCmd,1,True)

I'd rather use a COM object to hide all that madness:

http://www.vbaccelerator.com/codelib/zip/unzip.htm



Thu, 05 Feb 2004 00:48:47 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Wscript.shell Run doesn't work

2. WScript.GetObject doesn't get running Word App

3. WScript.GetObject doesn't get running Word App

4. Runs, doesn't work..

5. Shell command doesn't work under WinNT

6. shell - why doesn't this work

7. Why doesn't this Shell command work?

8. Shelling .HTM under NT Doesn't Work

9. Advanced : Shell doesn't appear to be running asynchronously

10. fRefreshLinks Doesn't work if path doesn't exist

11. If Field IsNull Then Go to Next Field And Run - Doesn't work HELP

12. Report works 1st time run, then doesn't any more

 

 
Powered by phpBB® Forum Software