|
-
May 3rd, 2005, 09:10 PM
#1
Thread Starter
Fanatic Member
Running Windows .exe's
How do I make it so that when I click somethign it runs a windows .exe, for example, "C:\WINDOWS\sytem32\shutdown.exe"? Thanks.
-
May 3rd, 2005, 09:21 PM
#2
Lively Member
Re: Running Windows .exe's
Use the Shell Command
VB Code:
Private Sub Command1_Click()
Shell "C:\Windows\System32\shutdown.exe", vbHide
End Sub
-
May 3rd, 2005, 10:16 PM
#3
Thread Starter
Fanatic Member
Re: Running Windows .exe's
Why isn't it shutting down the computer? Any Ideas?
-
May 3rd, 2005, 10:25 PM
#4
Lively Member
Re: Running Windows .exe's
did u use the correct parameters for the exe?
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
-
May 3rd, 2005, 10:27 PM
#5
Re: Running Windows .exe's
You are just displaying the help screen. You need parameters, or you'll get this:
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)
You want
VB Code:
Private Sub Command1_Click()
Shell "C:\Windows\System32\SHUTDOWN.EXE -S", vbHide
End Sub
-
May 3rd, 2005, 10:28 PM
#6
Lively Member
Re: Running Windows .exe's
@David Beat you this time
-
May 3rd, 2005, 10:33 PM
#7
Re: Running Windows .exe's
Kind of weird how you both got the same code example. 
JBD2, what is the use of shutting down the system through code?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 3rd, 2005, 10:37 PM
#8
Lively Member
Re: Running Windows .exe's
@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
-
May 3rd, 2005, 11:33 PM
#9
Re: Running Windows .exe's
 Originally Posted by RobDog888
Kind of weird how you both got the same code example. 
JBD2, what is the use of shutting down the system through code?
Maybe for an automated shutdown. I made a program that does that.
-
May 3rd, 2005, 11:54 PM
#10
Re: Running Windows .exe's
Shutting down network computers, or rebooting them for backups.
-
May 4th, 2005, 09:36 AM
#11
Thread Starter
Fanatic Member
Re: Running Windows .exe's
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|