dimanche, septembre 23, 2007

VBScript : Executing an exe containing spaces

First of all VBScript is a scripting language, what wants say a lightweight programming language interpreted on client side. you can create a vbs file to put the code inside, of put in into HTML Tag.

To launch an exe file for exemple :
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run "c:\myapplication.exe"
set wshshell = nothing

if there is no spaces in the path to the EXE including any directories, the script works fine. But if it is not the case and the file path contain spaces like "c:\My application.exe", the script will throw an error "file not found", the resolve this use this syntax :
Set wshShell = WScript.CreateObject ("WSCript.shell")
wshshell.run """c:\myapplication.exe"""
set wshshell = nothing


Find Microsoft script documentation here

Aucun commentaire: