Erik. Posted July 10, 2007 Posted July 10, 2007 (edited) Hello, I am trying to make some little things but it won't work I need to know all processes on a computer and send it whit udp send like this: $rc = Run(@ComSpec & " /c tasklist", @WorkingDir, @SW_HIDE, $STDOUT_CHILD) $StdOut = "" While ProcessExists($rc) If StdoutRead($rc, 0, 1) Then $StdOut &= StdoutRead($rc) WEnd UDPSend($socket,$StdOut) The socket has a correct ip number but it does not work... Can someone help me please. I think i make a little mistake but i don't see it Edited July 10, 2007 by Erik. I little problem, hard to find and fix
Pakku Posted July 10, 2007 Posted July 10, 2007 Hi, In the helpfile i found this function: ProcessList() This is way better than yours I think. Check out the following code: expandcollapse popup;;This is the UDP Server ;;Start this first ; Start The UDP Services ;============================================== UDPStartup() ; Bind to a SOCKET ;============================================== $socket = UDPBind("127.0.0.1", 65532) If @error <> 0 Then Exit While 1 $data = UDPRecv($socket, 50) If $data <> "" Then MsgBox(0, "UDP DATA", $data, 1) EndIf sleep(100) WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFunc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;This is the UDP Client ;;Start the server first ; Start The UDP Services ;============================================== UDPStartup() ; Open a "SOCKET" ;============================================== $socket = UDPOpen("127.0.0.1", 65532) If @error <> 0 Then Exit $n=0 While 1 Sleep(2000) $n = $n + 1 $status = UDPSend($socket, "Message #" & $n) If $status = 0 then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFunc This came directly from the helpfile. This will do Arjan How can someone use Windows without using AutoIt?That one would properly don't know how to handle a computer!My scripts:Send files over internetKind of RSS reader3Draw ProUDF: convert a character string to a binary one and backCalculate PiCommand line downloader (Youtube/Google video)Set the transparency of a window just by hitting a key!Secure your pcOther things:My filemanMy profilePM me
Erik. Posted July 10, 2007 Author Posted July 10, 2007 (edited) Hi, No it doens't sorry. Why? I also want to do net user so i can see all user accounts... You see my script and edit tasklist for C net user and you will get all user accounts. But it won't be send to my host When i do a msg box on the client side where the accounts are it works but it doens't send it EDIT: i have a remote and a script on my own pc... When i send a command it works very nice no erors etc.. Now do i want to send all users but it does not work. Hope you understand what i mean... Edited July 10, 2007 by Erik. I little problem, hard to find and fix
Erik. Posted July 14, 2007 Author Posted July 14, 2007 Hi,Ok i will explain it again and i hope you can help me because i need it...Ok, listenYou can send commands whit UDP send.There is an example in the help file:Whit this you send a number to the other side:$socket = UDPOpen("127.0.0.1", 65532)If @error <> 0 Then Exit$n=0While 1 Sleep(2000) $n = $n + 1 $status = UDPSend($socket, "Message #" & $n) If $status = 0 then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIfWEndFunc OnAutoItExit() UDPCloseSocket($socket) UDPShutdown()EndFunc;;This is the UDP Server;;Start this firstWhit this you get the numbers:; Start The UDP Services;==============================================UDPStartup(); Bind to a SOCKET;==============================================$socket = UDPBind("127.0.0.1", 65532)If @error <> 0 Then ExitWhile 1 $data = UDPRecv($socket, 50) If $data <> "" Then MsgBox(0, "UDP DATA", $data, 1) EndIf sleep(100)WEndFunc OnAutoItExit() UDPCloseSocket($socket) UDPShutdown()EndFuncNow you can send command to the other side like to shut down the computer ore something:This is what i made:The send side:While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE UDPShutdown() Exit Case $connect If GUICtrlRead($ip) = "" Then Msgbox(64,"No ip","Please full a ip adres in") EndIf $socket = UDPOpen(GUICtrlRead($ip), 28960) If @error <> 0 Then Exit $status = UDPSend($socket,"Connect") If $status = 0 then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) EndIf while 1 $data = UDPRecv($socket, 50) If $data = "Connected" Then GUICtrlSetData($info,GUICtrlRead($info) & @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " Connected whit host:" & GUICtrlRead($ip)) ExitLoop EndIf sleep(100) wend Case $Button3 If GUICtrlRead($ip) = "" Then Msgbox(64,"No ip","Please full a ip adres in") EndIf $socket = UDPOpen(GUICtrlRead($ip), 28960) If @error <> 0 Then Exit $status = UDPSend($socket,"shutdown") If $status = 0 then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) EndIf while 1 $data = UDPRecv($socket, 50) If $data = "shuttingdown" Then GUICtrlSetData($info,GUICtrlRead($info) & @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " The remote host is shutting down:" & GUICtrlRead($ip)) ExitLoop EndIf sleep(100) wend case $Button4 If GUICtrlRead($ip) = "" Then Msgbox(64,"No ip","Please full a ip adres in") EndIf $socket = UDPOpen(GUICtrlRead($ip), 28960) If @error <> 0 Then Exit $status = UDPSend($socket,"reboot") If $status = 0 then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) EndIf while 1 $data = UDPRecv($socket, 50) If $data = "rebooting" Then GUICtrlSetData($info,GUICtrlRead($info) & @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " The remote host is rebooting now:" & GUICtrlRead($ip)) ExitLoop EndIf sleep(100) wend case $Button5 If GUICtrlRead($ip) = "" Then Msgbox(64,"No ip","Please full a ip adres in") EndIf $socket = UDPOpen(GUICtrlRead($ip), 28960) If @error <> 0 Then Exit $status = UDPSend($socket,"getuser") If $status = 0 then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) EndIf while 1 $data1 = UDPRecv($socket, 50) $string = StringSplit($data1, "|") If $string[1] = "userfound" Then MsgBox(0, "data1",$string[2]) GUICtrlSetData($info,GUICtrlRead($info) & @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF & $string[2] & GUICtrlRead($ip)) ExitLoop EndIf sleep(100) wend EndSwitchWEndThis the Recv side: Bind to a SOCKET;==============================================$socket = UDPBind("172.27.183.213", 28960)If @error <> 0 Then MsgBox(0,"error",@error)While 1 $data = UDPRecv($socket, 50) If $data = "Connect" Then MsgBox(0, "UDP DATA","Connected", 1) UDPSend($socket,"Connected") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndIf If $data = "shutdown" Then MsgBox(0, "UDP DATA","shutdown", 1) UDPSend($socket,"shuttingdown") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndIf If $data = "reboot" Then MsgBox(0, "UDP DATA","reboot", 1) UDPSend($socket,"rebooting") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndIf If $data = "getuser" Then MsgBox(0, "UDP DATA","getuser", 1) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $rc = Run(@ComSpec & " /c net user", @WorkingDir, @SW_HIDE, $STDOUT_CHILD) $StdOut = "" While ProcessExists($rc) If StdoutRead($rc, 0, 1) Then $StdOut &= StdoutRead($rc) WEnd UDPSend($socket,"userfound|") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndIf sleep(100)WEndFunc OnAutoItExit() UDPCloseSocket($socket) UDPShutdown()EndFuncYou can get all users on the computer whit a dos command : net userFor my explain you can look here:http://www.autoitscript.com/forum/index.ph...787&hl=Erik.Now do i send the tekst getuser to the recv sideWhen the Recv side get that test it need to look whit i hide dos box for users..And send it back to the remote pc but that doesn't work...When i do a message box on the recv side whit all users it works but when i want to send it it doens't work any more..I hope you can understand what i mean and help me..Erik I little problem, hard to find and fix
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now