VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



AA Very Easy Shutdown Methods for Novice Users

by ukWaqas (1 Submission)
Category: Miscellaneous
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

Allows a novice user to shutdown/restart/log off/force shutdown with or without a specific time length his/her computer with a simple one line of code

Rate AA Very Easy Shutdown Methods for Novice Users

 Shutting down the computer in Visual Basic 
There are different commands you can give to shut down the computer.
Type thiese in any procedure e.g. Command1.Click() 


To Log off:  

 retval=shell("RUNDLL32 SHELL32.DLL,SHExitWindowsEx 0",1) 
 

To Shut Down:  

 retval=shell("RUNDLL32 SHELL32.DLL,SHExitWindowsEx 1",1) 
 

To Reboot: 
 retval=shell("RUNDLL32 SHELL32.DLL,SHExitWindowsEx 2",1) 
 

To Force ShutDown: 
 retval=shell("RUNDLL32 SHELL32.DLL,SHExitWindowsEx 4") 
 

The above code can also be inserted into timer so the computer shutdowns after a period of time. 

However, if you are a complete novice and use Windows Xp, then use the following code: 
 

retval=shell("SHUTDOWN /L /T:15 /Y /C",1) 
 

The above code will shutdown in 15 seconds, and close all existing programs without saving. 

If however you wish to stop the shutdown during these 15 seconds, then a simple ccommand: 
 

retval=shell("shutdown /a",1) 
 

should suffice. Note that the 15 seconds can be adjusted to seconds of your choice. Insert /n instead of /y for prompt to save exisiting applications and remove the final parameter /c if you do not want shutdown to be cancelled.
Hope the above Article helps you in understanding in different ways to shutdown. 

Please, please, please vote for me! It is my first submission

Download this snippet    Add to My Saved Code

AA Very Easy Shutdown Methods for Novice Users Comments

No comments have been posted about AA Very Easy Shutdown Methods for Novice Users. Why not be the first to post a comment about AA Very Easy Shutdown Methods for Novice Users.

Post your comment

Subject:
Message:
0/1000 characters