找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
查看: 61|回复: 0

[求助] 在批处理脚本中嵌套使用mshta创建快捷方式出错

[复制链接]
发表于 昨天 21:26 | 显示全部楼层 |阅读模式
因为新版本的系统的mshta组件被移除,所以大量使用mshta的脚本需要更新。

在此过程中,遇到了嵌套使用mshta的情况下,虽然成功地创建快捷方式,但是mshta提示缺少右括号(不嵌套,该指令单独一行时运行正常)。
在保持嵌套的情况下,这段代码有什么办法修复吗?
  1. IF /i "%WinPE%" EQU "1" (
  2.         PECMD.exe LINK %Desktop%\NotePad++,%CD%\Notepad++.exe,,%CD%\Notepad++.exe#0
  3. ) ELSE (
  4.         IF EXIST "%SystemRoot%\System32\mshta.exe" (
  5.                 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")
  6.                 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")
  7.         ) ELSE (
  8.                 IF EXIST "%SystemRoot%\System32\WindowsPowerShell\v1.0\Powershell.exe" (
  9.                         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();"
  10.                         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();"
  11.                 )
  12.         )
  13. )
复制代码


您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1|闽公网安备35020302032614号 )

GMT+8, 2026-3-20 00:41

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表