Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to run a shortcut LNK file 1

Status
Not open for further replies.

pcast01

Programmer
Joined
Sep 17, 2001
Messages
62
Location
US
I am unable to run a simple .LNK file from vbscript.
I have tried at least 3 different ways.

Attempt one...
Set ss = CreateObject("WScript.Shell")
ss.Run ss.specialfolders("Desktop") & "google.LNK"

Attempt two...
ss.Run "%comspec% /k ""C:\Documents and settings\op74216\Desktop\google.lnk"""

Attempt three...
ss.Run "rundll32.exe url.dll,FileProtocolHandler ""C:\Documents and settings\op74216\Desktop\Google.lnk""", 0, False

Every way gives me an error, [highlight]"The system cannot find the specified file"[/highlight], I can open another text file like this:
ss.run ss.SpecialFolders("Desktop") & "\new.txt"

I have looked all over the web for the correct way to run a shortcut and I have tried all these ways and cannot get it. Any help would be appreciated.. It would seem it should not be this difficult to open a shortcut. I am frustrated....


CHAOS, PANIC, & DISORDER - my work here is done.
 
Why don't you just run what the shortcut does. I presume it goes to (by the name) so can't you just run "iexplore ??

--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Ok well I would but I am just using this as a test.

Its kind of strange....

I am really trying to open another program which I am able to open with referencing the location and executable like normal but it does not come up correctly, the graphics/icons are missing. So, it seems to only work correctly when I just double-click the shortcut and that is why I am trying to do that.

CHAOS, PANIC, & DISORDER - my work here is done.
 
Your first example is missing a \
.specialfolders("Desktop") & "\google.LNK"

The other thing is that it may not be google.lnk, but google.url that you are trying to call.



--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
DM4EVER - I have tried that, it still gives me the error. The Windows Script Host box pops up and says

[highlight]"ERROR: The System cannot find the file specified" [/highlight]

on that line and on [highlight]char: 1[/highlight].

CHAOS, PANIC, & DISORDER - my work here is done.
 
The spaces may be causing issues for you too.
Try:
Set ss = CreateObject("WScript.Shell")
ss.Run Chr(34) & ss.specialfolders("Desktop") & "\google.url" & Chr(34)

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
No luck that time either...

Same error.

CHAOS, PANIC, & DISORDER - my work here is done.
 
Ok, let me take that back. Your exact code works but I want to run a LNK file and it will not work with this code.

Example: ss.Run Chr(34) & ss.specialfolders("Desktop") & "\service.lnk" & Chr(34)

and the google.lnk does not work, but google.url does...

CHAOS, PANIC, & DISORDER - my work here is done.
 
OK, I got it!!!

The shortcut name is: Service
My Shortcurt ran with this code:

ss.Run Chr(34) & ss.specialfolders("Desktop") & "\service" & Chr(34)

Thanks for all the help [highlight]dm4ever[/highlight] and [highlight]TheLad[/highlight]!!! Appreciate it....


CHAOS, PANIC, & DISORDER - my work here is done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top