we have a script that needs to run only if a user is logged in. If it runs while they arent logged in it will not achieve the results we need.
I can see how to schedule it. I can see how to check and abort if somebody ISNT logged in. whether I run it now or schedule, it will still run as soon as possible, even if the machine is booted and nobody logs into it.
Is there a way to do it?
If User is logged in
Do rest of Procedure
Reschedule script to run in 15 minutes
It will depend on what your script needs to do.
You can loop it to reschedule the script to run in "X" min if nobody is logged in however you will have a "Y" period after the person logs on before the script runs as per the schedule which is not always ideal.
You could try and trigger the script at logon using process monitoring but I found that this is extremely unreliable.
I use the RunOnce registry key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" to queue up commands I want executed when a user logs on to a computer.
A good example of this is when script connecting to network printers for a Windows PC or server. If nobody is logged in when you attempt this the script will fail so instead what I did with mine is add a command I use to connect to the network printer in the RunOnce Registry key and it executes the command to connect to the printer as soon as somebody logs on.
Have you tried using "impersonate user" or "use credential" commands?
working off of Peter's suggestion, I would reschedule the procedure against #vMachine.machName#? (it wants to specify which machine to run against the next time)
Or do I just need to leave that field blank for it to schedule against the computer it is presently running on?