cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mfry1379
Engaged Sweeper II
I am trying to run a command line in a depoyment as a step to see if an application is running. The command line is below:

tasklist /FI "IMAGENAME eq saplogon.exe" | find /I /N "saplogon.exe"

If it finds the file is running it will return an errorlevel of '0', if it doesn't it will return an errorlevel of '1'.

What I am setting up in the step is to run the command and that the success code is 1 (that it hasn't found the file) and then determining the steps from there.

Everytime I run the deployment though I get the following error:

Result: Deployment ended: The parameter is incorrect.

I am assuming that I am missing something with the way commands are run? When I run the command on the PC directly it works fine, so maybe I am missing soimething with the context within which the command is running, or maybe there is requirement for additional consideration around the way LANSweeper runs the command?

I have tried putting the command in a batch file only to have the same result.

I cannot see anywhere a great deal of detail about how the deployment works, so I probably am misunderstanding something.

Any ideas?
1 ACCEPTED SOLUTION
mfry1379
Engaged Sweeper II
As an update I have being playing around with this after the update to LanSweeper 5224.

I have changed the command slightly to be

tasklist /FI "IMAGENAME eq saplogon.exe" |find "saplogon.exe"

And now it appears the command is working as I get the correct success or failure as per the errorlevels like I want, but I am just a little confused at the feedback.

Result: Deployment ended: Incorrect function. Stop(Success).

Does anyone know what "incorrect function" means? is this something I should be looking in to further or ignoring as somekind of erronious feedback through LanSweeper?

View solution in original post

5 REPLIES 5
CyberCitizen
Honored Sweeper
There is also this,

tgt wrote:
You can accomplish your first point by inserting the following command:
QPROCESS "myprocess.exe">NUL


This would return 0 if the process is running.

From here on you can work with the Actions for Success and Failure...


Seriously Lansweeper, how is this not a default condition option still. Was covered back in 2014 we are now in 2019
Cam
Engaged Sweeper II
I know this post is super old, but I am using this in a new deployment to check and see if Java is running on a PC. Figured I would share. You can simplify the command a bit and if you use findstr, it will search for %tomcat% %java% %jp2launcher% or whatever you put in quotes.

With success as 1 as shown above, I can have it not continue my deployment if it finds one of the processes below.

tasklist | findstr "tomcat java jp2launcher"
Bert_D
Lansweeper Employee
Lansweeper Employee
I've been playing around with your command a little and this is what comes up:

using this command: tasklist /fi "IMAGENAME eq notepad.exe" | find "notepad.exe"

Notepad running: Return code = 0
Notepad Not running: Return code = 1

Windows translation for error codes (MSDN)

ERROR_SUCCESS
0 (0x0)
The operation completed successfully.
ERROR_INVALID_FUNCTION
1 (0x1)
Incorrect function.

ERROR_FILE_NOT_FOUND
2 (0x2)
The system cannot find the file specified.
...

To sum up:
Your command is working correctly, its only the error translation that is a bit 'off'


mfry1379
Engaged Sweeper II
Retract that... I just remembered I am using the error as the success. (If you cannot find the running process then go ahead and install the new version), so whilst the successful steps progress correctly the "incorrect function" is likely a reflection on the command's failure to find the running process.

The failure condition (finding the process) completes successfully.
mfry1379
Engaged Sweeper II
As an update I have being playing around with this after the update to LanSweeper 5224.

I have changed the command slightly to be

tasklist /FI "IMAGENAME eq saplogon.exe" |find "saplogon.exe"

And now it appears the command is working as I get the correct success or failure as per the errorlevels like I want, but I am just a little confused at the feedback.

Result: Deployment ended: Incorrect function. Stop(Success).

Does anyone know what "incorrect function" means? is this something I should be looking in to further or ignoring as somekind of erronious feedback through LanSweeper?