从批处理文件执行快捷方式链接和不等待应用程序退出 [英] Execute shortcut links from a batch file and don't wait for application to exit

查看:292
本文介绍了从批处理文件执行快捷方式链接和不等待应用程序退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个应用程序,我往往需要在同一时间打开,而不是仅仅在启动文件夹依托在同一时间推出他们(这样我就可以重新开始所有的人,如果有些人在某些时候关闭全天)我以类似的方式对Linux的运行级别的启动链接创建一个完整的快捷方式的文件夹中。因此,该文件夹中我有快捷方式链接类似于:

I have several applications that I tend to need open at the same time, and rather than relying solely on the Startup folder to launch them at the same time (and so I can reopen all of them if some were closed at some point throughout the day) I created a folder full of shortcuts in a similar fashion to Linux's runlevel startup links. So in the folder I have shortcut links similar to:


  • S00 - Outlook.lnk

  • S01 - 记事本++ LNK

  • S02 - Chrome.lnk

  • S03 - Skype.lnk

我创建了一个批处理文件,将遍历所有匹配的命名格式,并推出他们的链接。该批处理文件的内容是目前:

I created a batch file that will loop through all the links that match the naming format and launch them. The contents of that batch file currently is:

@FOR /F "usebackq delims==" %%f IN (`dir /b "S* - *.lnk"`) DO "%%f"

这将推出最让我试试就好了联系,但有些会推出,等待进程退出,从而$ ​​P $从开幕pventing进一步脚本。 有什么办法没有等待进程的批处理​​文件中退出来执行快捷方式?或这是一个失败的事业,我应该寻找一个PowerShell的解决方案呢?

It will launch most of the links I try just fine, but some will launch and wait for the process to exit, thus preventing further scripts from opening. Is there any way to execute the shortcuts without waiting for processes to exit within the batch file? Or is this a lost cause and I should look for a Powershell solution instead?

事情到目前为止,我已经试过:

Things I've tried so far:


  • 更改的内容,

  • Changing the contents to

@FOR /F "usebackq delims==" %%f IN (`dir /b "S* - *.lnk"`) DO START /B /I "%%f"

它启动一个后台进程的命令提示符下,但从来没有真正启动链接的目标。

It launches the command prompt in a background process, but never actually launches the target of the link.

更改的内容,

@FOR /F "usebackq delims==" %%f IN (`dir /b "S* - *.lnk"`) DO %comspec% /k "%%f"

它启动的第一个环节,而是等待。

It launches the first link, but waits.

推荐答案

<一个href=\"http://stackoverflow.com/questions/6139365/execute-shortcut-links-from-a-batch-file-and-dont-wait-for-application-to-exit/6139446#6139446\">dcp's回答尝试它,而不 / B 标志中了正确的方向,但它不是解决办法。显然开始会第一时间带引号的字符串,不管传递给它的参数的顺序,作为新窗口的标题,而不是假设它是可执行文件/命令。因此,当开始工艺推​​出他们的快捷方式链接作为窗口的标题,并启动目录是主要的批处理文件的工作目录。所以我在我的文件,批处理文件更新到以下和它的作品:

dcp's answer pointed in the right direction by trying it without the /B flag, but it wasn't the solution. Apparently START will take the first quoted string, regardless of the order of parameters passed to it, as the title of the new window rather than assuming it is the executable/command. So when the START processes launched they had the shortcut links as the title of the window, and the starting directory was the working directory of the main batch file. So I updated my file to batch file to the following and it works:

@FOR /F "usebackq delims==" %%f IN (`dir /b "S* - *.lnk"`) DO START /B /I "TITLE" "%%f"

这篇关于从批处理文件执行快捷方式链接和不等待应用程序退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