Install step to check if user is logged on

0

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?

Cancel
login to comment
0

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
}

Cancel
login to comment

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.

Cancel
login to comment

0

Can I use PowerShell like this and exit is $UserName = Null

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

Cancel
login to comment

Reply