Jump to content

VBS script with spaces in executable path


Recommended Posts

Guest Tyler Durden
Posted

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.

  • Replies 3
  • Created
  • Last Reply
Guest David H. Lipman
Posted

Re: VBS script with spaces in executable path

 

From: "Tyler Durden" <abuse@antispam.org>

 

| 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

 

--

Dave

http://www.claymania.com/removal-trojan-adware.html

Multi-AV - http://www.pctipp.ch/downloads/dl/35905.asp

Guest Michael A. Loginov
Posted

Re: VBS script with spaces in executable path

 

Path with spaces should be in quotes. So, modify Your last code row:

 

wSHShell.Run """" & LaunchDir & "\vncviewer.exe" & """" & " -notoolbar

-autoscaling myhost.dyndns.org"

 

Something like this, if I wasn't mistaken...

 

Tyler Durden wrote:

> 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.

>

>

Guest Twayne
Posted

Re: VBS script with spaces in executable path

 

> 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.


×
×
  • Create New...