[英]VBScript Error “End of Statement” in .vbs File with SendKeys Method
[英]Batch+VBS error End of expected statement
我已經制作了一個批處理文件,該文件應該創建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
嘗試像這樣調用vbscript:
@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
cscript //nologo "%~f0?.wsf" //job:VBS
pause
exit /b %errorlevel%
<package> <job id="VBS"> <script language="VBScript">
Set wshShell = CreateObject( "WScript.Shell" )
userProfile = wshShell.ExpandEnvironmentStrings( "%USERPROFILE%" )
game = wshShell.ExpandEnvironmentStrings( "%game%" )
dir1 = wshShell.ExpandEnvironmentStrings( "%dir%" )
Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = userProfile & "\Desktop\" & game & ".lnk"
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = dir1
oLink.Save
</script> </job> </package>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.