我试图在 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。