vbscript - Passing an argument into a VBS script which passes into a batch file -
vbscript - Passing an argument into a VBS script which passes into a batch file -
i have legacy application doesn't back upwards utilizing default applications defined in windows requires specify specific executable file format opened within application. since microsoft no longer includes modi office default have been looking @ using launching windows image viewer .tif, .tiff, & .bmp files since built windows; microsoft not have direct executable windows image viewer can called forcing me create script executes command calls windows image viewer execute. after research way have been able phone call application open specific file creating batch file such below:
gifts.bat
rundll32.exe c:\windows\system32\shimgvw.dll,imageview_fullscreen %~1
if execute above code such gifts.bat "c:\example directory\sample file.tif" command prompt or application launches , sample file.tif opens without problem; command prompt opens along file when launching application.
upon tried create vbscript hide batch file executing can't seem pass argument if argument has "space" within argument.
gifts.vbs
set wshshell = createobject("wscript.shell") wshshell.run """c:\gifts.bat"" " & wscript.arguments.item(0), 0 set wshshell = nil
if seek execute vbscript command prompt such gifts.vbs "c:\example directory\sample file.tif" application never launches , command prompt returns no message or error. if simplify execute command (removing spaces gifts.vbs "c:\sample_file.tif" application launches file sample_file.tif displayed , there no command prompt displayed when application executes vbscript.
my question how can pass argument vbs script in homecoming passes the batch file when argument contains spaces (which there going spaces since argument file name , path)?
there might easier approach want accomplish; looking solution windows 7 - 8.1 can utilize no additional software install or manage on each workstation. batch files works great need able hide command prompt opens along application end users won't know it.
thanks!
sometimes, nested levels of escaping characters requires intimate knowledge of undocumented behavior of cmd or voodoo. way attack problem guarantee won't have spaces in name of file. windows has concept of short path (no spaces or special chars) every existing file has unique one.
here's modified version of programme invoked subcommand doesn't need quotes around file name.
set wshshell = createobject("wscript.shell") set fso = createobject("scripting.filesystemobject") set fsofile = fso.getfile(wscript.arguments.item(0)) wshshell.run """c:\gifts.bat"" " & fsofile.shortpath, 0 set wshshell = nil
you may wish add together own error checking. specified file must exist in order getfile() command succeed.
batch-file vbscript arguments
Comments
Post a Comment