Results 1 to 11 of 11

Thread: Running Windows .exe's

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    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.

  2. #2
    Lively Member
    Join Date
    Apr 2005
    Posts
    68

    Re: Running Windows .exe's

    Use the Shell Command
    VB Code:
    1. Private Sub Command1_Click()
    2.     Shell "C:\Windows\System32\shutdown.exe", vbHide
    3. End Sub

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: Running Windows .exe's

    Why isn't it shutting down the computer? Any Ideas?

  4. #4
    Lively Member
    Join Date
    Apr 2005
    Posts
    68

    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:
    1. Private Sub Command1_Click()
    2.     Shell "C:\Windows\System32\shutdown.exe -s", vbHide
    3. End Sub

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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:
    1. Private Sub Command1_Click()
    2.     Shell "C:\Windows\System32\SHUTDOWN.EXE -S", vbHide
    3. End Sub

  6. #6
    Lively Member
    Join Date
    Apr 2005
    Posts
    68

    Re: Running Windows .exe's

    @David Beat you this time

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  8. #8
    Lively Member
    Join Date
    Apr 2005
    Posts
    68

    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

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Running Windows .exe's

    Quote 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.

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Running Windows .exe's

    Shutting down network computers, or rebooting them for backups.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2005
    Posts
    546

    Re: Running Windows .exe's

    Thanks for the help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width