Jump to content
Sign in to follow this  
sstanfie

How do I launch a .lnk

Recommended Posts

sstanfie

Hello. I'm attempting to launch the following shortcut (among other things) in my AutoIt script:

C:\Documents and Settings\All Users\Start Menu\Programs\Gaim\Gaim.lnk

This is how I'm trying it:

Run(@ComSpec & " /k " & @ProgramsCommonDir & "\Programs\Gaim\Gaim.lnk", "")

I'm using /k instead of /c so I can see the error in the cmd window, which says 'C:\Documents' is not recognized as an internal or external command, operable program or batch file.

This works fine:

Run(@ComSpec & " /k " & '"C:\Documents and Settings\All Users\Start Menu\Programs\Gaim\Gaim.lnk"', "")

but, I don't want to hardcode the path... I need to use the @ProgramsCommonDir marco. I know the above example works because the whole path (which has spaces) is enclosed in quotes.

Also, I tried running the .lnk directly, without using @ComSpec, but it didn't work.

I know the macro @ProgramsCommonDir resolves to C:\Documents and Settings\All Users\Start Menu\Programs, but it's apparently not enclosed in quotes, which is why I'm getting the error 'C:\Documents' is not recognized as an internal or external command, operable program or batch file.

What is the best way for me to execute this shortcut? FYI - I have to run the shortcut, not the .exe that the shortcut points to, because it's an MSI advertised shortcut and there are HKCU entries that get created by running the advertised shortcut.

Thanks in advance for your time,

Scott

Share this post


Link to post
Share on other sites
Paulie

Never tried with a .lnk file, but something like this?

Run(@COMSPEC & " /c Start *Filename.lnk*", "", @SW_Maximize)

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

Run(@ComSpec & ' /c gaim.lnk', @DesktopCommonDir, @SW_HIDE)

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
sstanfie

Try this:

Run(@ComSpec & " /c start " & @ProgramsCommonDir & "\Programs\Gaim\Gaim.lnk")

Damn, Paulie beat me.

With this, I get a window that pops up that says "Windows cannot find 'C:\Documents'. I think it's because C:\Documents and Settings\All Users\Start Menu\Programs (which is from @ProgramsCommonDir) is not in quotes. But, I can't put quotes around @ProgramsCommonDir because it'll be treated as literate text, instead of the macro.

Thanks,

Scott

Share this post


Link to post
Share on other sites
sstanfie

Do this then:

Run(@ComSpec & ' /c start "' & @ProgramsCommonDir & '\Programs\Gaim\Gaim.lnk"')

Note the use of single and dbl-quotes.

Ah, I see how to do it now. That worked. Thank you very much for your help.

Scott

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.