Jochem Posted March 12, 2009 Share Posted March 12, 2009 I simply want to create an array from a tasklist of a remote computer but is not working? can somebody help me. $1 = RunWait(@ComSpec & " /c " & "Tasklist" & " /s " & $pc & "/U:" & $user & " /p:" & $pw, "", @SW_SHOW) MsgBox(0,"",$1) Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 12, 2009 Share Posted March 12, 2009 (edited) This will get you started... #include <Constants.au3> #include <File.au3> #include <Array.au3> Dim $Array Dim $Line $RemotePC = "192.168.2.71" ; Remote IP $Username = "BinaryBrother" ; Remote Username $Password = "Pass-W0rd" ; Remote Password $Handle = Run(@ComSpec & " /c Tasklist /s " & $RemotePC & " /U:" & $Username & " /p:" & $Password, @SystemDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) While 1 $Line = StdoutRead($Handle) ; Read the help-file a bit on this function for further help FileWrite(@ScriptDir & "\RemoteProcesses.txt",$Line) ; Writes the output to a file If @Error Then ExitLoop ; Exits loop after done Wend _FileReadToArray(@ScriptDir & "\RemoteProcesses.txt",$Array) ; Adds ALL the data from remote tasklist to an array... Including things you may not want _ArrayDisplay($Array,"List the Array") ; Displays the Array info Wow... 7 edits in 60 seconds... >.< I messed something up... and every time I edited, I seen some other syntax error... lol Looks right now though... I managed to sneak 4 more in for spelling mistakes! Crap... Another edit for misspelling 'snook' Edited March 12, 2009 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Jochem Posted March 12, 2009 Author Share Posted March 12, 2009 (edited) thanx a lot, this is working too: Func tasklist() Run(@ComSpec & " /c " & "tasklist /s " & $pc & " /U:" & $user & " /p:" & $pw & " > " & $avArray, "", @SW_HIDE) EndFunc;==>tasklist tasklist() _FileReadToArray($avArray,$tasks) _ArrayDisplay($tasks,"") Edited March 12, 2009 by Jochem Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 12, 2009 Share Posted March 12, 2009 (edited) Func tasklist() Run(@ComSpec & " /c " & "tasklist /s " & $pc & " /U:" & $user & " /p:" & $pw & " > " & $avArray, "", @SW_HIDE) EndFunc;==>tasklist tasklist() _FileReadToArray($avArray,$tasks) _ArrayDisplay($tasks,"") It's actually not possible for the above code to run, as $avArray isn't defined, and neither is $tasks... Maybe you didn't post it all... I'm pretty sure you tried to echo the text to a file using the Command Line instead of AutoIt... Should have thought of that myself... Edited March 12, 2009 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Jochem Posted March 12, 2009 Author Share Posted March 12, 2009 (edited) It's actually not possible for the above code to run, as $avArray isn't defined, and neither is $tasks... Maybe you didn't post it all... I'm pretty sure you tried to echo the text to a file using the Command Line instead of AutoIt... Should have thought of that myself... Yeah sorry I didn`t post all the script: #Include <pass.au3> #include <File.au3> #include <Array.au3> $pc = "dnsname or ip" $avArray = "task.txt" dim $tasks Func tasklist() Run(@ComSpec & " /c " & "tasklist /s " & $pc & " /U:" & $user & " /p:" & $pw & " > " & $avArray, "", @SW_HIDE) EndFunc;==>tasklist tasklist() _FileReadToArray($avArray,$tasks) _ArrayDisplay($tasks,"") I am not familiar with the code you have used yet (StdoutRead etc.) i have to read that section still Edited March 12, 2009 by Jochem Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 12, 2009 Share Posted March 12, 2009 So did you get what you needed, or are you still missing something? SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Jochem Posted March 12, 2009 Author Share Posted March 12, 2009 So did you get what you needed, or are you still missing something? it is working like I wanted, Thanx a lot Link to comment Share on other sites More sharing options...
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