Reputation: 377
I've got this code which I've written in a .bat file, which worked perfectly, but suddenly... it just stopped working, I have no idea what happened to it other than me changing a few folder names.
Here's my code:
@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
And here's the desktop.vbs file:
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
wscript.echo(strDesktop)`
and in case it helps, here's a screenshot of the output:
Note: My code worked just fine when it was exactly the same except for the foldernames Files\
and DayZ Admin Panel\
If it's me just mucking up those foldernames, please tell me what I did wrong, because this looks pretty
Upvotes: 0
Views: 644
Reputation: 3179
You not need VBScript assistance in this case, but looks like you have problem with redirecting the output of an executable into a batch variable, therefore I made a piece of code with hope it w'd helps in similar tasks.
@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
Output:
And correct one one s'd be:
@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
Upvotes: -1
Reputation: 8488
You have to use quotes whenever paths have spaces: "%desktopdir%\DayZ Admin Panel\Files\DaRT"
Upvotes: 2
Reputation: 5148
You need to use "
around your paths, since the contain spaces
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"
Upvotes: 2