Hi Guys,
I'm trying to setup a script which should be able to run ONE time ONLY after reboot.
I don't need the script to run more than once and especially not if the user just logged off and logged in back - I need it to run only after the first restart.
The problem with the active setup, or run/runonce keys is that they are ran after the user is logging in, regardless the machine state (rebooted or not).
The purpose of this is that I have a package that should apply a bios update on Windows7, and the scenario is something like this:
Disable BitLocker
Install Bios Patch
Reboot Machine (user triggered)
ReEnable Bitlocker.

So as you see, I cannot reenable bitlocker if the machine has not been rebooted.
And I cannot reboot the machine by force, I have to let the user do it by himself. So somehow I must make sure that the reenable part is done ONLY after the next restart.
Any ideas are appreciated. Thanks.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

2
*VERY* much off the top of my head...perhaps compare the computer's uptime property against the user's last logon property?
Answered 10/05/2011 by: VBScab
Red Belt

Please log in to comment
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Sounds like a Windows Scheduled Task might be what you need.
Answered 10/05/2011 by: kin327
Senior Yellow Belt

Please log in to comment
0
ORIGINAL: VBScab

*VERY* much off the top of my head...perhaps compare the computer's uptime property against the user's last logon property?

Hmm, starting from this you gave me an idea.
1. When installing the bios patch I will read the last boot time using:
e.g.:

set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")
set objWMI = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
If Err Then ShowError
set colOS = objWMI.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
next

and write the last boot time in a registry, somewhere.

2. Ask for reboot, then the user reboots or not.
3. Next time when he logs in, an active setup script will use the same function that reads the lastBootUpTime
  • if the current lastbootUpTIme is the same with the one written at install (in the above mentioned reg) means that no reboot has been made from that point ....and then I delete the CurrentUser ActiveSetup registry so it will rerun at next logon.
  • eventually when the user logs in, but meanwhile he initiated a reboot, the active setup script will see that current lastbootUpTIme is greater than the one written at install time --> then enable the bitlocker and leave the currentuser ActiveSetup in place so it won't run ever again.
Of course I have to implement and test to see how it will actually work. But if you see any downside please let me know.

Many thanks for the idea!
Answered 10/05/2011 by: dryce
Senior Yellow Belt

Please log in to comment
0
ORIGINAL: kin327

Sounds like a Windows Scheduled Task might be what you need.

I tried that too, but no luck in getting a Task ran once and only after the next restart.
all I could find was either only once from a given date, either after every restart from a given date.
I need these two combined somehow.
Answered 10/05/2011 by: dryce
Senior Yellow Belt

Please log in to comment
0
if the current lastbootUpTIme is the same with the one written at install (in the above mentioned reg) means that no reboot has been made from that point ....and then I delete the CurrentUser ActiveSetup registry so it will rerun at next logon.

You might want to consider using the RUN key for this, and deleting that if the script runs successfully. Seems like a simpler solution to me since you don't need a user-based control mechanism. A reboot is a reboot afterall.

PJ
Answered 10/05/2011 by: pjgeutjens
Red Belt

Please log in to comment
0
ORIGINAL: pjgeutjens

if the current lastbootUpTIme is the same with the one written at install (in the above mentioned reg) means that no reboot has been made from that point ....and then I delete the CurrentUser ActiveSetup registry so it will rerun at next logon.

You might want to consider using the RUN key for this, and deleting that if the script runs successfully. Seems like a simpler solution to me since you don't need a user-based control mechanism. A reboot is a reboot afterall.

PJ


Yes, I will take that into consideration, thanks - it will make things more easier to control, from the scripting POV.
The thing with active setup is that I always preferred it because it is ran much earlier then the run key. The AS is ran before explorer.exe starts kicking, so the user has to wait in the Welcome screen ..before he can do anything on the machine - this way he has almost 0 chances to interfere, in any way, with the logon script triggered by AS.
but for this case, the run key would suffice - I think
Answered 10/05/2011 by: dryce
Senior Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity