How do I make it so that when I click somethign it runs a windows .exe, for example, "C:\WINDOWS\sytem32\shutdown.exe"? Thanks.
Printable View
How do I make it so that when I click somethign it runs a windows .exe, for example, "C:\WINDOWS\sytem32\shutdown.exe"? Thanks.
Use the Shell Command
VB Code:
Private Sub Command1_Click() Shell "C:\Windows\System32\shutdown.exe", vbHide End Sub
Why isn't it shutting down the computer? Any Ideas?
did u use the correct parameters for the exe?
Quote:
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without war
ning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)
VB Code:
Private Sub Command1_Click() Shell "C:\Windows\System32\shutdown.exe -s", vbHide End Sub
You are just displaying the help screen. You need parameters, or you'll get this:
You wantQuote:
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)
VB Code:
Private Sub Command1_Click() Shell "C:\Windows\System32\SHUTDOWN.EXE -S", vbHide End Sub
@David Beat you this time :)
Kind of weird how you both got the same code example. :lol:
JBD2, what is the use of shutting down the system through code?
@Rob we both added the param to the original posted code (Post #2). I find it weirder that we both copied and pasted from the command prompt at the same time :)
Maybe for an automated shutdown. I made a program that does that.Quote:
Originally Posted by RobDog888
Shutting down network computers, or rebooting them for backups.
Thanks for the help.