2015-11-13 141 views
2

我想用這樣的批處理文件來創建與圖標桌面快捷方式:如何使用批處理文件在桌面上使用圖標創建快捷方式?

set SCRIPT="%TEMP%\theiboosts1.vbs" 

echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% 
echo sLinkFile = "%USERPROFILE%\Desktop\Internetovy Booster.lnk" >> %SCRIPT% 
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT% 
echo oLink.TargetPath = "c:\Booster\booster.bat" >> %SCRIPT% 
echo oLink.Save >> %SCRIPT% 

"%windir%\system32\timeout.exe" /t 5 

start wscript.exe "%SCRIPT%" 

"%windir%\system32\timeout.exe" /t 10 
echo Const DESKTOP = &H10&>>"%TEMP%\testboost.vbs" 
"%windir%\system32\timeout.exe" /t 5 
echo Set objShell = CreateObject("Shell.Application") >>"%TEMP%\testboost.vbs" 
"%windir%\system32\timeout.exe" /t 5 
echo Set objFolder = objShell.NameSpace(DESKTOP) >>"%TEMP%\testboost.vbs" 
"%windir%\system32\timeout.exe" /t 5 
echo Set objFolderItem = objFolder.ParseName("Internetovy Booster.lnk") >>"%TEMP%\testboost.vbs" 
"%windir%\system32\timeout.exe" /t 5 
echo Set objShortcut = objFolderItem.GetLink >>"%TEMP%\testboost.vbs" 
"%windir%\system32\timeout.exe" /t 5 
echo objShortcut.SetIconLocation "C:\Windows\System32\SHELL32.dll",-16752 >>"%TEMP%\testboost.vbs" 
"%windir%\system32\timeout.exe" /t 5 
echo objShortcut.Save >>"%TEMP%\testboost.vbs" 

"%windir%\system32\timeout.exe" /t 5 

start wscript.exe "%TEMP%\testboost.vbs" 

"%windir%\system32\timeout.exe" /t 5 

但它寫了一個錯誤:

Syntex of the command is incorrect

"%windir%\system32\timeout.exe" /t 10 
之間沒有命令

echo Const DESKTOP = &H10&>>"%TEMP%\testboost.vbs" 

當我創建.vbs文件是否正常工作

Const DESKTOP = &H10& 

Set objShell = CreateObject("Shell.Application") 
Set objFolder = objShell.NameSpace(DESKTOP) 

Set objFolderItem = objFolder.ParseName("Internetovy Booster.lnk") 
Set objShortcut = objFolderItem.GetLink 

objShortcut.SetIconLocation "C:\Windows\System32\SHELL32.dll",-16752 
objShortcut.Save 

有人能幫助我嗎?

回答

1

與號(&)是在批處理文件/ Windows命令外殼特殊字符。它表示當前的命令已經結束並且新的命令正在啓動。

echo Const DESKTOP = &H10&>>"%TEMP%\testboost.vbs" 

實際上是由腳本解釋爲:

echo Const DESKTOP = 
H10 
>>"%TEMP%\testboost.vbs" 

,你只想打印&焦炭這是不正確。 「語法不正確」的錯誤實際上是關於腳本試圖執行H10作爲一個命令(不存在)。

要在字符串中打印&字符,您只需使用批轉義字符 - 卡拉^將其轉義。

echo Const DESKTOP = ^&H10^&>>"%TEMP%\testboost.vbs" 
+0

THX傑森!我忘了我必須在特殊字符之前寫^。 :d – TheGameSpider

相關問題