使用 Powershell 打开开始菜单

Tol*_*ani 2 windows-7 start-menu powershell

我目前正在开发业务流程自动化软件,实际上用户操作是由机器人模拟的。我需要将一些信息传递到 Windows 7 的开始菜单,我想知道是否可以使用 powershell 脚本打开 Windows 开始菜单?因为机器人可以理解打开powershell的信息。请任何建议都会很好。

You*_*Git 5

是的,使用一点 VB是可以的。

将此代码复制到记事本中,并另存为startmenu.vbs. [确保它不会保存为 startmenu.vbs.txt]

set wShell=wscript.createobject("wscript.shell")
wShell.sendkeys "^{ESC}"
Set WshShell = Nothing
Run Code Online (Sandbox Code Playgroud)

然后,您可以使用 运行它cscript C:\somefilepath\startmenu.vbs

(显然,您必须指定保存路径)


或者,转换为Powershell解决方案:

$wShell = New-Object -ComObject "wscript.shell"
$wShell.SendKeys("^{ESC}")
Run Code Online (Sandbox Code Playgroud)

可以进一步缩短为:

(New-Object -ComObject "wscript.shell").SendKeys("^{ESC}")  
Run Code Online (Sandbox Code Playgroud)

  • 或缩写为 `(New-Object -ComObject "wscript.shell").SendKeys("^{ESC}")` (4认同)
  • 翻译为 powershell:`$wShell = New-Object -ComObject "wscript.shell"; $wShell.SendKeys("^{ESC}")` (3认同)