How to execute an "exe" file

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
shamigc
Junior Coder
Posts: 37
Joined: Wed Oct 22, 2003 11:38 am
Location: Monterrey, Mexico

How to execute an "exe" file

Post by shamigc » Thu Jun 24, 2004 11:34 pm

Hi,

I need to execute an exe file, but I do not know how to do it, Can you help me?, I have the following code:

Sub ZipCompress(ZipFile,FilesToZip)
'ZipFile = Path and filename for the zipped file
'FilesToZip = List of files to zip

Parameters ="[-min] -a " + ZipFile + " " + FilesToZip
Execute "C:\Program Files\Winzip\WINZIP32.EXE" Parameters

End Sub

How can I fix it?

Thanks,
Salvador Hernandez
Thanks,
Salvador Hernandez

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Jun 25, 2004 3:28 am

This looks like a mix of VB and Macro Scheduler.

If you want to run a command to zip files from Macro Scheduler, then you need the command utilities from Winzip. That is available at http://www.winzip.com/wzcline.cgi If you have those, then you can create a line in your Macro Scheduler script that looks something like this:
Let>RP_WAIT=1
Let>Options=-a -k
Let>ZipFile=c:\test.zip
Let>SourceFiles=*.txt
//The next line adds all files with a .txt extension to the Zip file test.zip, keeping the original date.
Run Program>C:\Program Files\Winzip\wzzip %Options% %ZipFile% %SourceFiles%
Let>RP_WAIT=0
You can use variables for the parameters as shown here, or just enter them hard coded. See the WZCLINE.HLP file for more info on the option switches available with the WinZip command line utility.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

shamigc
Junior Coder
Posts: 37
Joined: Wed Oct 22, 2003 11:38 am
Location: Monterrey, Mexico

How to execute an "exe" file from inside a VBScrip

Post by shamigc » Fri Jun 25, 2004 5:02 am

Hi Bob,

Thanks for your help, but I was using the winzip application as an known example, but what I'm looking for is to call an "exe" program, with parameters, from inside a VBScript sub module, without Macro Scheduler commands, Do you know how to do it?

Thanks,
Salvador Hernandez
Thanks,
Salvador Hernandez

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Jun 25, 2004 6:21 am

:idea: Real quick thought is that you may only need to declare your Parameters.
See how close this works for you shamigc:
VBSTART
Sub ZipCompress(ZipFile,FilesToZip)
'ZipFile = Path and filename for the zipped file
'FilesToZip = List of files to zip

dim strParameters as String

Parameters ="[-min] -a " + ZipFile + " " + FilesToZip

Execute "C:\Program Files\Winzip\WINZIP32.EXE" strParameters

End Sub
VBEND
Note: This is an untested quick and dirty thought......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

shamigc
Junior Coder
Posts: 37
Joined: Wed Oct 22, 2003 11:38 am
Location: Monterrey, Mexico

How to run an "exe" from VBScript

Post by shamigc » Fri Jul 09, 2004 4:57 am

Bob,

Thanks, I found how to do it, this is the way:
--------------------------------
VBStart
Sub Principal

set oShell=createobject("WScript.Shell")
Set oProc=oShell.Exec("C:\Program Files\Winzip\WINZIP32.EXE -min -a C:\Temp\Prueba.zip D:\TextAloud\*.mp3")

End Sub

VBEnd

VBRun>Principal
-----------------------------------------
Bye,
Salvador Hernandez

Bob Hansen wrote::idea: Real quick thought is that you may only need to declare your Parameters.
See how close this works for you shamigc:
VBSTART
Sub ZipCompress(ZipFile,FilesToZip)
'ZipFile = Path and filename for the zipped file
'FilesToZip = List of files to zip

dim strParameters as String

Parameters ="[-min] -a " + ZipFile + " " + FilesToZip

Execute "C:\Program Files\Winzip\WINZIP32.EXE" strParameters

End Sub
VBEND
Note: This is an untested quick and dirty thought......
Thanks,
Salvador Hernandez

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Fri Jul 09, 2004 7:23 am

Thanks.shamigc.

Glad to see the feedback. Now we can all add this specific solution into our toolboxes.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts