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.
--
Joe Fawcett (MVP - XML)
"Tyler Durden" <ab...@antispam.org> wrote in message
news:e36RBu%23BJH...@TK2MSFTNGP02.phx.gbl...
"Joe Fawcett" <joefa...@newsgroup.nospam> wrote in message
news:%23hWfYfB...@TK2MSFTNGP06.phx.gbl...
/Al
"Joe Fawcett" <joefa...@newsgroup.nospam> wrote in message
news:%23hWfYfB...@TK2MSFTNGP06.phx.gbl...
"Al Dunbar" <Alan...@hotmail.com.nospaam> wrote in message
news:uSpcc3FC...@TK2MSFTNGP02.phx.gbl...
Dim LaunchDir, FSO, WSHShell
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = WScript.CreateObject("WScript.Shell")
LaunchDir = FSO.GetFolder(".")
LaunchDir = Chr(34) & LaunchDir & "\vncviewer.exe" & Chr(34)
wSHShell.Run LaunchDir & "-notoolbar -autoscaling myhost.dyndns.org"
Thanks!
"Al Dunbar" <Alan...@hotmail.com.nospaam> wrote in message
news:uSpcc3FC...@TK2MSFTNGP02.phx.gbl...
Trying changing your 'Run' line to (watch for wrapping):
wSHShell.Run """" & LaunchDir & "\vncviewer.exe"" -notoolbar -autoscaling
myhost.dyndns.org"
Also, if you are only using the 'Scripting.FileSystemObject' to get the
current directory and nothing else, you can get it from 'WScript.Shell' &
remove the instantiation of 'Scripting.FileSystemObject'
LaunchDir = WSHShell.CurrentDirectory
FYI: The '.CurrentDirectory' method is read/write, so you can use it to
change the current directory as well.
"James Whitlow" <jwhitlow...@bloglines.com> wrote in message
news:%23ZKPDgG...@TK2MSFTNGP02.phx.gbl...
Dim LaunchDir, FSO, WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")
LaunchDir = WSHShell.CurrentDirectory
WSHShell.Run """" & LaunchDir & "\vncviewer.exe"" -notoolbar -autoscaling
myhost.dyndns.org"
"James Whitlow" <jwhitlow...@bloglines.com> wrote in message
news:%23ZKPDgG...@TK2MSFTNGP02.phx.gbl...
I personally think it looks good. Others in the group might have some
helpful comments, though.
The only things that I would do differently would be to add 'Option
Explicit' as the first line to force variable declaration and use some form
of Hungarian Notation to indicate what type your variables are (string,
integer, object, etc.). I think most people prefer 3 letter abbreviations
(ex: strLaunchDir, objWSHShell), I personally prefer 1 letter abbreviations
(ex: sLaunchDir, oWSHShell).
"James Whitlow" <jwhitlow...@bloglines.com> wrote in message
news:uBDZfgHC...@TK2MSFTNGP06.phx.gbl...
Personally, I mistrust the current directory and prefer to explicitly use
the directory where the script is located, i.e.:
replace( WScript.ScriptFullName, WScript.ScriptName, "vncviewer.exe")
This will give the full path to a file called "vncviewer.exe" located in the
same directory as the script itself - even if the current directory has been
changed for some reason, or is pointing elsewhere in case your script is
being executed by another script and not by double-clicking in explorer.
Some will point out that the above replace reference will fail in the event
that the path includes a folder that is a superset of the name of the
script. A more bullet-proof method would use the GetParent method of the
file system object. As an aside, it is almost always better to use the
filename parsing capabilities of FSO instead of string concatenation and
sub-stringing methods to calculate file paths.
/Al
I prefer to use this to sync the current directory to the running script...
shell.CurrentDirectory = WScript.ScriptFullName & "\.."
...which has worked for me 100% of the time, even with scripts executed via
UNC paths.
--
Michael Harris
I hadn't thought of doing it that way, even though I do much the same in
batch files:
@echo off
cls & pushd "%~dp0"
This also works with batch scripts executed via UNC paths, however, it does
this by temporarily mapping the UNC to an available drive letter.
But that said, this would seem to depend on one's personal preference. I
have spent so much of my (vb)scripting time mistrusting (and therefore not
using) the current directory that I'm not so sure I need to adopt it now ;-)
/Al
"Michael Harris" <mikhar.at.mvps.dot.org> wrote in message
news:OYOzhvtC...@TK2MSFTNGP03.phx.gbl...
Assuming that vncviewer.exe and the script are actually in the same
folder...
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")
WSHShell.CurrentDirectory = WScript.ScriptFullName & "\.."
WSHShell.Run "vncviewer.exe -notoolbar -autoscaling myhost.dyndns.org"
--
Michael Harris
"Michael Harris" <mikhar.at.mvps.dot.org> wrote in message
news:OI89cLXD...@TK2MSFTNGP02.phx.gbl...