我有这个代码,我用.bat文件写的,工作得很好,但是突然......它刚停止工作,我不知道发生了什么事情,除了我改变一些文件夹名称
这是我的代码:
@echo off
start /w Files\MySQL\mysql-connector-net-6.6.5.msi
echo MySQL Connector/NET 6.6.5 has been installed.
FOR /F "usebackq delims=" %%i in (`cscript desktop.vbs`) DO SET DESKTOPDIR=%%i
copy Files\DayZAdminApp.exe %DESKTOPDIR%\DayZ Admin Panel
echo.
echo DayZ Admin Panel has been placed onto your desktop.
echo D | xcopy Files\DaRT %desktopdir%\DayZ Admin Panel\Files\DaRT /E /Q
ping 127.0.0.1 -n 2 -w 1000 >nul: 2>nul:
echo.
echo DayZ Admin rCon Tool (DaRT) has been copied.
echo.
copy Files\loadout.exe %DESKTOPDIR%\DayZ Admin Panel\Files
echo Loadout editor has been copied.
echo.
echo.
echo Make sure you keep the folder intact, any missing files will limit the panel's capabilities.
echo.
pause
这是desktop.vbs文件:
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
wscript.echo(strDesktop)`
如果有帮助,这里是输出的屏幕截图:
注意:除了foldernames Files\
和DayZ Admin Panel\
如果我只是弄乱那些foldernames,请告诉我我做错了什么,因为这看起来很漂亮
答案 0 :(得分:2)
您需要在路径周围使用"
,因为包含空格
copy Files\DayZAdminApp.exe "%DESKTOPDIR%\DayZ Admin Panel"
...
echo D | xcopy Files\DaRT "%desktopdir%\DayZ Admin Panel\Files\DaRT" /E /Q
...
copy Files\loadout.exe "%DESKTOPDIR%\DayZ Admin Panel\Files"
答案 1 :(得分:2)
只要路径有空格,您就必须使用引号:"%desktopdir%\DayZ Admin Panel\Files\DaRT"
答案 2 :(得分:-1)
在这种情况下您不需要VBScript帮助,但看起来您将可执行文件的输出重定向到批处理变量时遇到问题,因此我制作了一段代码,希望它能帮助完成类似的任务。
@Echo OFF
Echo --- Test 1 ---
FOR /F "usebackq delims=" %%i IN (cscript desktop.vbs) DO (
SET DESKTOPDIR=%%i
)
Echo %DESKTOPDIR%
Echo --- Test 2 ---
FOR /F "usebackq delims=" %%i IN (%windir%\system32\cscript.exe desktop.vbs) DO (
SET DESKTOPDIR=%%i
)
Echo %DESKTOPDIR%
Pause
输出:
并纠正一个人:
@ECHO OFF
Echo --- Test 1 ---
FOR /F "tokens=*" %%i IN ('cscript.exe desktop.vbs') DO (
SET DESKTOPDIR=%%i
)
ECHO Desktop: %DESKTOPDIR%
REM or...
Echo --- Test 2 ---
FOR /F "usebackq delims=" %%i IN (`cscript.exe desktop.vbs`) DO (
SET DESKTOPDIR=%%i
)
Echo Desktop: %DESKTOPDIR%
Pause