Shut Down the Computer

hmk

Active Member
Joined
Jun 8, 2004
Messages
423
Hi there

Is there a VBA code to shut down the computer ?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thank u 4 reply

i tried this
Code:
Sub Test2()

'SHUTDOWN [logoff_option]  [/m \\Computer] [options]
'/s         Shutdown    
'/r         Shutdown and Restart

SHUTDOWN /s 

End Sub

but it tells me Expected : Expression and highlight this sign /

could you please show me how to make it work ?? (y)
 
Upvote 0
Perhaps:

Code:
Sub test()
Shell (Environ("SystemRoot") & "\System32\shutdown.exe -s")
End Sub
 
Upvote 0
Thank u v much

it worked, but how about using r, it did not work, it only shuts the pc down, any idea why ?

and how about controlling the defult time of shuting down ?


r is to shutdown and restart the PC

Thank u v much (y)
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,342
Members
448,956
Latest member
Adamsxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top