Jump to content

PsExec - escape character '>'


JakubPL
 Share

Recommended Posts

Hi guys!
Calling the below command from poweshell works flawlessly:

PsExec.exe \\remote-server-name -u User -p Pass tasklist /FI "ImageName eq notepad.exe" > C:\tmp\notepad_tasks.txt

When i try to call it form AutoIT script:

RunWait("PsExec.exe \\remote-server-name -accepteula -u User -p Pass tasklist /FI ""ImageName eq notepad.exe"" > C:\tmp\notepad_tasks.txt")

i keep getting this error:

Quote

ERROR: Invalid argument/option - '>'.
Type "TASKLIST /?" for usage.
tasklist exited on remote-server-name with error code 1.

 

The below action works without any problems:

RunWait("PsExec.exe \\remote-server-name -accepteula -u User -p Pass tasklist /FI ""ImageName eq notepad.exe"")

 

Any suggestions on how to escape the sign '>' ?

Link to comment
Share on other sites

  • Developers

Try added the cmd prompt to allow for piping the STDOUT: 

RunWait(@comspec & " /c PsExec.exe \\remote-server-name -accepteula -u User -p Pass tasklist /FI ""ImageName eq notepad.exe"" > C:\tmp\notepad_tasks.txt")

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

10 hours ago, Jos said:

Try added the cmd prompt to allow for piping the STDOUT: 

RunWait(@comspec & " /c PsExec.exe \\remote-server-name -accepteula -u User -p Pass tasklist /FI ""ImageName eq notepad.exe"" > C:\tmp\notepad_tasks.txt")

Jos

Yessss! This solution is working.

 

Thnak you very much foer your help!!!

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