0

我试图在 Windows 下制作批处理脚本。建立名为“Ragnarok International”的游戏配置。

并且请不要告诉“Simple Use Installer”,因为制作这个的想法,它的第一个学习批处理,两个包含在“Ragnarok International”的个人自动内容版本中,该软件包,它适用于“Linux / Windows / Mac OS X”用户. 而且我认为它更好地包括一个简单的脚本批处理 Windows ,配置和制作快捷方式。

好吧,我尝试使用以下代码:

@echo off

color A
title Ragnarok International
set DIR="%CD%"
set PWD=%CD%\wine\data\drive_c\software

REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop
FOR /F "usebackq tokens=3 skip=4" %%i in (`REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) DO SET DESKTOPDIR=%%i
FOR /F "usebackq delims=" %%i in (`ECHO %DESKTOPDIR%`) DO SET DESKTOPDIR=%%i
set IRODIR="%DESKTOPDIR%\Ragnarok International"



echo ===========Configuring Software=========
echo.

if exist     "%IRODIR%" (
if not exist "%IRODIR%\Ragnarok Classic.lnk" goto make_icr
if not exist "%IRODIR%\Classic Setup.lnk" goto make_ics
if not exist "%IRODIR%\Setup.lnk" goto make_setup
if not exist "%IRODIR%\Ragnarok Replay.lnk" goto make_replay
if not exist "%IRODIR%\Ragnarok.lnk" goto make_ragnarok
)

cd "%DESKTOPDIR%
echo "Make the Directory"
If NOT exist "%IRODIR%" md "%IRODIR%" goto shortcuts

:shortcuts
echo.
echo "Make the Shorcuts"
echo.

:make_icr
echo "Ragnarok Classic"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%IRODIR%\Ragnarok Classic.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%\ClassicRO.exe" >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.

:make_ics
echo "Classic Setup"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = %IRODIR%\Classic Setup.lnk >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%"\Setup_Classic.exe >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.

:make_setup
echo "Setup"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = %IRODIR%\Setup.lnk >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%"\Setup.exe >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.

:make_replay
echo "Ragnarok Replay"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = %IRODIR%\Ragnarok Replay.lnk >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%"\Ragexe.exe 1rag1 Replay >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%

:make_ragnarok
echo "Ragnarok"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = %IRODIR%\Ragnarok.lnk >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%"\Ragnarok.exe >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.
goto iro

echo ===========Configuring Software=========
pause

:iro
echo.
start /b %windir%\explorer.exe "%IRODIR%"

好吧,错误出现在第一个“如果不存在”中,请告诉我“和”它没有重新整理的命令或功能(它试图读取路径 C:\Documents 和设置)

而另一个失败,它是当脚本尝试制作快捷方式时:C:\DOCUME~1\ADMINI~1\CONFIG~1\Temp\755-14902-9577-25159.vbs(2, 15) Microsoft VBS 脚本编译错误:预期的语句结束

“设置” C:\DOCUME~1\ADMINI~1\CONFIG~1\Temp\31294-32230-10280-4385.vbs(2, 1) Microsoft VB 脚本运行时错误:需要对象:“设置”

那么这不起作用,有人可以帮我修复脚本。我不知道如何批量制作,对我来说它更容易 Bash XD。

4

2 回答 2

2
FOR /F "tokens=2*" %%i in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop^|findstr /C:"REG_SZ" /C:"REG_EXPAND_SZ"') DO SET "DESKTOPDIR=%%j"

我从 VBS 没有任何线索,对不起。

另外,这是不正确的:

If NOT exist "%IRODIR%" md "%IRODIR%" goto shortcuts

你在这里每行只能有一个命令:

If NOT exist "%IRODIR%" (
    md "%IRODIR%"
    goto shortcuts
)
于 2013-09-07T08:06:09.400 回答
0

谢谢大家,这已经解决了。批处理脚本最终代码如下->

@echo off

color A
title Ragnarok International
set DIR="%CD%"
set PWD=%CD%\wine\data\drive_c\software
C:
REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop

FOR /F "tokens=2*" %%i in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop^|findstr /C:"REG_SZ" /C:"REG_EXPAND_SZ"') DO SET "DESKTOPDIR=%%j"

FOR /F "usebackq delims=" %%i in (`ECHO %DESKTOPDIR%`) DO SET DESKTOPDIR=%%i

set IRODIR=%DESKTOPDIR%\Ragnarok International



echo ===========Configuring Software=========
echo.
echo DESKTOPDIR = %DESKTOPDIR%
echo %IRODIR%


cd "%DESKTOPDIR%"
if exist     "%IRODIR%" ( echo.
if not exist "%IRODIR%\Ragnarok Classic.lnk" goto make_icr
if not exist "%IRODIR%\Classic Setup.lnk" goto make_ics
if not exist "%IRODIR%\Setup.lnk" goto make_setup
if not exist "%IRODIR%\Ragnarok Replay.lnk" goto make_replay
if not exist "%IRODIR%\Ragnarok.lnk" goto make_ragnarok
)

:shortcuts
echo.
echo "Make the Directory"
cd "%DESKTOPDIR%"
echo "Make the Shorcuts"

If NOT exist "%IRODIR%" (
    md "%IRODIR%"
    cd "%IRODIR%"
    goto shortcuts
    echo.
)
echo.

:make_icr
echo "Ragnarok Classic"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%IRODIR%\Ragnarok Classic.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%\ClassicRO.exe" >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.

:make_ics
echo "Classic Setup"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%IRODIR%\Classic Setup.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%\Setup_Classic.exe" >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.

:make_setup
echo "Setup"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%IRODIR%\Setup.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%\Setup.exe" >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.

:make_replay
echo "Ragnarok Replay"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%IRODIR%\Ragnarok Replay.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%\Ragexe.exe" >> %SCRIPT%
echo oLink.Arguments = "1rag1 Replay" >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%

:make_ragnarok
echo "Ragnarok"
set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%IRODIR%\Ragnarok.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = "%PWD%\Ragnarok.exe" >> %SCRIPT%
echo oLink.WorkingDirectory = "%PWD%" >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
echo.

echo ===========Configuring Software=========
goto iro

pause

:iro
echo.
start /b %windir%\explorer.exe "%IRODIR%"

这非常适合这个提议,感谢 Endoro 帮助我编写这个脚本。

于 2013-09-07T16:47:16.470 回答