找回密码
 加入
搜索
查看: 2357|回复: 3

runwait调用外部程序加参数的时候执行不起来

[复制链接]
发表于 2008-12-22 15:42:18 | 显示全部楼层 |阅读模式
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\图标\13.ico
#AutoIt3Wrapper_outfile=af.exe
#AutoIt3Wrapper_Compression=3
#AutoIt3Wrapper_Res_Comment=智能网关绑定器
#AutoIt3Wrapper_Res_Description=智能网关绑定器
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=叁恨居士
#AutoIt3Wrapper_Res_Field=说明|网吧专用
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Opt('MustDeclareVars', 1)
_Singleton("Gateway")
Global $IniFile


$IniFile = StringReplace(@ScriptFullPath & "?", StringTrimLeft(@ScriptName, StringInStr(@ScriptName, '.', 0, -1)) & "?", "ini")

If Not FileExists($IniFile) Then 

_WriteMac()

Exit

EndIf

_Gatewaybundled()

Func _Gatewaybundled()
        
Local $Gateway,$GatewayMac,$AutoRun

$Gateway=IniRead($IniFile,"Bundled","Ip","")
$GatewayMac=IniRead($IniFile,"Bundled","Mac","")
$AutoRun=IniRead($IniFile,"Bundled","AutoRun","")

RunWait(@ComSpec & ' /c arp -d',@SystemDir, @SW_HIDE)
RunWait(@ComSpec & ' /c \flarp.exe Freeland='&$Gateway&' '&$GatewayMac&' 1 freeland false', @SystemDir, @SW_HIDE)
Switch $AutoRun
        
        Case 0
                RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Run",@ScriptName)
        Case 1
       RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Run",@ScriptName,"REG_SZ",@ScriptFullPath)
                
EndSwitch

EndFunc ;==>_Gatewaybundled()

Func _WriteMac()

Local $IniIp,$IniMac,$foo,$line,$lines,$Tmp_Gateway,$x

$foo = Run(@ComSpec & " /c ipconfig/all", @SystemDir, @SW_HIDE, 2)
$lines = ""
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
     $lines &= $line
Wend

$lines = StringSplit($lines,@CRLF,1)
For $x = 1 To $lines[0]
        If StringInStr($lines[$x], "Gateway")  Then
                $Tmp_Gateway=StringSplit(StringStripWS($lines[$x],8),":")
                ExitLoop
                Exit
      EndIf
Next
  
$IniIp=InputBox("获取远程计算机MAC",@CRLF&@CRLF&"请输入远程计算机的IP地址",$Tmp_Gateway[2],"",-1,-1,-1,-1)
If @error Then Exit

$IniMac=_GetMAC($IniIp)
If @error Then MsgBox(16,"错误","获取指定"&$IniIp&"的MAC地址失败")        
        IniWrite($IniFile,"Bundled","Ip",$IniIp)
        IniWrite($IniFile,"Bundled","Mac",$IniMac)
        IniWrite($IniFile,"Bundled","AutoRun","1")
EndFunc  ;==>_WriteMac()


Func _GetMAC($sIP)
  Local $MAC,$MACSize
  Local $i,$s,$r,$iIP
  
  $MAC = DllStructCreate("byte[6]")
  $MACSize = DllStructCreate("int")

  DllStructSetData($MACSize,1,6)
  $r = DllCall ("Ws2_32.dll", "int", "inet_addr", "str", $sIP)
  $iIP = $r[0]
  $r = DllCall ("iphlpapi.dll", "int", "SendARP","int", $iIP,"int", 0,"ptr", DllStructGetPtr($MAC),"ptr", DllStructGetPtr($MACSize))
  $s    = ""
  For $i = 0 To 5
      If $i Then $s = $s & "-"
      $s = $s & Hex(DllStructGetData($MAC,1,$i+1),2)
  Next
  If $s = "00-00-00-00-00-00"  Then SetError(1)
  Return $s
EndFunc   ;==>_GetMAC()

Func _Singleton($sOccurenceName, $iFlag = 0)
        Local Const $ERROR_ALREADY_EXISTS = 183
        Local Const $SECURITY_DESCRIPTOR_REVISION = 1
        Local $handle, $lastError, $pSecurityAttributes = 0

        If BitAND($iFlag, 2) Then
                Local $structSecurityDescriptor = DllStructCreate("dword[5]")
                Local $pSecurityDescriptor = DllStructGetPtr($structSecurityDescriptor)
                Local $aRet = DllCall("advapi32.dll", "int", "InitializeSecurityDescriptor", _
                                "ptr", $pSecurityDescriptor, "dword", $SECURITY_DESCRIPTOR_REVISION)
                If Not @error And $aRet[0] Then
                        $aRet = DllCall("advapi32.dll", "int", "SetSecurityDescriptorDacl", _
                                                 "ptr", $pSecurityDescriptor, "int", 1, "ptr", 0, "int", 0)
                        If Not @error And $aRet[0] Then
                                Local $structSecurityAttributes = DllStructCreate("dword;ptr;int")
                                DllStructSetData($structSecurityAttributes, 1, DllStructGetSize($structSecurityAttributes))
                                DllStructSetData($structSecurityAttributes, 2, $pSecurityDescriptor)
                                DllStructSetData($structSecurityAttributes, 3, 0)
                                $pSecurityAttributes = DllStructGetPtr($structSecurityAttributes)
                        EndIf
                EndIf
        EndIf

        $handle = DllCall("kernel32.dll", "int", "CreateMutex", "ptr", $pSecurityAttributes, "long", 1, "str", $sOccurenceName)
        $lastError = DllCall("kernel32.dll", "int", "GetLastError")
        If $lastError[0] = $ERROR_ALREADY_EXISTS Then
                If BitAND($iFlag, 1) Then
                        Return SetError($lastError[0], $lastError[0], 0)
                Else
                        Exit -1
                EndIf
        EndIf
        Return $handle[0]
EndFunc   ;==>_Singleton


为什么我这一句都没有执行起来呀RunWait(@ComSpec & ' /c \flarp.exe Freeland='&$Gateway&' '&$GatewayMac&' 1 freeland false', @SystemDir, @SW_HIDE),如位高手帮忙呀!
附flarp.exe 执行参数批处理实例:flarp.exe Freeland=192.168.1.1 00-74-05-7C-70-24 1 freeland false

[ 本帖最后由 fjvip 于 2008-12-23 10:23 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2008-12-22 15:55:39 | 显示全部楼层
你Flarp.exe文件放在那里 ?
发表于 2008-12-22 17:28:22 | 显示全部楼层
这明明是我写的脚本,什么时候又变成了帽子的了?哈。。。
 楼主| 发表于 2008-12-23 10:14:35 | 显示全部楼层
不好意思,,申明确实是叁恨居士的。
不过我进行修改了以下这样,就没有问题了,结合了沸蓝网盟的绑定后好用,再也不会出现,
病毒代码中加arp -d解除绑定了。。。。
Run("flarp.exe Freeland=" & $Gateway & " " & $GatewayMac & " 1 freeland false")
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-23 11:56 , Processed in 0.071137 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表