Jump to content

remote tasklist


Recommended Posts

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

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

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...