Solved

need assistance with a login script that will reboot the system only one time

Posted on 2014-11-25
10
144 Views
Last Modified: 2014-11-25
We are deploying a login script that requires the system be rebooted, however we need a way to add logic to the script so that the system will not reboot as second time.

can someone provide a way that we can add additional logic to copy a file and if the system sees the file, it will know not to reboot a second time.

thanks in advance.

S
0
Comment
Question by:siber1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
10 Comments
 
LVL 24

Expert Comment

by:NVIT
ID: 40465645
Is the script a .bat file? How about...
if exist %temp%\DidReboot.txt goto :EOF
(reboot code here)

Open in new window

0
 

Author Comment

by:siber1
ID: 40465654
thx. how would I incorporate that into this script, so that the system does not reboot each time the users logs in:

@echo off
MsiExec.exe /I{8F023021-A7EB-45D3-9269-D65264C81729} /qb
MsiExec.exe /X {786A9F7E-CFEC-451F-B3C4-22EB11550FD8} /q
powershell -executionpolicy bypass -file \\fs1\deploy\fwenable.ps1
gpupdate /force
shutdown.exe /r /t 00

Open in new window

0
 
LVL 29

Expert Comment

by:becraig
ID: 40465657
simply set a scheduled task on the computer to run at startup and to run once.
Step1 The scheduled task
schtasks /create /RU system /SC ONSTART /TN "Reboot Task"
/TR "c:\temp\rebooter.ps1"

Open in new window



maybe a simple one liner script like this (save as ebooter.ps1)

Step2 The script
New-Item -Type file c:\rebooted.txt SchTasks /Delete /TN “Reboot Task”
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Accepted Solution

by:
NVIT earned 500 total points
ID: 40465659
@echo off
MsiExec.exe /I{8F023021-A7EB-45D3-9269-D65264C81729} /qb
MsiExec.exe /X {786A9F7E-CFEC-451F-B3C4-22EB11550FD8} /q
powershell -executionpolicy bypass -file \\fs1\deploy\fwenable.ps1
gpupdate /force

if exist %temp%\DidReboot.txt goto :EOF
shutdown.exe /r /t 00
echo Rebooted %computername% %date% %time%>%temp%\DidReboot.txt

Open in new window

0
 

Author Closing Comment

by:siber1
ID: 40465669
brilliant. just what I was looking for.

many thanks!
0
 
LVL 29

Expert Comment

by:becraig
ID: 40465672
Taking a look at your script, I cannot see any reason not to reboot after the msi install.

The chances of a reboot happening before the msi install is complete seems highly unlikely.


So in this scenario, if the msi is what requires the reboot then no matter if a recent shutdown happened or not it will still need to reboot.
0
 

Author Comment

by:siber1
ID: 40465682
thanks becraig, the issue is, we needed that logic to prevent the system from rebooting every time the user logs in.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40465692
So then instead of checking for the file when the system reboots, check for the presence of whatever it is the msi is installing.

That way you also do not install on every login.

There has to be a way to do that check simply make that your first step and evaluate if it is present and exit if it is, if not then run the msi install and reboot.
0
 

Author Comment

by:siber1
ID: 40465702
ah.. sorry the syntax I provided was slightly off, I should have read /x  [these are uninstall commands only]
good catch :)
0
 
LVL 29

Expert Comment

by:becraig
ID: 40465711
In either event I would still check the presence before the uninstall action.

I am sure you can do so using any number of options based on how the application is actually installed.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question