Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Command Line Script from VBS

Status
Not open for further replies.

thec0dy

IS-IT--Management
Apr 16, 2010
41
US
I need to run the line below in VBS. It is tricky due to the quotes. I need to run the code and any output send to a log file. This is the A-PDF Renaming software I am using. Thanks for you assistance!

for %i in (D:\Centers\CO022\Test\*.pdf) do ""C:\Program Files (x86)\A-PDF Rename\prncmd.exe"" %i ""[%Content_1% ] %Content_2% (%Content_3%)"" -L""C:\Scripts\1.rul"",""C:\Scripts\2.rul"",""C:\Scripts\3.rul"" > ""C:\Scripts\CO022-RPL-Log.txt


Code:
Dim WshShell, fso, file
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso  = CreateObject("Scripting.FileSystemObject")
WshShell.Run("cmd for %i in (D:\Centers\CO022\Test\*.pdf) do ""C:\Program Files (x86)\A-PDF Rename\prncmd.exe"" %i ""[%Content_1% ] %Content_2% (%Content_P3%)"" -L""C:\Scripts\1.rul"",""C:\Scripts\2.rul"",""C:\Scripts\3.rul"" > ""C:\Scripts\CO022-RPL-Log.txt"""),1,false
wscript.quit
 
Why not simply run a .BAT (or .CMD) file ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
When I try to do a .bat it does not like %i in (D:\Centers\CO022\Test\*.pdf). It always comes back with for \Centers\CO022\Test\*.pdf")' do "C:\Program Files (x86)\A-PDF..... It seems to be cutting that first part off (D:

for %i in (D:\Centers\CO022\Test\*.pdf) do ""C:\Program Files (x86)\A-PDF Rename\prncmd.exe"" %i ""[%Content_1% ] %Content_2% (%Content_3%)"" -L""C:\Scripts\1.rul"",""C:\Scripts\2.rul"",""C:\Scripts\3.rul"" > ""C:\Scripts\CO022-RPL-Log.txt
 
In a .bat you should use %%I

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Also, if you are using files, use for /f.

To get all the options in a for loop,type for /?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top