Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-11-25
10
Medium Priority
?
171 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 25

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Accepted Solution

by:
NVIT earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

916 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