Annoyances.org
Home » Windows XP Discussion Forum » Message 1044370705 » Entire Thread Search | Help | Home
  
Question about 'Run a Shortcut from the Command Prompt'
Showing all messages in thread #1044370705
Windows XP Annoyances Discussion Forum


The following are all of the messages in this thread (32 in all), shown in chronological order. Click any message subject to view that message by itself or to view the thread hierarchy.
Question about 'Run a Shortcut from the Command Prompt'
Tuesday, February 4, 2003 at 6:58 am
Posted by Chris (Hunt) (3 messages posted)

I have a question about Run a Shortcut from the Command Prompt:

Does this work with windows XP? I can't launch a lnk from within a batch file - I just get a command prompt window opening up. I've tried with and without the .exe and with and without including .exe i the name of the shortcut. What could I be doing wrong/ Thanks

[Reply or follow-up to this message]

Tip: Run a free scan for common Windows errors ad

re: Question about 'Run a Shortcut from the Command Prompt'
Tuesday, February 4, 2003 at 9:38 am
Posted by PartieHonteuse (20 messages posted)

don't use quotes around the path....for example if your shortcut file was in this path... C:\testdir\shortcut.exe.lnk in your batch file you'd have.. @echo off cls start C:\testdir\shortcut.exe.lnk end not @echo off cls start "c:\testdir\shortcut.exe.lnk" end even though the little tutorial show's to have quotes around the path, they are incorrect. also make sure the name of your shortcut isnt "shortcut to program.exe" ;-) and if it is make sure you call that exact name start C:\testdir\shortcut to program.exe.lnk hope this helps

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Tuesday, February 4, 2003 at 4:09 pm
Posted by Chris (Hunt) (3 messages posted)

Thanks for the reply. I tried without the quotes but it didn't help. Here is the command I used: start K:\Shortcuts\links\tiki tiki flets.exe.lnk The name of the shortcut is tiki tiki flets I've also renamed the shortcut to tikiflets (tikiflets.lnk)and tried : start K:\Shortcuts\links\tikiflets.exe.lnk start K:\Shortcuts\links\tikiflets.lnk Without success. Any ideas, please? Chris (Hunt)


On Tuesday, February 4, 2003 at 9:38 am, MEsquibel wrote:
>don't use quotes around the path....for example if your shortcut file was in this
>path... C:\testdir\shortcut.exe.lnk in your batch file you'd have..
>
>@echo off
>cls
>start C:\testdir\shortcut.exe.lnk
>end
>
>
>not
>@echo off
>cls
>start "c:\testdir\shortcut.exe.lnk"
>end
>
>even though the little tutorial show's to have quotes around the path, they are incorrect.
>also make sure the name of your shortcut isnt "shortcut to program.exe" ;-) and if
>it is make sure you call that exact name
>
>start C:\testdir\shortcut to program.exe.lnk
>hope this helps

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, March 19, 2003 at 7:39 am
Posted by Revoman (1 messages posted)

I've also run into this problem on XP. the start whatever.lnk works on win 9x and 2k but I haven't been able to get it to work on XP. I do know with Win 2k I was able to run the whatever.lnk without a start command in front. Still haven't found a solution, so any help would be appreciated.


On Tuesday, February 4, 2003 at 4:09 pm, Chris (Hunt) wrote:
>Thanks for the reply. I tried without the quotes but it didn't help. Here is the
>command I used:
>
>start K:\Shortcuts\links\tiki tiki flets.exe.lnk
>
>The name of the shortcut is tiki tiki flets
>
>I've also renamed the shortcut to tikiflets (tikiflets.lnk)and tried :
>
>start K:\Shortcuts\links\tikiflets.exe.lnk
>start K:\Shortcuts\links\tikiflets.lnk
>
>Without success.
>
>Any ideas, please?
>
>Chris (Hunt)
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Friday, May 23, 2003 at 7:19 pm
Posted by Salieri (1 messages posted)

