在login时使用VBScript来确定是否安装了PowerShell

我的networking上有Win7和XP机器的混合。 每个用户都使用基于VBS的login脚本进行login,对于支持它的客户端,我想要显示一个信息popup窗口,如下所示 。

如何检测是否使用VBScript安装了Powershell?

你可以使用下面的东西。 它读取PowerShell的registry项。 如果读取成功(返回代码0),您将得到相应的消息框,您可以将其切换为其他需要执行的逻辑 – 例如,如果未检测到PowerShell,则安装PowerShell。 请参阅下面的来源链接了解更多信息。

Option Explicit Dim oShell Dim value 'If the key isn't there when we try to read it, an error will be generated 'that we will later test for, so we want to automatically resume execution. On Error Resume Next '#Try reading the registry value Set oShell = CreateObject("WScript.Shell") value = oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\") 'Catch the error If Err.Number = 0 Then 'Error code 0 indicates success MsgBox(Err.Number & "PowerShell is installed.") Else 'Any other error code indicates failure MsgBox(Err.Number & "PowerShell is NOT installed.") End If 

VBScript来检查应用程序的registry(例如.NET): https : //stackoverflow.com/questions/4394607/vbscript-to-check-if-net-2-0-is-installed

registry项来检查PowerShell: http : //blogs.msdn.com/b/powershell/archive/2009/06/25/detection-logic-poweshell-installation.aspx