|
|
因为新版本的系统的mshta组件被移除,所以大量使用mshta的脚本需要更新。
在此过程中,遇到了嵌套使用mshta的情况下,虽然成功地创建快捷方式,但是mshta提示缺少右括号(不嵌套,该指令单独一行时运行正常)。
在保持嵌套的情况下,这段代码有什么办法修复吗?
- IF /i "%WinPE%" EQU "1" (
- PECMD.exe LINK %Desktop%\NotePad++,%CD%\Notepad++.exe,,%CD%\Notepad++.exe#0
- ) ELSE (
- IF EXIST "%SystemRoot%\System32\mshta.exe" (
- Start "" /min mshta.exe VBScript:Execute("Set WshShell=CreateObject(""WScript.Shell""):Set Shortcut=WshShell.CreateShortcut(WshShell.SpecialFolders(""Desktop"") & ""\Notepad++.lnk""):Shortcut.TargetPath=""%~dp0Notepad++.exe"":Shortcut.WorkingDirectory=""%~dp0"":Shortcut.Save:close")
- Start "" /min mshta.exe VBScript:Execute("Set WshShell=CreateObject(""WScript.Shell""):Set Shortcut=WshShell.CreateShortcut(WshShell.SpecialFolders(""Programs"") & ""\Notepad++.lnk""):Shortcut.TargetPath=""%~dp0Notepad++.exe"":Shortcut.WorkingDirectory=""%~dp0"":Shortcut.Save:close")
- ) ELSE (
- IF EXIST "%SystemRoot%\System32\WindowsPowerShell\v1.0\Powershell.exe" (
- Powershell.exe -Command "$WshShell = New-Object -ComObject WScript.Shell; $LnkPath = [Environment]::GetFolderPath('Desktop'); $Shortcut = $WshShell.CreateShortcut($LnkPath + '\Notepad++.lnk'); $Shortcut.TargetPath = "%~dp0Notepad++.exe";$Shortcut.WorkingDirectory = "%UserProfile%";$Shortcut.WindowStyle=1;$Shortcut.Save();"
- Powershell.exe -Command "$WshShell = New-Object -ComObject WScript.Shell; $LnkPath = [Environment]::GetFolderPath('Programs'); $Shortcut = $WshShell.CreateShortcut($LnkPath + '\Notepad++.lnk'); $Shortcut.TargetPath = "%~dp0Notepad++.exe";$Shortcut.WorkingDirectory = "%UserProfile%";$Shortcut.WindowStyle=1;$Shortcut.Save();"
- )
- )
- )
复制代码
|
|