batch-file - 批处理+ VBS错误预期语句结束

标签 batch-file vbscript syntax-error

我已经制作了一个批处理文件,该文件应该创建vbscript,该脚本创建由choice命令描述的某个文件的快捷方式。唯一的问题是我不断收到预期的语句结尾错误。我假设这是一个语法错误。
(对不起,因为我是Vb的新手,所以我不能很好地解释它)这是代码

@echo off
Title Dragonball Z
cls
echo Please Type The Number Corosponding To Your Chosen Title
more "%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\Titles.txt"
%SystemRoot%\System32\choice.exe /C 12345 /N /M ":"
if errorlevel 5 goto tlog2
if errorlevel 4 goto tlog
if errorlevel 3 goto t
if errorlevel 2 goto ssw
if errorlevel 1 goto bf

:bf
set DIR=""%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\BUU'S FURY\Dragonball Z Buu's Fury.GBA""
set game="Buus Fury"
goto END

:ssw
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\SUPERSONIC WARRIORS\DragonBall Z Supersonic Warriors.gba"
set game="Supersonic Warriors"
goto END

:t
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\Taiketsu\Dragonball Z Taiketsu.GBA"
set game="Taiketsu"
goto END

:tlog
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\THE LEGACY OF GOKU\Dragonball Z the Legacy of Goku.GBA"
set game="The Legacy of Goku"
goto END

:tlog2
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\THE LEGACY OF GOKU 2\Dragonball Z the Legacy of Goku 2.GBA"
set game="The Legacy of Goku 2"
goto END

:END
set SCRIPT="%USERPROFILE%\Documents\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\%game%.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%
echo oLink.TargetPath = %DIR% >> %SCRIPT%
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%
rem Here I keep getting a Expected End Of statement error
pause

任何帮助将不胜感激

最佳答案

Powershell有很多用途,请尝试以下操作:

@ECHO OFF
Title Dragonball Z
cls
echo Please Type The Number Corosponding To Your Chosen Title
more "%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\Titles.txt"
%SystemRoot%\System32\choice.exe /C 12345 /N /M ":"
if errorlevel 5 goto tlog2
if errorlevel 4 goto tlog
if errorlevel 3 goto t
if errorlevel 2 goto ssw
if errorlevel 1 goto bf

:bf
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\BUU'S FURY\Dragonball Z Buu's Fury.GBA"
set game="Buus Fury"
goto END

:ssw
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\SUPERSONIC WARRIORS\DragonBall Z Supersonic Warriors.gba"
set game="Supersonic Warriors"
goto END

:t
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\Taiketsu\Dragonball Z Taiketsu.GBA"
set game="Taiketsu"
goto END

:tlog
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\THE LEGACY OF GOKU\Dragonball Z the Legacy of Goku.GBA"
set game="The Legacy of Goku"
goto END

:tlog2
set DIR="%USERPROFILE%\Documents\ROMS\GB\DRAGONBALL Z\THE LEGACY OF GOKU 2\Dragonball Z the Legacy of Goku 2.GBA"
set game="The Legacy of Goku 2"
goto END

:END
powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('"%~dp0%game%.LNK"');$s.TargetPath='"%DIR%"';$s.Save()"

pause
goto :EOF

关于batch-file - 批处理+ VBS错误预期语句结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52563951/

相关文章:

r - tidyr::spread() function throws an error

java - 修饰符组合非法 : public and private

java - 如何使用批处理文件无限循环需要参数的 jar 文件?

batch-file - 使用批处理文件添加到 PATH 环境变量(Windows 10)

windows - Windows 批处理文件中的日期解析

vbscript - Visual Basic语句的结尾?

excel - Dax-计算列中变量的语法错误

Windows Batch - 如何修改文件并仅保留以 "<?xml"开头并以 "</testsuites>"结尾的子字符串?

vbscript - VB 使用 WMI - 获取登录用户

powershell - 如何将 PowerShell 变量返回到 VBScript