引用LocalSecurityAuthority.au3的问题
本帖最后由 jiayun 于 2009-9-28 18:26 编辑代码如下:
#include <LocalSecurityAuthority.au3>
If Not @Compiled Then Exit(Msgbox(48, '', 'Compile first!'))
MsgBox(0,"",$CmdLine)
If $CmdLine = 0 Then
_CreateProcessAsSystem(@ScriptFullPath, " -System", "WinLogon.exe")
Exit
EndIf
Msgbox(0, '', "现在是SYSTEM权限,这里加一些操作代码。")
编译后执行错误提示如下:
错误信息:
Line -1:
Error:子脚本使用了非数组变量
大家帮我看看什么问题,谢谢。 你使用上面的代码,目的是什么,创建系统级进程吗? 恩,写了一段改IP的代码,用WMI来改的,
要管理员才行。我想干脆用Styme来运行好了。
下面是以前的代码,想在Styme下运行
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <GuiIPAddress.au3>
$MainForm = GUICreate("IP Change - YangZB", 680, 190, @DesktopWidth / 2 - 680 / 2, @DesktopHeight / 3 - 190/3)
$LabSelectCard = GUICtrlCreateLabel("选择网卡:", 8, 8, 64,20, $SS_RIGHT)
$CmbCard = GUICtrlCreateCombo ("", 75, 5,525, 21, $CBS_DROPDOWNLIST)
$ButRefreshCard=GUICtrlCreateButton ("刷新",605,4,70,21,$BS_FLAT)
$GroupCurIP = GUICtrlCreateGroup("当前IP配置 ", 8, 30, 200, 150)
$LabCurIP = GUICtrlCreateLabel("I P 地址:", 16, 55, 64, 20, $SS_RIGHT)
$SysCurIP = _GUICtrlIpAddressCreate($MainForm, 90, 53, 110, 21, $WS_CHILD)
$LabCurMask = GUICtrlCreateLabel("子网掩码:", 16, 80, 64, 20, $SS_RIGHT)
$SysCurMask = _GUICtrlIpAddressCreate($MainForm, 90, 78, 110, 21, $WS_CHILD)
$LabCurGateway = GUICtrlCreateLabel("默认网关:",16, 105, 64, 20, $SS_RIGHT)
$SysCurGateway= _GUICtrlIpAddressCreate($MainForm, 90, 102, 110, 21, $WS_CHILD)
$LabCurPDNS = GUICtrlCreateLabel("首选 DNS:", 16, 130, 64, 20, $SS_RIGHT)
$SysCurPDNS= _GUICtrlIpAddressCreate($MainForm, 90, 128, 110, 21, $WS_CHILD)
$LabCurADNS = GUICtrlCreateLabel("备用 DNS:", 16, 155, 64, 20, $SS_RIGHT)
$SysCurADNS= _GUICtrlIpAddressCreate($MainForm, 90, 152, 110, 21, $WS_CHILD)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupNewIP = GUICtrlCreateGroup("IP设置 ",218, 30, 200, 150)
$LabNewIP = GUICtrlCreateLabel("I P 地址:", 226, 55, 64, 20, $SS_RIGHT)
$SysNewIP = _GUICtrlIpAddressCreate($MainForm, 300, 53, 110, 21, $WS_CHILD)
$LabNewMask = GUICtrlCreateLabel("子网掩码:", 226, 80, 64, 20, $SS_RIGHT)
$SysNewMask = _GUICtrlIpAddressCreate($MainForm, 300, 78, 110, 21, $WS_CHILD)
$LabNewGateway = GUICtrlCreateLabel("默认网关:",226 ,105, 64, 20, $SS_RIGHT)
$SysNewGateway= _GUICtrlIpAddressCreate($MainForm, 300, 102, 110, 21, $WS_CHILD)
$LabNewPDNS = GUICtrlCreateLabel("首选 DNS:", 226, 130, 64, 20, $SS_RIGHT)
$SysNewPDNS= _GUICtrlIpAddressCreate($MainForm, 300, 128, 110, 21, $WS_CHILD)
$LabNewADNS = GUICtrlCreateLabel("备用 DNS:", 226, 155, 64, 20, $SS_RIGHT)
$SysNewADNS= _GUICtrlIpAddressCreate($MainForm, 300, 152, 110, 21, $WS_CHILD)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$GroupSelectIP = GUICtrlCreateGroup("IP配置表 ",428, 30, 245, 150)
$ButSetIP = GUICtrlCreateButton("切换配置", 600, 45, 65, 28, $BS_FLAT)
$ButEditIP = GUICtrlCreateButton("修改配置", 600, 78, 65, 28, $BS_FLAT)
$ButAddIP = GUICtrlCreateButton("添加配置", 600 ,111, 65, 28, $BS_FLAT)
$ButDeleteIP = GUICtrlCreateButton("删除配置", 600, 144, 65, 28, $BS_FLAT)
$LstSelectIP = GUICtrlCreateList("", 435, 45, 160, 135)
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
If $SectionNames <> 1 Then
For $i = 1 To $SectionNames
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $SectionNames)
Next
Else
Dim $SectionNames
$SectionNames = ""
EndIf
GUICtrlCreateGroup("", -99, -99, 1, 1)
_GetCard()
_CurrentIPConfig()
_ShowSelectIP(GUICtrlRead($LstSelectIP))
GUICtrlSetState($SysCurIP,$GUI_DISABLE)
GUISetState()
#EndRegion ### END Koda GUI section ###
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $MainForm, "int", 500, "long", 0x00090000)
Exit
Case $ButRefreshCard
_GetCard()
Case $CmbCard
_CurrentIPConfig()
Case $LstSelectIP
$SectionNames = GUICtrlRead($LstSelectIP)
_ShowSelectIP($SectionNames)
Case $ButAddIP
_AddIP()
Case $ButEditIP
$SectionNames = GUICtrlRead($LstSelectIP)
_UpDateIP($SectionNames)
Case $ButDeleteIP
$SectionNames = GUICtrlRead($LstSelectIP)
_DeleteIP($SectionNames)
$SectionNames = GUICtrlRead($LstSelectIP)
_ShowSelectIP($SectionNames)
Case $ButSetIP
$SectionNames = GUICtrlRead($LstSelectIP)
$StrCardName=GUICtrlRead ($CmbCard)
_SetIp($SectionNames,$StrCardName)
EndSwitch
WEnd
Func _GetCard() ;取得网卡列表
Local $strComputer = "."
Local $wbemFlagReturnImmediately = 0x10,$wbemFlagForwardOnly = 0x20
Local $StrCrad ="",$strCradOne=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colNIC = $objWMIservice.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", $wbemFlagReturnImmediately + _
$wbemFlagForwardOnly)
$colItemName= $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", 0x30)
For $objCard In $colNIC
For $objName In $colItemName
If $objName.Index =$objCard.Index Then
if $StrCrad="" Then
$StrCrad=$objName.NetConnectionID
$strCradOne=$objName.NetConnectionID
Else
$StrCrad= $StrCrad & "|" & $objName.NetConnectionID
EndIf
ExitLoop
EndIf
Next
Next
GUICtrlSetData ($CmbCard,"")
GUICtrlSetData ($CmbCard,$StrCrad,$strCradOne)
EndFunc
Func _CurrentIPConfig() ;显示当前IP方案
$StrCardName=GUICtrlRead ($CmbCard)
If StringIsSpace ($StrCardName) or $StrCardName="" Then
_GUICtrlIpAddressSet($SysCurIP, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurMask, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurGateway,"0.0.0.0")
_GUICtrlIpAddressSet($SysCurPDNS, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurADNS, "0.0.0.0")
Else
Local $strComputer = "."
local $CardIndex=-1
Local $wbemFlagReturnImmediately = 0x10,$wbemFlagForwardOnly = 0x20
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItemName= $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter Where NetConnectionID='" & $StrCardName & "'", "WQL", 0x30)
For $objName In $colItemName
If $objName.NetConnectionID =$StrCardName Then
$CardIndex=$objName.Index
ExitLoop
EndIf
Next
if $CardIndex =-1 Then
MsgBox(0,"选择网卡",'找不到网卡“' & $StrCardName & '”,请刷新网卡列表。' )
_GUICtrlIpAddressSet($SysCurIP, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurMask, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurGateway,"0.0.0.0")
_GUICtrlIpAddressSet($SysCurPDNS, "0.0.0.0")
_GUICtrlIpAddressSet($SysCurADNS, "0.0.0.0")
Else
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE And Index='" & $CardIndex & "'" , "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
For $objItem In $colItems
if $objItem.Index= $CardIndex Then
$LocalIP = $objItem.IPAddress (0)
$LocalSubnetmask = $objItem.IPSubnet (0)
$LocalGateway = $objItem.DefaultIPGateway (0)
$LocalDns1 = $objItem.DNSServerSearchOrder (0)
$LocalDns2 = $objItem.DNSServerSearchOrder (1)
ExitLoop
EndIf
Next
_GUICtrlIpAddressSet($SysCurIP, $LocalIP)
_GUICtrlIpAddressSet($SysCurMask, $LocalSubnetmask)
_GUICtrlIpAddressSet($SysCurGateway, $LocalGateway)
_GUICtrlIpAddressSet($SysCurPDNS, $LocalDns1)
_GUICtrlIpAddressSet($SysCurADNS, $LocalDns2)
EndIf
EndIf
EndFunc
Func _ShowSelectIP($CurrentSectionName = "") ;显示IP配置方案$CurrentSectionName:选中的配置方案名
GUICtrlSetData($GroupNewIP, "IP配置 - " & $CurrentSectionName , "")
$IPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "IPAddress", "")
$Subnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "SubnetMask", "")
$Gateway = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "Gateway", "")
Dim $Dns
$Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "DNSServer1", "")
$Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "DNSServer2", "")
_GUICtrlIpAddressSet($SysNewIP, $IPAddress)
_GUICtrlIpAddressSet($SysNewMask, $Subnetmask)
_GUICtrlIpAddressSet($SysNewGateway, $Gateway)
_GUICtrlIpAddressSet($SysNewPDNS, $Dns)
_GUICtrlIpAddressSet($SysNewADNS, $Dns)
EndFunc;==>_ShowSelectIP
Func _AddIP() ;新增IP配置方案
$AddForm= GUICreate("添加IP配置", 225, 270, @DesktopWidth / 2 - 225 / 2, @DesktopHeight / 3 - 270 / 3, $WS_SYSMENU, $WS_EX_WINDOWEDGE, $MainForm)
$GroupAddIP = GUICtrlCreateGroup("新IP配置", 10, 15, 205, 175)
Local $index = 3
GUICtrlCreateLabel("I P 地址:", 20, 35, 60, 15)
$AddNewIP = _GUICtrlIpAddressCreate($AddForm, 80, 33, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("子网掩码:", 20, 60, 60, 15)
$AddNewMask = _GUICtrlIpAddressCreate($AddForm, 80, 57, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认网关:", 20, 85, 60, 15)
$AddNewGateway = _GUICtrlIpAddressCreate($AddForm, 80, 80, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("首选 DNS:", 20, 110, 60, 15)
$AddNewPDns = _GUICtrlIpAddressCreate($AddForm, 80, 105, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("备用 DNS:", 20, 135, 60, 15)
$AddNewADns = _GUICtrlIpAddressCreate($AddForm, 80, 130, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("配置名称", 20, 160, 60, 15)
$AddNewName = GUICtrlCreateInput("新IP配置", 80, 155, 125, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ButADD = GUICtrlCreateButton("添加", 10, 200, 60, 30)
$ButReset = GUICtrlCreateButton("重置", 83, 200, 60, 30)
$ButCancel = GUICtrlCreateButton("取消", 155, 200, 60, 30)
GUISetState()
While 1
$AddMsg = GUIGetMsg(1)
Switch $AddMsg
Case $ButADD
$IPAddress = _GUICtrlIpAddressGet($AddNewIP)
$Subnetmask = _GUICtrlIpAddressGet($AddNewMask)
$Gateway = _GUICtrlIpAddressGet($AddNewGateway)
Dim $Dns
$Dns = _GUICtrlIpAddressGet($AddNewPDns)
$Dns = _GUICtrlIpAddressGet($AddNewADns)
$NewSectionName = GUICtrlRead($AddNewName)
Dim $Configuration = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns], ["DNSServer2", $Dns] ]
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
$flag = 1
If $SectionNames == 1 Then
IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
ElseIf $SectionNames <> 1 Then
For $i = 1 To $SectionNames
If $NewSectionName == $SectionNames[$i] Then
$selete = MsgBox(36, "确认配置替换", "配置“" & $NewSectionName & "”已存在,是否替换?")
If $selete == 6 Then
ExitLoop
ElseIf $selete <> 6 Then
$flag = 0
ExitLoop
EndIf
EndIf
Next
EndIf
If $flag = 0 Then
ContinueLoop
EndIf
IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
GUICtrlSetData($LstSelectIP, "", "")
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
For $i = 1 To $SectionNames
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $NewSectionName)
Next
_ShowSelectIP($NewSectionName)
ExitLoop
Case $ButReset
_GUICtrlIpAddressSet($AddNewIP, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewMask, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewGateway, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewPDns, "0.0.0.0")
_GUICtrlIpAddressSet($AddNewADns, "0.0.0.0")
GUICtrlSetData($AddNewName, "新IP配置")
ContinueLoop
Case $ButCancel
ExitLoop
Case $GUI_EVENT_CLOSE
If $AddMsg == $AddForm Then
ExitLoop
EndIf
EndSwitch
WEnd
GUIDelete($AddForm)
If Not WinActive($MainForm) Then
WinActivate($MainForm)
EndIf
EndFunc ;==>_AddIP
Func _DeleteIP($DeleteSectionName = 0) ;删除IP配置方案 $DeleteSectionName:配置方案名
$selete = MsgBox(36, "确认删除", "确实要删除“" & $DeleteSectionName & "”IP配置吗?")
If $selete == 6 Then
IniDelete(@ScriptDir & "\IP Configlist.ini", $DeleteSectionName)
GUICtrlSetData($LstSelectIP, "", "")
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
If $SectionNames <> 1 Then
For $i = 1 To $SectionNames
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $SectionNames[$i])
Next
EndIf
EndIf
If Not WinActive($MainForm) Then
WinActivate($MainForm)
EndIf
EndFunc ;==>_DeleteIP
Func _UpDateIP($OldSectionName = "") ;更改IP配置方案 $OldSectionName:配置方案名
$IPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "IPAddress", "")
$Subnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "SubnetMask", "")
$Gateway = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "Gateway", "")
Dim $Dns
$Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "DNSServer1", "")
$Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "DNSServer2", "")
$UpDateForm = GUICreate("修改IP配置", 225, 270, @DesktopWidth / 2 - 225 / 2, @DesktopHeight / 3 - 270 / 3, $WS_SYSMENU, $WS_EX_WINDOWEDGE, $MainForm)
$GroupUpDateIP = GUICtrlCreateGroup($OldSectionName & "IP配置", 10, 15, 205, 175)
Local $index = 3
GUICtrlCreateLabel("I P 地址:", 20, 35, 60, 15)
$UpDateIP = _GUICtrlIpAddressCreate($UpDateForm, 80, 33, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateIP, $IPAddress)
GUICtrlCreateLabel("子网掩码:", 20, 60, 60, 15)
$UpDateMask = _GUICtrlIpAddressCreate($UpDateForm, 80, 57, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateMask, $Subnetmask)
GUICtrlCreateLabel("默认网关:", 20, 85, 60, 15)
$UpDateGateway = _GUICtrlIpAddressCreate($UpDateForm, 80, 80, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateGateway, $Gateway)
GUICtrlCreateLabel("首选 DNS:", 20, 110, 60, 15)
$UpDatePDNS = _GUICtrlIpAddressCreate($UpDateForm, 80, 105, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDatePDNS, $Dns)
GUICtrlCreateLabel("备用 DNS:", 20, 135, 60, 15)
$UpDateADNS = _GUICtrlIpAddressCreate($UpDateForm, 80, 130, 125, 20, $WS_CHILD)
_GUICtrlIpAddressSet($UpDateADNS, $Dns)
GUICtrlCreateLabel("配置名称", 20, 160, 60, 15)
$UpDateName = GUICtrlCreateInput($SectionNames, 80, 155, 125, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$ButEdit = GUICtrlCreateButton("修改", 10, 200, 60, 30)
$ButReset = GUICtrlCreateButton("重置", 83, 200, 60, 30)
$ButCancel = GUICtrlCreateButton("取消", 155, 200, 60, 30)
GUISetState()
While 1
$EditMsg = GUIGetMsg(1)
Switch $EditMsg
Case $ButEdit
$IPAddress = _GUICtrlIpAddressGet($UpDateIP)
$Subnetmask = _GUICtrlIpAddressGet($UpDateMask)
$Gateway = _GUICtrlIpAddressGet($UpDateGateway)
$Dns = _GUICtrlIpAddressGet($UpDatePDNS)
$Dns = _GUICtrlIpAddressGet($UpDateADNS)
$NewSectionName = GUICtrlRead($UpDateName)
Dim $Configuration = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns], ["DNSServer2", $Dns] ]
If ($OldSectionName <> $NewSectionName) And (Not IniRenameSection(@ScriptDir & "\IP Configlist.ini", $OldSectionName, $NewSectionName, 0)) Then
$selete = MsgBox(36, "确认配置替换", "配置“" & $NewSectionName & "”已存在,是否替换?")
If $selete == 6 Then
IniRenameSection(@ScriptDir & "\IP Configlist.ini", $OldSectionName, $NewSectionName, 1)
Else
ContinueLoop
EndIf
EndIf
IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
GUICtrlSetData($LstSelectIP, "", "")
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
For $i = 1 To $SectionNames
GUICtrlSetData($LstSelectIP, $SectionNames[$i], $NewSectionName)
Next
_ShowSelectIP($NewSectionName)
ExitLoop
Case $ButReset
_GUICtrlIpAddressSet($UpDateIP, $IPAddress)
_GUICtrlIpAddressSet($UpDateMask, $Subnetmask)
_GUICtrlIpAddressSet($UpDateGateway, $Gateway)
_GUICtrlIpAddressSet($UpDatePDNS, $Dns)
_GUICtrlIpAddressSet($UpDateADNS, $Dns)
GUICtrlSetData($UpDateName, $OldSectionName)
ContinueLoop
Case $ButCancel
ExitLoop
Case $GUI_EVENT_CLOSE
If $EditMsg == $UpDateForm Then
ExitLoop
EndIf
EndSwitch
WEnd
GUIDelete($UpDateForm)
If Not WinActive($MainForm) Then
WinActivate($MainForm)
EndIf
EndFunc ;==>_UpDateIP
Func _SetIP($SectionNames = "",$StrCardName="") ;设置系统IP $SectionNames:选中的配置方案名$StrCardName:选中的网卡名
Local $strComputer = "."
local $CardIndex=-1
Local $wbemFlagReturnImmediately = 0x10,$wbemFlagForwardOnly = 0x20
Dim $SetIPAddress
$SetIPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "IPAddress", "")
Dim $SetSubnetmask
$SetSubnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "SubnetMask", "")
Dim $SetGateway
$SetGateway = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "Gateway", "")
Dim $SetDns
$SetDns = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "DNSServer1", "")
$SetDns = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "DNSServer2", "")
TrayTip("设置", "正在设置IP,请稍等...", 1)
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItemName= $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter Where NetConnectionID='" & $StrCardName & "'", "WQL", 0x30)
For $objName In $colItemName
If $objName.NetConnectionID =$StrCardName Then
$CardIndex=$objName.Index
ExitLoop
EndIf
Next
if $CardIndex =-1 Then
MsgBox(0,"切换配置",'找不到网卡“' & $StrCardName & '”,请刷新网卡列表。' )
TrayTip("错误", '未找到网卡“' & $StrCardName &@CRLF & '”,IP配置更改失败。', 1)
Else
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE And Index='" & $CardIndex & "'" , "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objNetAdapter In $colItems
$objNetAdapter.EnableStatic ($SetIPAddress, $SetSubnetmask)
$objNetAdapter.SetGateways ($SetGateway)
$objNetAdapter.SetDNSServerSearchOrder ($SetDns)
Next
EndIf
TrayTip("IP设置完成","I P 地址:" & $SetIPAddress & @CRLF & "子网掩码:" & $SetSubnetmask & @CRLF & "网 关:" _
& $SetGateway & @CRLF & "首选 DNS:" & $SetDns & @CRLF & "备用 DNS:" & $SetDns, 1)
_CurrentIPConfig()
Endif
EndFunc;==>_SetIP 提升至系统级?把以下代码加入进去即可。#include <LocalSecurityAuthority.au3>
_RaiseToSystem()
Func _RaiseToSystem()
Local $sApp, $sArg, $hToken, $pUserThread, $pUserLogged
$pUserLogged = _LookupAccountName(_LsaGetUserName(False))
$hToken = _OpenProcessToken(-1)
$pUserThread = _LookupAccountName(_GetTokenUser($hToken))
_LsaCloseHandle($hToken)
If _EqualSid($pUserLogged, $pUserThread) Then
If @Compiled Then
$sApp = @ScriptFullPath
$sArg = " " & $CmdLineRaw
Else
$sApp = @AutoItExe
$sArg = " " & FileGetShortName(@ScriptFullPath) & " " & $CmdLineRaw
EndIf
_CreateProcessAsSystem($sApp, $sArg, "Winlogon.exe")
Exit(_HeapFree($pUserLogged) or _HeapFree($pUserThread))
EndIf
Return _HeapFree($pUserLogged) or _HeapFree($pUserThread)
EndFunc ;==>_RaiseToSystem
报错很多啊
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(45,109) : ERROR: $SE_CREATE_TOKEN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CREATE_TOKEN_NAME") Then GLOBAL CONST $SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(46,128) : ERROR: $SE_ASSIGNPRIMARYTOKEN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_ASSIGNPRIMARYTOKEN_NAME") Then GLOBAL CONST $SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(47,106) : ERROR: $SE_LOCK_MEMORY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_LOCK_MEMORY_NAME") Then GLOBAL CONST $SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(48,115) : ERROR: $SE_INCREASE_QUOTA_NAME previously declared as a 'Const'
If Not IsDeclared("SE_INCREASE_QUOTA_NAME") Then GLOBAL CONST $SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(49,124) : ERROR: $SE_UNSOLICITED_INPUT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_UNSOLICITED_INPUT_NAME") Then GLOBAL CONST $SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(50,118) : ERROR: $SE_MACHINE_ACCOUNT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_MACHINE_ACCOUNT_NAME") Then GLOBAL CONST $SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(51,83) : ERROR: $SE_TCB_NAME previously declared as a 'Const'
If Not IsDeclared("SE_TCB_NAME") Then GLOBAL CONST $SE_TCB_NAME = "SeTcbPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(52,98) : ERROR: $SE_SECURITY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SECURITY_NAME") Then GLOBAL CONST $SE_SECURITY_NAME = "SeSecurityPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(53,115) : ERROR: $SE_TAKE_OWNERSHIP_NAME previously declared as a 'Const'
If Not IsDeclared("SE_TAKE_OWNERSHIP_NAME") Then GLOBAL CONST $SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(54,106) : ERROR: $SE_LOAD_DRIVER_NAME previously declared as a 'Const'
If Not IsDeclared("SE_LOAD_DRIVER_NAME") Then GLOBAL CONST $SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(55,115) : ERROR: $SE_SYSTEM_PROFILE_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SYSTEM_PROFILE_NAME") Then GLOBAL CONST $SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(56,104) : ERROR: $SE_SYSTEMTIME_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SYSTEMTIME_NAME") Then GLOBAL CONST $SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(57,132) : ERROR: $SE_PROF_SINGLE_PROCESS_NAME previously declared as a 'Const'
If Not IsDeclared("SE_PROF_SINGLE_PROCESS_NAME") Then GLOBAL CONST $SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(58,128) : ERROR: $SE_INC_BASE_PRIORITY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_INC_BASE_PRIORITY_NAME") Then GLOBAL CONST $SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(59,118) : ERROR: $SE_CREATE_PAGEFILE_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CREATE_PAGEFILE_NAME") Then GLOBAL CONST $SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(60,121) : ERROR: $SE_CREATE_PERMANENT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CREATE_PERMANENT_NAME") Then GLOBAL CONST $SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(61,92) : ERROR: $SE_BACKUP_NAME previously declared as a 'Const'
If Not IsDeclared("SE_BACKUP_NAME") Then GLOBAL CONST $SE_BACKUP_NAME = "SeBackupPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(62,95) : ERROR: $SE_RESTORE_NAME previously declared as a 'Const'
If Not IsDeclared("SE_RESTORE_NAME") Then GLOBAL CONST $SE_RESTORE_NAME = "SeRestorePrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(63,98) : ERROR: $SE_SHUTDOWN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SHUTDOWN_NAME") Then GLOBAL CONST $SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(64,89) : ERROR: $SE_DEBUG_NAME previously declared as a 'Const'
If Not IsDeclared("SE_DEBUG_NAME") Then GLOBAL CONST $SE_DEBUG_NAME = "SeDebugPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(65,89) : ERROR: $SE_AUDIT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_AUDIT_NAME") Then GLOBAL CONST $SE_AUDIT_NAME = "SeAuditPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(66,127) : ERROR: $SE_SYSTEM_ENVIRONMENT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SYSTEM_ENVIRONMENT_NAME") Then GLOBAL CONST $SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(67,112) : ERROR: $SE_CHANGE_NOTIFY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CHANGE_NOTIFY_NAME") Then GLOBAL CONST $SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(68,118) : ERROR: $SE_REMOTE_SHUTDOWN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_REMOTE_SHUTDOWN_NAME") Then GLOBAL CONST $SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(69,92) : ERROR: $SE_UNDOCK_NAME previously declared as a 'Const'
If Not IsDeclared("SE_UNDOCK_NAME") Then GLOBAL CONST $SE_UNDOCK_NAME = "SeUndockPrivilege"
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(137,42) : ERROR: $TOKEN_ADJUST_DEFAULT previously declared as a 'Const'
GLOBAL CONST $TOKEN_ADJUST_DEFAULT = 0x80
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(138,41) : ERROR: $TOKEN_ADJUST_GROUPS previously declared as a 'Const'
GLOBAL CONST $TOKEN_ADJUST_GROUPS = 0x40
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(139,45) : ERROR: $TOKEN_ADJUST_PRIVILEGES previously declared as a 'Const'
GLOBAL CONST $TOKEN_ADJUST_PRIVILEGES = 0x20
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(140,45) : ERROR: $TOKEN_ADJUST_SESSIONID previously declared as a 'Const'
GLOBAL CONST $TOKEN_ADJUST_SESSIONID = 0x100
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(141,42) : ERROR: $TOKEN_ASSIGN_PRIMARY previously declared as a 'Const'
GLOBAL CONST $TOKEN_ASSIGN_PRIMARY = 0x01
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(142,36) : ERROR: $TOKEN_DUPLICATE previously declared as a 'Const'
GLOBAL CONST $TOKEN_DUPLICATE = 0x2
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(144,38) : ERROR: $TOKEN_IMPERSONATE previously declared as a 'Const'
GLOBAL CONST $TOKEN_IMPERSONATE = 0x4
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(145,32) : ERROR: $TOKEN_QUERY previously declared as a 'Const'
GLOBAL CONST $TOKEN_QUERY = 0x8
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(146,40) : ERROR: $TOKEN_QUERY_SOURCE previously declared as a 'Const'
GLOBAL CONST $TOKEN_QUERY_SOURCE = 0x10
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(215,79) : ERROR: $GENERIC_READ previously declared as a 'Const'
If Not IsDeclared("GENERIC_READ") Then GLOBAL CONST $GENERIC_READ = 0x80000000
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(216,81) : ERROR: $GENERIC_WRITE previously declared as a 'Const'
If Not IsDeclared("GENERIC_WRITE") Then GLOBAL CONST $GENERIC_WRITE = 0x40000000
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(217,85) : ERROR: $GENERIC_EXECUTE previously declared as a 'Const'
If Not IsDeclared("GENERIC_EXECUTE") Then GLOBAL CONST $GENERIC_EXECUTE = 0x20000000
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(218,77) : ERROR: $GENERIC_ALL previously declared as a 'Const'
If Not IsDeclared("GENERIC_ALL") Then GLOBAL CONST $GENERIC_ALL = 0x10000000
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,48) : ERROR: syntax error
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(782,40) : WARNING: $iAccess: possibly used before declaration.
"hWnd", $hProcess, "dword", $iAccess,
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(1671,32) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(2201,32) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(2355,33) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(2474,32) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(3322,44) : ERROR: syntax error
Func _LsaEnumerateLocalAccounts($iFilter = $FILTER_ALL_USER_ACCOUNTS
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(3326,20) : WARNING: $sSystem: possibly used before declaration.
"wstr", $sSystem,
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(3326,51) : WARNING: $iFilter: possibly used before declaration.
"wstr", $sSystem, "dword", 0, "dword", $iFilter,
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(3759,32) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(3763,55) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken($iSystemPid, $iAccessMask)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(3772,60) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken($iSystemPid, $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(4361,33) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(4368,33) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(4452,33) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(4632,33) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(4834,64) : ERROR: syntax error
Func _LogonUser($sUser, $sPswd, $sDomain, $iType, $iProvider = $LOGON32_PROVIDER_DEFAULT
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(4839,23) : WARNING: $iProvider: possibly used before declaration.
"dword", $iProvider,
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(5339,50) : ERROR: syntax error
Func _CryptHashCeritificate($sBinData, $iAlgID = $CALG_MD5
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(5348,20) : WARNING: $iAlgID: possibly used before declaration.
"dword", $iAlgID,
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(5432,70) : ERROR: syntax error
Func _CryptVerifyObjectHashValue($sObject, $iType, $iMask, $iAlgID = $CALG_MD5
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(5433,62) : ERROR: _OpenProcessToken() called with wrong number of args.
Local $sBinData, $pSecurDesc, $hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(5598,52) : ERROR: _CryptHashCeritificate() called with wrong number of args.
$bHash = _CryptHashCeritificate($sBinData, $iAlgID)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(5339,60) : REF: definition of _CryptHashCeritificate().
Func _CryptHashCeritificate($sBinData, $iAlgID = $CALG_MD5)
D:\AutoIt\IP Change\IPChange.au3(15,39) : ERROR: _OpenProcessToken() called with wrong number of args.
$hToken = _OpenProcessToken(-1)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(774,66) : REF: definition of _OpenProcessToken().
Func _OpenProcessToken($iProcessId, $iAccess = $TOKEN_ALL_ACCESS)
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(782,40) : ERROR: $iAccess: undeclared global variable.
"hWnd", $hProcess, "dword", $iAccess,
D:\AutoIt\IP Change\LocalSecurityAuthority.au3(2877,25) : ERROR: IsPtr(): undefined function.
ElseIf Not IsPtr($sData)
D:\AutoIt\IP Change\IPChange.au3 - 59 error(s), 5 warning(s)
是不是删除掉那些声明啊。 Re 5#:
你觉得上面的提示是正确的吗?
IsPtr(): undefined function?
$SE_CREATE_TOKEN_NAME previously declared as a 'Const' ???
If Not IsDeclared("SE_CREATE_TOKEN_NAME") Then GLOBAL CONST $SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
$iAccess = $TOKEN_ALL_ACCESS
$iAccess: undeclared global variable ??
或者,你把LocalSecurityAuthority.au3和哪些库文件混用了啊? 我要哭了,555555555 我把LocalSecurityAuthority.au3放在编译目录下用的,
或者要放到别的地方? 如果你跟WinAPI.au3或者其它库文件混用,注意把#include <LocalSecurityAuthority.au3>置于其他库文件下面,例如:#include <WinAPI.au3>
#include <GUIListView.au3>
#include <LocalSecurityAuthority.au3> 我把文件夹打包给你帮我看下好不,麻烦你了。
可能 这两个库
#include <GuiIPAddress.au3>
#include <LocalSecurityAuthority.au3>
不兼容 汗。。那怎么办啊。有没有解决办法。 出错原因:
1,没有包含以下文件
GUIButton.au3
GUIComboBox.au3
StaticConstants.au3
WindowsConstants.au3
2,代码中调用了GUIIpAddress.au3中没有的函数,解决方法:用记事本的替换功能,把字符串"_GUICtrlIpAddress"替换为"_GUICtrlIpAddress_"。
3,GUIIPAddress.au3与LocalSecurityAuthority.au3并非不兼容,提示“常量已经定义”只是AU3自检过程的错误,因为定义之前先用IsDeclared检查过了。 OK,搞掂。
就是报病毒有点麻烦。不知道怎么处理啊。 13# pusofalse
谢谢你了哈。
页:
[1]
2