我需要一种方法来更改 Java NextGen 插件。我需要事先检查操作系统,以便它进入正确的路径。我有一个检查操作系统的脚本,我已经检查并重新检查了它,它确实有效
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
set objShell = wscript.createobject("wscript.shell")
strComputer = InputBox("Enter PC name:", "JavaNextGen Disable")
strVersion = InputBox("Enter Java Version:", "JavaNextGen Disable")
If ((strComputer <> "") And (strVersion <> "")) Then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
If objOperatingSystem.Caption = "Microsoft Windows 7 Enterprise" Then
wscript.echo strComputer & "Is Windows 7"
Elseif objOperatingSystem.Caption = "Microsoft Windows XP Professional" Then
wscript.echo strComputer & "Is Windows XP"
End If
现在这是我用来更改注册表设置的代码
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Wow6432Node\JavaSoft\Java Plug-in\1.6.0_" & strVersion
strEntryName = "UseNewJavaPlugin"
dwValue = 0
objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, dwValue
wscript.echo strKeyPath
If Not Err.Number = 0 Then
wscript.Echo "Error: "& vbCrLf & strComputer & "Please check to make sure the computer is on the network! And that you have admin rights on the computer!"
Else
wscript.echo strComputer & "NextGen has been turned off."
End If
现在,如果我把它们放在一起,它看起来像这样
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
set objShell = wscript.createobject("wscript.shell")
strComputer = InputBox("Enter PC name:", "JavaNextGen Disable")
strVersion = InputBox("Enter Java Version:", "JavaNextGen Disable")
If ((strComputer <> "") And (strVersion <> "")) Then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
If objOperatingSystem.Caption = "Microsoft Windows 7 Enterprise" Then
strKeyPath = "SOFTWARE\Wow6432Node\JavaSoft\Java Plug-in\1.6.0_" & strVersion
strEntryName = "UseNewJavaPlugin"
dwValue = 0
objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, dwValue
If Not Err.Number = 0 Then
wscript.Echo "Error: "& vbCrLf & strComputer & "Please check to make sure the computer is on the network! And that you have admin rights on the computer!"
Else
wscript.echo strComputer & "NextGen has been turned off."
End If
Elseif objOperatingSystem.Caption = "Microsoft Windows XP Professional" Then
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\JavaSoft\Java Plug-in\1.6.0_" & strVersion
strEntryName = "UseNewJavaPlugin"
dwValue = 0
objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, dwValue
If Not Err.Number = 0 Then
wscript.Echo "Error: "& vbCrLf & strComputer & "Please check to make sure the computer is on the network! And that you have admin rights on the computer!"
Else
wscript.echo strComputer & "NextGen has been turned off."
End If
End If
Next
End If
但是它在这条线之后没有做任何事情,我知道是因为在那之后添加了一个回声,我的屏幕上什么也没有。如果 objOperatingSystem.Caption = "Microsoft Windows 7 Enterprise" 那么