在PowerShell脚本下面查找正确的CMD命令。
$wshshell = New-Object -ComObject WScript.Shell
$lnk = $wshshell.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\"+"\Internet Explorer.lnk")
$lnk.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe"
$lnk.Save()
试过:
powershell.exe -Command $wshshell = New-Object -ComObject WScript.Shell $lnk = $wshshell.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\"+"\Internet Explorer.lnk") $lnk.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe" $lnk.Save()
At line:1 char:81 + ... ect -ComObject WScript.Shell $lnk = $wshshell.CreateShortcut(C:\Progr ... + ~ Missing ')' in method call. At line:1 char:145 + ... \Accessories"+\Internet Explorer.lnk) $lnk.TargetPath = C:\Program Fi ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The string is missing the terminator: ". + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
答案 0 :(得分:0)
powershell.exe $wshshell = New-Object -ComObject WScript.Shell; $lnk =
$wshshell.CreateShortcut('C:\ProgramData\Microsoft\Windows\Start
Menu\Programs\Accessories\'+'\Internet Explorer.lnk'); $lnk.TargetPath =
'C:\Program Files\Internet Explorer\iexplore.exe'; "$lnk.Save()"
分号完成了这项工作