Run a shortcut with a batch file

Isaac OConnor picture Isaac OConnor · Jul 12, 2016 · Viewed 56.1k times · Source

I am trying to set up multiple steam accounts, and you can instantly launch an account by making a shortcut for it, blah blah blah. The shortcuts works fine but I want to make a batch file to select which account to use, then launch the shortcut for that account. For some reason I can't find out how to launch a shortcut from a batch file. I have searched and searched but I cannot find how. Everything seems to work up until launching the shortcut which does nothing.

Here is my code

    @echo off
    echo Which steam account to use?
    echo ---------------------------
    cd "C:\Program Files (x86)\Steam"
    TIMEOUT 2 >null
    echo 1. user1
    TIMEOUT 2 >null
    echo 2. user2
    set /p account="Select a number. "
    echo %account%
    TIMEOUT 2 >null
    if %account%==1 (
        echo Account "user1" selected.
        TIMEOUT 3 >null
        start "C:\Program Files (x86)\Steam\user1.lnk"
        )
    IF %account%==2 (
        echo Account "user2" selected.
        TIMEOUT 3 >null
        start "C:\Program Files (x86)\Steam\user2.lnk"
        )

Running Windows 8.

Answer

Anon Coward picture Anon Coward · Jul 12, 2016

The help for start contains this tidbit:

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
      [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
      [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B]
      [command/program] [parameters]

    "title"     Title to display in window title bar.

In other words the first quoted string will be used for the title. To launch something with quotes, you need to provide a quoted string before it, like this:

start "" "C:\Program Files (x86)\Steam\user1.lnk"

Since it's not a program with a console window, the contents don't matter, they won't be used.