Vbscript更改非管理员用户IP

时间:2018-04-14 13:57:18

标签: networking vbscript passwords ip admin

用户登录后我想将其IP网络更改为特定的静态地址。该用户不应该知道管理员的用户密码。

到目前为止,我已经找到了这个vbscript

的成功
'run in elevated mode
If WScript.Arguments.length =0 Then
  Set objShell = CreateObject("Shell.Application")
  'Pass a bogus argument with leading blank space, say [ uac]
  objShell.ShellExecute "wscript.exe", Chr(34) & _
  WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
  'change IP address
strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 

Set colNetAdapters = objWMIService.ExecQuery _ 
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") 
strIPAddress = Array("10.5.0.77") 
strSubnetMask = Array("255.255.255.0") 
strGateway = Array("10.5.0.1") 
strGatewayMetric = Array(1) 

For Each objNetAdapter in colNetAdapters 
    errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask) 
    errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric) 
Next 
End If

问题是这个脚本如何通过管理员密码以便用户不注意它? (没有提示输入管理员密码)

0 个答案:

没有答案