PowerShell无法找到可执行文件的某些动词 [英] PowerShell cannot find some Verbs of executable
问题描述
我是PowerShell的新手。现在的任务是将某些程序固定到任务栏。此
所以请告诉我为什么以及如何解决此问题,谢谢!
它可能是因为 C:\Windows\
中没有 cmd.exe
,请改用此:
$ cmd =连接路径$ env:SystemRoot'System32\cmd.exe'
注意:我正在使用加入-路径 cmdlet组合路径,并使用 $ env:SystemRoot
检索系统根目录(例如G。 C:\Windows
)
I'm new to PowerShell. Now the task is to pin some programs to the Taskbar. This Tutorial is great and runs well in one of my Win7 32bit in Vmware. But same script cannot run in Win10 32bit in Vmware. So I modified the code and finally found it was because some Verbs are not found. My test code is as following:
CLS
$cmd = 'C:\Windows\System32\cmd.exe'
Test-Path $cmd
$Shell = New-Object -ComObject Shell.Application
$Desktop = $Shell.NameSpace(0X0)
$itemLnk = $Desktop.ParseName($cmd)
$itemVerbs = $itemLnk.Verbs()
Foreach($v in $itemVerbs)
{
write-host $v.Name
}
The ISE is run as admin and the result, as well as 'Verbs' found by mannually right clicking the cmd.exe, are shown as below:
So please tell me why and how to fix this, thank you!
Its probably because there is no cmd.exe
located in C:\Windows\
, use this instead:
$cmd = Join-Path $env:SystemRoot 'System32\cmd.exe'
Note: Im using the Join-Path cmdlet to combine the path and $env:SystemRoot
to retrieve the system root (e. g. C:\Windows
)
这篇关于PowerShell无法找到可执行文件的某些动词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!