Sign in to follow this  
Followers 0
Jochem

remote tasklist

7 posts in this topic

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)

Share this post


Link to post
Share on other sites



#2 ·  Posted (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' :P

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Jochem

Share this post


Link to post
Share on other sites

#4 ·  Posted (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... :unsure:

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... :P

Edited by BinaryBrother

Share this post


Link to post
Share on other sites

#5 ·  Posted (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... :unsure:

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... :P

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 by Jochem

Share this post


Link to post
Share on other sites

So did you get what you needed, or are you still missing something? :P

it is working like I wanted, Thanx a lot

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0