|
Sosoul
新手上路
积分 12
发帖 5
注册 2008-8-7
状态 离线
|
『楼 主』:
[求助]请大家看看这个脚本有什么问题
找到一段代码,用于设置Windows下的网络连接认证属性
但执行的时候始终提示第2行字符1有8004100E的代码错误
请各位高手指正,谢谢!
const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("Winmgmts:rootdefault:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
Dim oreg2
Set oreg2 = WScript.CreateObject("WScript.Shell")
strKeyPath = "HKLM\" & strKeyPath & "\"
strKeyPath2 = "SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"
binValue = Array(&H05, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H40, &H0d, &H00, &H00, &H00, &H20, &H00, &H00, &H00, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H0d, &H00, &H00, &H00, &H28, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H28, &H00, &H00, &H00, &H05, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00)
For Each subkey In arrSubKeys
strSubkeyPath = strKeyPath & subkey & "\ServiceName"
strValue = oreg2.RegRead(strSubKeyPath)
strSubkeyPath2 = strKeyPath2 & strValue
Returnvalue = oreg.SetBinaryValue(HKEY_LOCAL_MACHINE, strSubkeyPath2, "1", binValue)
If Returnvalue <> 0 Or Err.Number <> 0 Then
oreg.CreateKey HKEY_LOCAL_MACHINE, strSubkeyPath2
oreg.SetBinaryValue HKEY_LOCAL_MACHINE, strSubkeyPath2, "1", binValue
End If
Next
|
|
2008-8-7 13:19 |
|
|
huahua0919
银牌会员
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第
2 楼』:
Set oReg=GetObject("Winmgmts:\\rootdefault\StdRegProv")
|
|
2008-8-7 13:26 |
|
|
Sosoul
新手上路
积分 12
发帖 5
注册 2008-8-7
状态 离线
|
『第
3 楼』:
Quote: | Originally posted by huahua0919 at 2008-8-7 01:26 PM:
Set oReg=GetObject("Winmgmts:\\rootdefault\StdRegProv") |
|
谢谢!
但是运行后提出“远程服务不存在或不可用”
|
|
2008-8-7 13:36 |
|
|
huahua0919
银牌会员
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第
4 楼』:
这个应该是连接到远程主机注册表的。如果对方的注册表禁止远程修改则无效。
或则没指定主机则回出现这样的提示
|
|
2008-8-7 13:47 |
|
|
Sosoul
新手上路
积分 12
发帖 5
注册 2008-8-7
状态 离线
|
『第
5 楼』:
Quote: | Originally posted by huahua0919 at 2008-8-7 01:47 PM:
这个应该是连接到远程主机注册表的。如果对方的注册表禁止远程修改则无效。
或则没指定主机则回出现这样的提示 |
|
Remote Registry服务已经开启
执行这个的目的是获取本机的网络连接,然后修改该网络连接的认证设置
执行的途径是通过域分发,不过现在就在脚本这里卡住了……
|
|
2008-8-7 13:51 |
|
|
huahua0919
银牌会员
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第
6 楼』:
这个我盲
既然是通过域,好象有个ip策略不知可否分发?
|
|
2008-8-7 14:03 |
|
|
Sosoul
新手上路
积分 12
发帖 5
注册 2008-8-7
状态 离线
|
『第
7 楼』:
分发不存在任何问题,就是脚本一直无法被正确执行
也不知道脚本哪个地方错了……
|
|
2008-8-7 14:41 |
|
|
huahua0919
银牌会员
积分 1608
发帖 780
注册 2007-10-7
状态 离线
|
『第
8 楼』:
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
Dim oreg2
Set oreg2 = WScript.CreateObject("WScript.Shell")
strKeyPath = "HKLM\" & strKeyPath & "\"
strKeyPath2 = "SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"
binValue = Array(&H05, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H40, &H0d, &H00, &H00, &H00, &H20, &H00, &H00, &H00, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H0d, &H00, &H00, &H00, &H28, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H28, &H00, &H00, &H00, &H05, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00)
For Each subkey In arrSubKeys
strSubkeyPath = strKeyPath & subkey & "\ServiceName"
strValue = oreg2.RegRead(strSubKeyPath)
strSubkeyPath2 = strKeyPath2 & strValue
Returnvalue = oreg.SetBinaryValue(HKEY_LOCAL_MACHINE, strSubkeyPath2, "1", binValue)
If Returnvalue <> 0 Or Err.Number <> 0 Then
oreg.CreateKey HKEY_LOCAL_MACHINE, strSubkeyPath2
oreg.SetBinaryValue HKEY_LOCAL_MACHINE, strSubkeyPath2, "1", binValue
End If
Next
|
|
2008-8-7 15:11 |
|
|
Sosoul
新手上路
积分 12
发帖 5
注册 2008-8-7
状态 离线
|
『第
9 楼』:
Quote: | Originally posted by huahua0919 at 2008-8-7 03:11 PM:
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\defaul ... |
|
呵呵,终于成功了!其实还差一行
我把完整的补充一下
const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
Dim oreg2
Set oreg2 = WScript.CreateObject("WScript.Shell")
strKeyPath = "HKLM\" & strKeyPath & "\"
strKeyPath2 = "SOFTWARE\Microsoft\EAPOL\Parameters\Interfaces\"
binValue = Array(&H05, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H80, &H04, &H00, &H00, &H00, &H20, &H00, &H00, &H00, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H33, &H11, &H22, &H0d, &H00, &H00, &H00, &H28, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H28, &H00, &H00, &H00, &H05, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00)
For Each subkey In arrSubKeys
strSubkeyPath = strKeyPath & subkey & "\ServiceName"
strValue = oreg2.RegRead(strSubKeyPath)
strSubkeyPath2 = strKeyPath2 & strValue
Returnvalue = oreg.SetBinaryValue(HKEY_LOCAL_MACHINE, strSubkeyPath2, "1", binValue)
If Returnvalue <> 0 Or Err.Number <> 0 Then
oreg.CreateKey HKEY_LOCAL_MACHINE, strSubkeyPath2
oreg.SetBinaryValue HKEY_LOCAL_MACHINE, strSubkeyPath2, "1", binValue
End If
Next
|
|
2008-8-7 15:36 |
|
|