windows 使用批处理文件运行快捷方式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38318719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:37:24  来源:igfitidea点击:

Run a shortcut with a batch file

windowsbatch-filecmdshortcut

提问by Isaac OConnor

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.

我正在尝试设置多个 Steam 帐户,您可以通过为其创建快捷方式来立即启动一个帐户,等等。快捷方式工作正常,但我想制作一个批处理文件来选择要使用的帐户,然后启动该帐户的快捷方式。出于某种原因,我无法找到如何从批处理文件启动快捷方式。我已经搜索和搜索,但我找不到如何。一切似乎都在运行,直到启动什么都不做的快捷方式。

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.

运行 Windows 8。

回答by Anon Coward

The help for startcontains this tidbit:

的帮助start包含以下花絮:

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.

由于它不是带有控制台窗口的程序,因此内容无关紧要,它们不会被使用。