VBS script with spaces in executable path

T

Tyler Durden

I'm trying to write a vbs to run vncviewer on a relative path. The following
code works, except when the path has spaces:

Dim LaunchDir, FSO, WSHShell
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("WScript.Shell")
LaunchDir = FSO.GetFolder(".")

wSHShell.Run LaunchDir & "\vncviewer.exe -notoolbar -autoscaling
myhost.dyndns.org"

Where's the error?
Any help would be appreciated.
 
D

David H. Lipman

From: "Tyler Durden" <[email protected]>

| I'm trying to write a vbs to run vncviewer on a relative path. The following
| code works, except when the path has spaces:

| Dim LaunchDir, FSO, WSHShell
| Set FSO = CreateObject("Scripting.FileSystemObject")
| Set WSHShell = WScript.CreateObject("WScript.Shell")
| LaunchDir = FSO.GetFolder(".")

| wSHShell.Run LaunchDir & "\vncviewer.exe -notoolbar -autoscaling
| myhost.dyndns.org"

| Where's the error?
| Any help would be appreciated.


I suggest asking here... microsoft.public.windows.server.scripting
 
T

Twayne

I'm trying to write a vbs to run vncviewer on a relative path. The
following code works, except when the path has spaces:

Dim LaunchDir, FSO, WSHShell
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("WScript.Shell")
LaunchDir = FSO.GetFolder(".")

wSHShell.Run LaunchDir & "\vncviewer.exe -notoolbar -autoscaling
myhost.dyndns.org"

Where's the error?
Any help would be appreciated.

Put quotes around the paths. e.g. "c:\path\...\...\" Then it sees the
entire path, not just part of it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top