the attached file shows how I've been attempting to do
this with mixed results.
the shell run will run an exe but seems unable to launch a
shortcut. shell and shellexecute give type mismatches
regardless of how I 'type' my variables.
Thanks
WshShell.Run, WshShell.Exec, Shell.ShellExecute (plus a few others) can all execute *.lnk files. And they all follow the same rules requiring executable paths that include spaces to be enclosed in quotes...
sPath = "c:\my path with spaces\my pgm with spaces.exe"
won't work when passed to any of the above methods.
sPath = """c:\my path\mypgm.exe"""
sPath = Chr(34) & "c:\my path\mypgm.exe" & Chr(34)
will work because the quotes are included...
--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--
> Finn McGowan wrote:
> > What would be the best way to execute a file from a VBS or
> > WSF file. I have tried Wshell.run, shell and shellexecute.
> > the programs I'm trying to run could be shortcuts, other
> > scripts, URL's and exe's.
> >
> > the attached file shows how I've been attempting to do
> > this with mixed results.
> >
> > the shell run will run an exe but seems unable to launch a
> > shortcut. shell and shellexecute give type mismatches
> > regardless of how I 'type' my variables.
> >
>
> WshShell.Run, WshShell.Exec, Shell.ShellExecute (plus a few others) can all execute *.lnk files.
Hi
At least on Win2k and better, WshShell.Run "drive:\somepath\somefile.lnk" will not work if the lnk-file is made by MSI.
When trying to use the WScript.Shell Run method to start a MSI created link file you will
get this error:
Microsoft VBScript runtime error: Permission denied
--
torgeir
--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com
"Torgeir Bakken" <Torgeir.B...@hydro.com> wrote in message
news:3D7279BA...@hydro.com...
> Torgeir, made by an MSI - or one that points to an MSI, like the Office
> app shortcuts?
Hi
Made by an MSI installation, like e.g. the Office 2k/XP shortcuts. If you select
one of those and select properties, you will see that you can't edit (or really
see) e.g. the target path part.
--
torgeir
"Torgeir Bakken" <Torgeir.B...@hydro.com> wrote in message
news:3D72833C...@hydro.com...
set oShell = CreateObject("wscript.shell")
oShell.run chr(34) & "C:\WINNT\Profiles\All Users\Start Menu\Programs\Administrative Tools\Active Directory Users and
Computers.lnk" & chr(34) >-- 'Error: Permission denied.
oShell.run "rundll32 url.dll,FileProtocolHandler " & "D:\WINNT\Profiles\All Users\Start Menu\Programs\Administrative Tools\Active
Directory Users and Computers.lnk" --> Opens mmc
Try to see if it works on MSI created MS Office shortcuts. Mine are in a custom location...
regards,
--
Gurgen Alaverdian
http://www.gurgensvbstuff.com
"Torgeir Bakken" <Torgeir.B...@hydro.com> wrote in message news:3D7279BA...@hydro.com...
> An old trick should work:
>
> set oShell = CreateObject("wscript.shell")
> oShell.run chr(34) & "C:\WINNT\Profiles\All Users\Start Menu\Programs\Administrative Tools\Active Directory Users and
> Computers.lnk" & chr(34) >-- 'Error: Permission denied.
> oShell.run "rundll32 url.dll,FileProtocolHandler " & "D:\WINNT\Profiles\All Users\Start Menu\Programs\Administrative Tools\Active
> Directory Users and Computers.lnk" --> Opens mmc
>
> Try to see if it works on MSI created MS Office shortcuts. Mine are in a custom location...
Hi
All other methods to launch a shortcut works (e.g. the rundll trick as well as the shell.application ShellExecute method), this has
been discussed in previous threads in the scripting newsgroups. It's the oShell.Run that has problems :(
--
torgeir
--
Please respond in the newsgroup so everyone may benefit.
http://dev.remotenetworktechnology.com
"Gurgen" <gur...@bellatlantic.net> wrote in message
news:wuwc9.10178$VW5....@nwrddc02.gnilink.net...