Solved

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

Posted on 2014-11-25
10
138 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
  • 4
  • 4
  • 2
10 Comments
 
LVL 23

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 28

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
 
LVL 23

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 28

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 28

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 28

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

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now