Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Install step to check if user is logged on

I am attempting to install a Java package from the Package Library. I'd like to test if a user is logged into the computer before doing anything. I don't see that I can do this until I reach step 6. Well, by then, the package has already removed the previous versions. 

How can I add a step before Step 1 to test for logged in and quit if true?

0

Comments

3 comments
Date Votes
  • Can I use PowerShell like this and exit is $UserName = Null

    $UserName = (Get-WmiObject  -Namespace root\cimv2 -Class Win32_ComputerSystem).UserName

    0
  • Erik,

    You could probably solve this with PowerShell but here is a simpler way. Go to "Step 3- Kill Java Processes" and go to the Conditions tab. Change "Logged On State" to "Only run if no user is logged on." Go to the Options tab and change the "Error Mode" to "Stop Deployment with Error"

     

    I would advise against modifying steps 1 or 2-- you don't want to set them to stop the deployment on a failure since they will fail on machines that don't have 32/64 bit Java. It's also harmless to run those steps if a user is logged in since they only read a reg value-- they don't actually do anything disruptive to the user. You could create a new step as the first step in the package and set the above options there, though.

    1
  • I found that I can add a Powershell Step as Step1 and set Error Mode within the Options tab to stop on error

     

    $UserName = (Get-WmiObject -Namespace root\cimv2 -Class Win32_ComputerSystem).UserName
    If($UserName){
    exit 100
    }
    Else{
    exit 0
    }

    1