Jump to content

pslist


Recommended Posts

hello

i cant for the live of me figure out whats wrong with this:

$asset = "192.168.12.12"
$output_dir = "c:\documents and settings\all users\desktop\script"

    $file = ($output_dir & "\Active_Processes\active-processes_" & $asset & ".txt")

    FileWrite($file, '"' & @ScriptDir & '\pslist.exe" \\' & $asset & " > " & '"' & $file & '"')

    RunWait(@ComSpec & ' /c "' & @ScriptDir & '\pslist.exe" \\' & $asset & " > " & '"' & $file & '"', "", @SW_HIDE)
    ShellExecute($file)

i even copy and paste teh filewrite results into a cmd window which works.. but the runwait doesnt - arrrrggg!!!

Edited by gcue
Link to comment
Share on other sites

first look at your paths... for testing you might try to put everything in a folder like C:\Testing\

Next, sometimes I've found that the run command needs to have $STDIN_CHILD flagged on it to run some things properly (requires #include<Constants.au3>)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

  • Moderators

gcue,

I realise it probably just a typo, but you define $outputdir and then use $output_dir to define $file.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

ya that was me doing a typo on my post not int eh script =/

i have no idea what the prob is!!!

usually the filewrite helps me figure this out but not in this case..

Edited by gcue
Link to comment
Share on other sites

This works for me to grab the output:

#include <Constants.au3>
; Example Usage
$result= _CMDreturn('c:\pslist.exe \\192.168.1.55')
msgbox(0,"Version",$result)


Func _CMDreturn($sCommand) ; This function returns the output of a DOS command as a string
    $cmdreturn = ""
    $stream = Run(@ComSpec & " /c " & $sCommand, @SystemDir, @SW_HIDE, $STDERR_MERGED + $STDIN_CHILD)
    While 1 ; loop through the return from the command until there is no more
        $line = StdoutRead($stream)
        If @error Then ExitLoop
        $cmdreturn &= $line
    WEnd
    Return $cmdreturn
EndFunc   ;==>_CMDreturn

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

so it works without the quotes if the filepath doesnt have spaces.. but if the filepath has spaces it doesnt work

i tried setting the quotes in the run command and in the $file declaration - neither worked =/

$file = '"' & $output_dir & '\Checkers\Active_Processes\active-processes_' & $asset & '.txt"'oÝ÷ Ú)¬ç[£7éø¥y©ÝÙh¢K(»­(¶§ÚâyÖ®¶­se'VåvB6öÕ7V2fײb33²ö2gV÷C²b33²fײ67&DF"fײb33²b3#·6Æ7BæWRgV÷C²b3#²b3#²b33²fײb33c¶76WBfײgV÷C²fwC²gV÷C²fײb33²gV÷C²b33²fײb33c¶fÆRfײb33²gV÷C²b33²ÂgV÷C²gV÷C²Â5uôDR

still no go

help!

Link to comment
Share on other sites

maybe:

Run(@ComSpec & ' /c "' & @ScriptDir & '\pslist.exe" \\' & $asset & ' > "c:\documents and settings\eh.txt"', "", @SW_HIDE)

for testing though, I usually do something like stick the entire convoluted command line into a variable and then show it in a msgbox just to make sure all the parts extrapolate properly and that it has the right 'quoting'

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

$asset = "192.168.12.12"

$output_dir = @ScriptDir

$file_path = $output_dir & "\active-processes_" & $asset & ".txt"

$command = StringFormat('pslist.exe \\\\%s > "%s"',$asset,$file_path)

ConsoleWrite($command & @CRLF)

;RunWait(@ComSpec & ' /K ' & $command, @ScriptDir, @SW_SHOW);Laave command window open after completion
RunWait(@ComSpec & ' /C ' & $command, @ScriptDir, @SW_HIDE);Close command window immediately

ShellExecute($file_path)

Link to comment
Share on other sites

I think the key to WeaponX's solution was using @ScriptDir as the workingdir in the command (as that is where your executable was located)

$asset = "192.168.12.12"
$output = '"c:\documents and settings\eh.txt"'
$command='pslist.exe \\' & $asset & ' > ' & $output
RunWait(@ComSpec & ' /c ' & $command, @ScriptDir, @SW_HIDE)

[edit] clarification

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

You need to specify the working directory when using Run and RunWait. Also I used StringFormat to relieve the quote usage confusion but then I had to escape the hell out of the backslashes.

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