Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default vba code to reboot

Is it possible to reboot a PC using VBA code

Thanks

Kevin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default vba code to reboot

Kevin,

You can use the ExitWindowsEx API function to do this, but I
would STRONGLY recommend that you do not do this. Users will not
be happy. Just out of curiosity, why do you need to do this?

Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const EWX_REBOOT = 2

Sub AAA()
ExitWindowsEx EWX_REBOOT, 0
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Kevin" wrote in message
...
Is it possible to reboot a PC using VBA code?

Thanks.


Kevin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default vba code to reboot

Thanks for the help Chip

I plan on using this in a macro that will be restricted (by password) for my use only. No other users will experience the reboot. The macro will launch one of two .reg files that will restrist or unrestrict various features, e.g., start/run, file options, find, etc. To take affect the PC must be rebooted. I thought since the macro was running anyway, why not have it reboot the PC too

I'm doing this to safeguard my PC from the children

Kevin
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default vba code to reboot

Hi Kevin;

Sub Reboot()
With CreateObject("Shell.Application")
.ShutdownWindows
End With
End Sub

MP

"Kevin" a écrit dans le message de
...
Is it possible to reboot a PC using VBA code?

Thanks.


Kevin



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I recover a file not saved - auto reboot? publishing in phoenix Excel Discussion (Misc queries) 0 June 13th 07 03:10 PM
ribbon changed after reboot laurie_g Excel Discussion (Misc queries) 2 September 22nd 06 03:36 PM
autorecover doesn't work reliably during a forced reboot johndog Excel Discussion (Misc queries) 1 January 8th 06 03:17 PM
Excel ALWAYS locks up-little white cross-& I need to reboot HELP! Bunky Girl Excel Discussion (Misc queries) 1 July 20th 05 04:17 PM
PC Reboot on Excel Launch CW Excel Discussion (Misc queries) 2 July 13th 05 08:36 AM


All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"