微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

批处理文件:`调用:Process`

如何解决批处理文件:`调用:Process`

在批处理文件中,我应该如何更改最初按顺序打开的 @for /L %%i in (0,1,9) Do call :Process 950%%i 9500.lnk,9501.lnk,9502.lnk,9503.lnk,9504.lnk,9505.lnk,9506.lnk,9507.lnk,9508.lnk,& 9509.lnk

当我更改了每个快捷方式名称并在四个数字后添加了一些内容时?因为现在我在这四个数字后面添加了不同的东西(使控制台窗口在任务栏上更容易识别),Window 找不到那些快捷方式文件

这是用于自动启动 Halcyon Regions。

这是 Autostart.bat 文件

@Echo Off
: System Autostart of regions
C:
@Echo Starting up Grid services!

cd \Users\Administrator\Desktop\HalcyonGridIcons
start "Whip Assets 1" "Whip Assets 1.lnk"
timeout 40
start "Grid Users 2" "Grid Users 2.lnk"
timeout 3
start "Grid Server 3" "Grid Server 3.lnk"
timeout 3
start "Grid Messaging 4" "Grid Messaging 4.lnk"
timeout 3

@Echo Starting up regions!
start "Grid Aperture 5" "Grid Aperture 5.lnk"
timeout 3
@for /L %%i in (0,9) Do call :Process 950%%i

goto Done

:Process
echo Checking port %1
powershell -ExecutionPolicy Bypass -File C:\RegionChk.ps1 %1
if ERRORLEVEL 2 goto Done
if ERRORLEVEL 1 goto Skip
start "%1" "%1.lnk"    ((Actually,this line might have to be changed?))
timeout 15
:Skip

:Done
: Send email to notify of startup.
 start "Sendmail" "C:\Sendmail.lnk"

它可以正常运行所有五个网格服务,但由于我更改了区域的快捷方式名称,Windows 找不到 9500.lnk9501.lnk 等。

新的快捷方式文件名称相同,只是在数字后附加了区域名称,如:950* region name.lnk

谢谢。

解决方法

echo Checking port %1
SET "region950="
for %%r in (%1*.lnk) do ECHO found %%r&set "region950=%%r"
REM AT this point,%region950% contains the link filename
powershell -ExecutionPolicy Bypass -File C:\RegionChk.ps1 %1

好吧,我不知道您是否需要将 %1(包含,例如 9503)或链接文件名作为 %region950% 放入您的代码的其余部分。您应该小心使用引号 "as necessary since your names appear contain spaces"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。