Results 1 to 6 of 6

Thread: [RESOLVED] Shutdown code

  1. #1

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Resolved [RESOLVED] Shutdown code

    Can any one tell me if there is a code for VB to shutdown windows for example,
    if i hit start an hit shutdown it shutsdown the computer, if there is a piece of code what is it.

    im using VB 2003.net

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

  2. #2
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    413

    Re: Shutdown code

    Probably not the best, but use the process and issue the command "shutdown -s -t 00".

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Shutdown code

    You can call Process.Start to execute the command PENNYSTOCK suggests, but it must be done with two parameters:
    VB Code:
    1. Process.Start("shutdown", "-s -t 00")
    The shutdown.exe commandline program can do much more than that too. You can get help on its parameters either in the Windows help or on the commandline itself. The other option is to use the ExitWindowsEx API. There are plenty of examples on the forum already. Keep in mind that while both these options will work on WinXP they are not available on all Windows versions. I believe that there's another API too but I can't remember the name. Something like "InitiateWindowsShutdown" but not quite.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    413

    Re: Shutdown code

    There is this too...An API. However, this just shows the shut down dialog screen.

    Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal YourGuess As Int32) As Int32

    Then just call

    VB Code:
    1. SHShutDownDialog(1234)

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Shutdown code

    That other API I mentioned is InitiateSystemShutdown and it is available on Win2003 and WinXP only. ExitWindowsEx is available back to Win95, so it is probably the safest bet if your app is likely to be used on older platforms. I believe that shutdown.exe may only be available from Win2000, but I'm not 100% sure.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Hyperactive Member FireKnox101's Avatar
    Join Date
    Aug 2005
    Location
    Snohomish,Washington
    Posts
    301

    Re: Shutdown code

    ty for the feedback ill try ur suggestions

    Im currently using: VB.NET 2003, And VB 2005 Express
    My Projects
    Form Them Show Keypress In App
    Simple Ping Control

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