Auto restart of window 7 pc gracefully

Hello,

We have a pc that we would like to restart nightly.  the catch is that we cannot force the restart as Microsoft outlook is installed and running.  is there a way to bring down the applications and then restart the machine once they are done?
posaeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

flubbsterCommented:
I assume you are using task scheduler to do the shutdown and are using the shutdown command to do the restart. I would just change the command to the following:

shutdown /l /f /r

/l = log off any user
/f = force close any program without prompt
/r = restart
posaeAuthor Commented:
thanks flubbster.  yes this is through safe mode.  The only issue is forcing the close...i am assuming this doesn't shut down outlook gracefully, correct?  The reason i ask is when the machine comes back up, if outlook did not close down it prompts to start in safe mode.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

flubbsterCommented:
Any open program is "forced" to shutdown.
posaeAuthor Commented:
i created a script to do the following which worked:

delay = 30000 'delay in milliseconds to let Outlook close gracefully
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")

'If Outlook is running, let it quit on its own.
For Each Process in objWMIService.InstancesOf("Win32_Process")
  If StrComp(Process.Name,"OUTLOOK.EXE",vbTextCompare) = 0 Then
    Set objOutlook = CreateObject("Outlook.Application")
    objOutlook.Quit
    WScript.Sleep delay
    Exit For
  End If
Next

'Make sure Outlook is closed and otherwise force it.
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Outlook.exe'")
For Each objProcess in colProcessList
  objProcess.Terminate()
Next

wscript.sleep delay

Set objWMIService = Nothing
Set objOutlook = Nothing
Set colProcessList = Nothing

Set WSHShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
posaeAuthor Commented:
this solution found was the best fit
flubbsterCommented:
Glad you go it. Funny... I found the exact same script on another webpage :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Miscellaneous

From novice to tech pro — start learning today.