Type the exact filename of the shortcut (with or without a "start" doesn't matter). 
 For example, if the shortcut is to winrar.exe, windows' default filename is 

shortcut to winrar.lnk

typing 

shortcut to winrar.exe.lnk 

won't work because such a file does not exist.

Please tell me whether this helps.

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, June 4, 2003 at 12:02 am
Posted by Vinnie D (1 messages posted)

Here's what I have found (only tested on Windows 2000 server) You can call a shortcut straight from a command line but not from a batch file (weird eh?). So how do you do it? You call a command line first! cmd /k "c:\temp\shortcut.exe.lnk" I tried using cmd /c but that doesn't work (well not with dial up networking links). The only problem is /k leaves an open cmd window. I'm trying to solve that but it is a small price to pay. Use cmd /? to find out more. Cheers V


On Friday, May 23, 2003 at 7:19 pm, Salieri wrote:

>Type the exact filename of the shortcut (with or without a "start" doesn't matter). 
> For example, if the shortcut is to winrar.exe, windows' default filename is 
>
>shortcut to winrar.lnk
>
>typing 
>
>shortcut to winrar.exe.lnk 
>
>won't work because such a file does not exist.
>
>Please tell me whether this helps.

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, June 11, 2003 at 4:20 am
Posted by Daniel (1 messages posted)

I don´t know, but I made the samething at Win2k Professional I haven´t got this error! I just write the full name "project1.exe.lnk". Lets see... rename the file to 8.3 format, and try again! I neather didn´t got command locked I'll see at XP and send back some information []'s xalala


On Wednesday, June 4, 2003 at 12:02 am, Vinnie D wrote:
>Here's what I have found (only tested on Windows 2000 server)
>
>You can call a shortcut straight from a command line but not from a batch file (weird
>eh?). So how do you do it? You call a command line first!
>
>cmd /k "c:\temp\shortcut.exe.lnk"
>
>I tried using cmd /c but that doesn't work (well not with dial up networking links).
>The only problem is /k leaves an open cmd window. I'm trying to solve that but it
>is a small price to pay. Use cmd /? to find out more.
>
>Cheers
>V
>
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, December 31, 2003 at 2:55 am
Posted by Nick C (1 messages posted)

Hi,

I'm having the same problem when running a dialup lnk from a batch file using cmd 
/k where it leaves a window open. Did you find out how to get round the issue?

cheers
Nick C





On Wednesday, June 4, 2003 at 12:02 am, Vinnie D wrote: >Here's what I have found (only tested on Windows 2000 server) > >You can call a shortcut straight from a command line but not from a batch file (weird >eh?). So how do you do it? You call a command line first! > >cmd /k "c:\temp\shortcut.exe.lnk" > >I tried using cmd /c but that doesn't work (well not with dial up networking links). >The only problem is /k leaves an open cmd window. I'm trying to solve that but it >is a small price to pay. Use cmd /? to find out more. > >Cheers >V > >

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Friday, January 30, 2004 at 8:27 am
Posted by Chrisb (1 messages posted)

Use something called appload.exe. That runs shortcuts and other non exe,com,bat etc files...


On Wednesday, December 31, 2003 at 2:55 am, Nick C wrote:

>Hi,
>
>I'm having the same problem when running a dialup lnk from a batch file using cmd 
>/k where it leaves a window open. Did you find out how to get round the issue?
>
>cheers
>Nick C
>
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Sunday, November 28, 2004 at 2:34 am
Posted by Assad E.K. Ebrahim (1 messages posted)

I've had similar difficulties on Windows XP.
It turns out the problem is not with running a shortcut from the command line.  You 
can verify this by running from the command line the Paint.lnk shortcut located in 
your desktop folder.

The problem is with running the dialup connection shortcut from the command-line. 
 This does not seem possible by simply calling the link.

Instead, the DOS shell utility to use is rasdial.  To find out how to use it, open 
a cmd window and type: rasdial /?  

You'll use it in this way: rasdial [Phone Book Entry] [username] [password]

VB6 Example:
  Shell "rasdial ""Connect to Intergate"" myusername@intergate.com mypassword", vbNormalFocus 

Here the doublequotes are because "Connect to Intergate" is the name of my connection 
in the Remote Dialer phonebook, and the spaces in the name force me to use quotes.

Good luck.


[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, December 8, 2004 at 2:42 pm
Posted by jason (1 messages posted)

Hello, I'm writing a simple batch file to load 8 command windows, each executing its own, different process. All of these processes are specified as link files, for example

"f18 lead converted.lnk"

I've tried using the following:

start "f18 lead converted.lnk"

this does not work.

I've had success with the following:

start call "f18 lead converted.lnk"
cmd /k "f18 lead igen_console.lnk"

Here's the problem.
The programs have text based interaction so that I can query them for debugging purposes as they run. This functionality does not work when loading the files with the above commands (the program is unresponsive to my text input).

When I launch the programs by manually clicking on all eight links, the text based interactions functions as they should.

The question:
Why is this? Are there other batch file commands I can use to launch the command windows and my processes so that they are responsive?

This is frustrating :P
Thanks for any help!
-jason


On Sunday, November 28, 2004 at 2:34 am, Assad E.K. Ebrahim wrote:
>I've had similar difficulties on Windows XP.
>It turns out the problem is not with running a shortcut from the command line. You
>can verify this by running from the command line the Paint.lnk shortcut located in
>your desktop folder.
>
>The problem is with running the dialup connection shortcut from the command-line.
> This does not seem possible by simply calling the link.
>
>Instead, the DOS shell utility to use is rasdial. To find out how to use it, open
>a cmd window and type: rasdial /?
>
>You'll use it in this way: rasdial [Phone Book Entry] [username] [password]
>
>VB6 Example:
> Shell "rasdial ""Connect to Intergate"" myusername@intergate.com mypassword", vbNormalFocus
>
>Here the doublequotes are because "Connect to Intergate" is the name of my connection
>in the Remote Dialer phonebook, and the spaces in the name force me to use quotes.
>
>Good luck.
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Sunday, January 30, 2005 at 3:19 pm
Posted by Tom Anselmo (2 messages posted)

I had lots of trouble trying to run outlook express from the command line. The shortcut filename had a space in it 'Outlook Express.lnk'. Then I tried dir /x to get the 8.3 dos name of the shortcut. Then Start EightPointThreeDosFilename.lnk worked perfectly.

[Reply or follow-up to this message]

Why "start" doesn't work
Sunday, February 6, 2005 at 4:29 am
Posted by David Spector (1 messages posted)

If you read the documentation of "start" you will see that the first argument is 
the title of the new command window that "start" creates.

If you omit the first argument, you may get a cmd window that stays in interactive 
mode, waiting for you to type "exit". Or you may get a command window that stays 
on the screen for a fraction of a second then disappears without doing anything.

Sometimes you can get the same effect as "start /wait" (except not redirecting command 
output away from the current window) by adding "&" at the end of the command in the 
batch file.

David







On Tuesday, February 4, 2003 at 6:58 am, Chris (Hunt) wrote:
>I have a question about Run
>a Shortcut from the Command Prompt
:


>
>Does this work with windows XP? I can't launch a lnk from within a batch file - ...

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Friday, March 18, 2005 at 10:40 pm
Posted by Curt (1 messages posted)

here's a solution: go to system in control panel (or hit Windows-key+Break). in the advanced tab, choose environment variables. change the system variable named 'PATHEXT' so that it includes .LNK it should look something like .COM;.EXE;.BAT;.VBS;.JS; .etc.; .LNK then you run a shortcut by typing the name with or without .lnk at the end. like: $> c:\links\firefox where firefox.lnk is the name of the shortcut.


On Wednesday, March 19, 2003 at 7:39 am, Revoman wrote:
>I've also run into this problem on XP. the start whatever.lnk works on win 9x and
>2k but I haven't been able to get it to work on XP. I do know with Win 2k I was
>able to run the whatever.lnk without a start command in front. Still haven't found
>a solution, so any help would be appreciated.
>
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Sunday, August 7, 2005 at 9:21 am
Posted by narc (1 messages posted)

I hate the new behaviour or the Windows XP Start command. The behaviour changes if you are running it from the command line OR if you are running it from a batch file. I like to run batch files and on WinXP they were not working. I was just getting a new command prompt with the application not launching.

Now I got it all figured out. Keep in mind this is for batch file processing. I don't know how it works on the command line yet...

If the file you want to run has spaces in it, then you MUST include the title parameter in quotes and the application path in quotes, such as this:

start "stupid_title" "C:\Program Files\TightVNC\vncviewer.exe"

If you are running a short file name, then you can leave out the title, just be sure to leave out the quotes around the SFN:

start c:\windows\notepad.exe

This should work for .lnk files as well. Hope this helps. - narc


On Friday, March 18, 2005 at 10:40 pm, Curt wrote:
>here's a solution:
>go to system in control panel (or hit Windows-key+Break).
>in the advanced tab, choose environment variables.
>change the system variable named 'PATHEXT'
>so that it includes .LNK
>it should look something like
>.COM;.EXE;.BAT;.VBS;.JS; .etc.; .LNK
>then you run a shortcut by typing the name with or
>without .lnk at the end. like:
>$> c:\links\firefox
>where firefox.lnk is the name of the shortcut.
>
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Friday, November 18, 2005 at 12:02 pm
Posted by Paul Cramer (2 messages posted)

Greetings A related question. I have need to open a cmd window of a specific size from wihtin another application. If a short cut is created to the partictular application I can control the size of the resulting window. However, if I attempt to call the shortcut all the sizing and colrs are ignored. In windows is there a way to contol the size of a window that is opend by another application? THX Paul


On Tuesday, February 4, 2003 at 9:38 am, PartieHonteuse wrote:
>don't use quotes around the path....for example if your shortcut file was in this
>path... C:\testdir\shortcut.exe.lnk in your batch file you'd have..
>
>@echo off
>cls
>start C:\testdir\shortcut.exe.lnk
>end
>
>
>not
>@echo off
>cls
>start "c:\testdir\shortcut.exe.lnk"
>end
>
>even though the little tutorial show's to have quotes around the path, they are incorrect.
>also make sure the name of your shortcut isnt "shortcut to program.exe" ;-) and if
>it is make sure you call that exact name
>
>start C:\testdir\shortcut to program.exe.lnk
>hope this helps

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Friday, November 18, 2005 at 12:21 pm
Posted by Rich Kurtz (12246 messages posted)


Joe's List / 
Falcon's cleanup

Here is a small bat file I call from a program to open a cmd prompt window and launch a program (x editor) within it. @echo off mode con: cols=120 lines=50 x %1 %1 %2 %3 %4 %5 %6 %7 %8 %9


Repair install WinXP / Clean install WinXP

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, November 23, 2005 at 12:53 pm
Posted by Paul Cramer (2 messages posted)

Rich Many thanks, solves the problem nicely.


On a more expansive note is there any way to get a finer grained control as one would have in unix? To open a unix cmd window one could enter a command like: xterm -geometry 80x50-0+0 -fg white -bg blue -font . This would open a terminal window of 80x50 in the upper right corner of the screen with white text on a blue background with a specified font. Any idea if there is any method of gaining this level of control wihtout moving to a more advanced programming language? THX Paul


On Friday, November 18, 2005 at 12:21 pm, Rich Kurtz wrote:
>
>Joe's List
/
>Falcon's cleanup



>Here is a small bat file I call from a program to open a cmd prompt window and launch
>a program (x editor) within it.
>
>@echo off
>mode con: cols=120 lines=50
>x %1 %1 %2 %3 %4 %5 %6 %7 %8 %9
>



>Repair install WinXP
/
>Clean install WinXP

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Thursday, March 16, 2006 at 11:45 pm
Posted by Oisín (1 messages posted)

This is old now, but in case anyone's wondering the same thing, all you need to do here is 'cmd /k "appname arguments & exit"', so the prompt instance will close itself after appname completes.


On Wednesday, December 31, 2003 at 2:55 am, Nick C wrote:
>
>Hi,
>
>I'm having the same problem when running a dialup lnk from a batch file using cmd
>/k where it leaves a window open. Did you find out how to get round the issue?

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Tuesday, July 25, 2006 at 3:23 pm
Posted by Ken Jones (1 messages posted)

Solution: cmd /k "c:\blah_link.lnk & exit" This will execute the link first and then close the dos window.


On Wednesday, June 11, 2003 at 4:20 am, Daniel wrote:
>I don´t know, but I made the samething at Win2k Professional I haven´t got this error!
>I just write the full name "project1.exe.lnk". Lets see... rename the file to 8.3
>format, and try again!
> I neather didn´t got command locked
> I'll see at XP and send back some information
>
>[]'s
>xalala
>

[Reply or follow-up to this message]

re: lnk won't run minimized when executed from cmd
Monday, November 20, 2006 at 11:39 am
Posted by dan (1 messages posted)

using the advice in this thread, i successfully used a bat file (actually, a cron.tab file) to run a shorcut to a bourne shell script on windows. the reason that i'm using a shortcut is to take adantage of the "run minimized" feature. unfortunately, the bat file file runs it maximized. any ideas how to solve this problem? thanks in advance, dan

[Reply or follow-up to this message]

re: lnk won't run minimized when executed from cmd
Tuesday, January 23, 2007 at 11:02 am
Posted by DDB (1 messages posted)

I had such problem that shortcuts from the command prompt could't be runned. Link fix helped me - http://www.dougknox.com/xp/fileassoc/linkfile_fix.zip I created bat file, which runs link with vpn connection. nnCron programm run's this bat file when VPN connection crashes. Feature cmd /k "something & exit" doesn't work because connection needs console and if console closes connection is not done. I solved this problem using feature of nncron to run programs minimized.

[Reply or follow-up to this message]

re: lnk won't run minimized when executed from cmd
Wednesday, April 4, 2007 at 5:24 am
Posted by paul lawrence (1 messages posted)

If you want to run any kind of a batch file minimized, even ones with the 'start' command and prevent the quick flash at the beginning use a .bat to .exe converter and click the "ghost" option. In fact you can combine several batch files and .vbs scripts or other executables all together in one compiled exe using the include option. The one I use is found at http://www.f2ko.de/English/english.html There is a handy .vbs to .exe converter there too!

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Saturday, May 26, 2007 at 6:41 pm
Posted by Sonrisante (1 messages posted)

Chris:

I see this is a very old post and this thread had gone off in many directions. But none of the many responses came up with a simple answer I've found to work for me.

Instead of putting quotes around the entire name, only quote those path-sections that contain spaces. Any that do not contain spaces do not need to be quoted. This is a bit cumbersome, but works (at least in .BAT files, which is when I tend to use them. I don't know about typing into the command line directly; I try to stay away from such manual activity :).)

For example, the following shortcut:

C:\
   Documents and Settings
      All Users
         Start Menu
            Programs
               NUnit 2.4
                  NUnit GUI (.NET 2.0).lnk
would render the following start command:
start C:\"Documents and Settings"\Bob\"Start Menu"\Programs\"NUnit 2.4"\"NUnit 
GUI (.NET 2.0)".lnk
(I'm sure you caught it, but the line above is so long that the message wrapped it. In the batch file it should be a single line of text.)

Hope this helps.
Bob

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, October 3, 2007 at 9:00 pm
Posted by dan-e (1 messages posted)

NICE! OMG Nice nice nice nice! I have been trying to figure this problem out for a long time now, and I've come to the conclusion that MS have disabled the calling of .lnk files due to some kind of security vulnerability. Appload is the way to go for this kind of problem. Get her here and start cheering: http://www.novell.com/coolsolutions/tools/13522.html thankyou so much, this is exactly the util I've needed for a while, it's going into the archive!


On Friday, January 30, 2004 at 8:27 am, Chrisb wrote:
>Use something called appload.exe. That runs shortcuts and other non exe,com,bat
>etc files...
>
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Thursday, April 17, 2008 at 7:41 am
Posted by brunces (1 messages posted)

Guys, I know this is a very old thread, but I'd like to give my contribution. :)

A friend above has taught us to use it like that...

cmd /k "appname arguments & exit"

... and that's correct, I mean, that's how it works. But there's only one detail. Windows XP won't recognize folder or program names with spaces, so we have to type those names in DOS old style (8.3). For example:

cmd /k "C:\MyShortcuts\Window~1.lnk & exit"

... instead of...

cmd /k "C:\MyShortcuts\Windows Live Messenger.lnk & exit"

To figure out the names in 8.3 format, run DOS prompt and enter the folder where your shortcuts are. Then, type DIR /X. With this command, you'll be able to see the names of the shortcuts in DOS old style. That's what you gotta use in your batch files.

Hope this can help you. :)

Cheers,

Bruno

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, May 14, 2008 at 6:23 am
Posted by generic_idea_machine (1 messages posted)

Thanks This is by far the simplest solution and it works.


On Saturday, May 26, 2007 at 6:41 pm, Sonrisante wrote:
>Chris:
>
>

I see this is a very old post and this thread had gone off in many directions.
> But none of the many responses came up with a simple answer I've found to work for
>me.
>
>

Instead of putting quotes around the entire name, only quote those path-sections
>that contain spaces. Any that do not contain spaces do not need to be quoted. This
>is a bit cumbersome, but works (at least in .BAT files, which is when I tend to use
>them. I don't know about typing into the command line directly; I try to stay away
>from such manual activity :).)
>
>

For example, the following shortcut:
>C:\
> Documents and Settings
> All Users
> Start Menu
> Programs
> NUnit 2.4
> NUnit GUI (.NET 2.0).lnk
>
>
>would render the following start command:
>
>start C:\"Documents and Settings"\Bob\"Start Menu"\Programs\"NUnit 2.4"\"NUnit
>GUI (.NET 2.0)".lnk
>
>(I'm sure you caught it, but the line above is so long that the message
>wrapped it. In the batch file it should be a single line of text.)

>

Hope this helps.
>
Bob

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Wednesday, October 21, 2009 at 6:30 am
Posted by Johny Johnson (1 messages posted)

Wow... Hope you all know if you use the code cmd /c "c:\shortcut.lnk" it works fine.. and continues with the batch file....


On Wednesday, May 14, 2008 at 6:23 am, generic_idea_machine wrote:
>Thanks
>
>This is by far the simplest solution and it works.
>
>
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Sunday, March 28, 2010 at 4:14 pm
Posted by bobby boy (1 messages posted)

This is an old thread, but i had the same problem.And for others ,this may help them. If you created the short cut ,by say right clicking the original file and dragging it to a new folder,or desktop and creating the shortcut that way,then you renamed the file with the.lnk extension and then you batch file to that shortcut fails,it's because the file now has 2 .ink extensions.One is completely hidden from normal view(very strange),leaving the other on view! Even if you right click the shortcut file and choose properties,you will still be shown a name with only 1 .ink extension,but you have to click the details tab and then you will see the real file name and it will end in .ink.ink ! This is why your bat files are failing to load your shortcuts,as it is looking for a file which is named e.g runme.lnk ,but it's actually named runme.lnk.lnk ! Why the Os hides it like this is baffling . But i hope that helps anyone coming here in the future. But do remember,if you remove one of the .lnk's ,making the shortcut look as if it now has no .lnk extension,just right click it and look at the details tab,and then just make your bat file as you normally would .


On Wednesday, October 21, 2009 at 6:30 am, Johny Johnson wrote:
>Wow... Hope you all know if you use the code
>cmd /c "c:\shortcut.lnk"
>it works fine.. and continues with the batch file....
>
>
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Thursday, June 24, 2010 at 2:39 am
Posted by Andy Gee (2 messages posted)

I looked around for the solution and found this little gem:
From a batch file call 

rundll32 shell32.dll,ShellExec_RunDLL "C:\path to link\shortcut to program.lnk"







On Tuesday, February 4, 2003 at 6:58 am, Chris (Hunt) wrote:
>I have a question about Run
>a Shortcut from the Command Prompt
:


>
>Does this work with windows XP? I can't launch a lnk from within a batch file -
>I just get a command prompt window opening up. I've tried with and without the .exe
>and with and without including .exe i the name of the shortcut. What could I be doing
>wrong/
>
>Thanks
>

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Sunday, June 27, 2010 at 4:53 am
Posted by brunob75 (1 messages posted)

The 'issue' here is not related specifically to shortcuts (.lnk files) or batch files.

This is the way the start command is designed to work, and it is exactly the same when used from the command line or when trying to launch other executable file types. The same goes when trying to leverage data file type associations to open them from the command line (or batch file).

As has been mentionned above in this page, the first argument to the 'start' command is the desired "Title" for the new window, enclosed between double quotes.

So when using the start command followed by an enquoted string and nothing else, it will launch a new cmd.exe (command prompt) with the provided string as "title". This can be seen right there in the new window title bar.

This is what happens when the full pathname of the target file includes space chars, and you MUST double quote it.

To avoid this, you need to provide a title argument before the pathname of the file you want to launch. This "Title" string can be empty, but the argument needs to be there.

For instance, this command will launch IE just fine :

start "" "c:\Program Files\Internet Explorer\iexplore.exe"

While this one instead will not :

start "c:\Program Files\Internet Explorer\iexplore.exe"

The only thing specific to executable files (defined in your system's %PATHEXT% environment variable) is that the file extension technically needs not be provided.

To avoid any possible confusion though, and potentially create a security exposure, it is a good idea to always explicitly provide it in the command.

[Reply or follow-up to this message]

re: Question about 'Run a Shortcut from the Command Prompt'
Sunday, June 27, 2010 at 7:01 am
Posted by Andy Gee (2 messages posted)

Yes it works with XP (I have XP Pro but I would imagine it's the same)

Here's a working example.
Put this in a batch file and run it. It should load notepad from the link on your 
start menu (assuming you didn't move it).

Note it's all on one line

---------start batch file---------
start rundll32 shell32.dll,ShellExec_RunDLL "C:\Documents and Settings\%username%\Start 
Menu\Programs\Accessories\notepad.lnk"
----------end batch file----------

Good luck

[Reply or follow-up to this message]

Tip: Use one of the [Reply or follow-up to this message] links above to add a message to this thread
Return to the Windows XP Discussion Forum


All content at Annoyances.org is Copyright ©1995-2012 Creative Elementtm All rights reserved.
Please do not plagiarize; redistributing these pages without permission is strictly prohibited.