Jump to content

Syntax for embedding @username in tasklist command


Recommended Posts

I'm using this code:

#include <Constants.au3>

Global $DOS, $Message = '' ;; added "= ''" for show only.

$DOS = Run(@ComSpec & " /c tasklist /S server1 /U server1\admin /P password /FI " "USERNAME" & "eq"  & @UserName /FI ""IMAGENAME eq notep*""", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

ProcessWaitClose($DOS)
$Message = StdoutRead($DOS)

MsgBox(0, "Stdout Read:", $Message)

But I can't get the syntax right.  The tasklist command from the commandline goes like this and works: 

tasklist /S server1 /U server1\admin /P password /FI  "USERNAME eq user1" /FI "IMAGENAME eq notep*".  So everything behind the FI parameter needs quotes. I'm using the @username macro to get the logged on user.  But I just can't get the syntax right.

 

Link to comment
Share on other sites

  • Developers

Something like this working?

$DOS = Run(@ComSpec & ' /c tasklist /S server1 /U server1\admin /P password /FI "USERNAME eq '  & @UserName & '" /FI "IMAGENAME eq notep*"', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

×
×
  • Create New...