locked
adding functions to a Botton in my Form RRS feed

  • Question

  • Hi All

    I am new in VB 2005. I am trying to create a form that will have two function, a reboot and a cancel botton. I am not sure how to add reboot or any other function to the botton when the user click on the botton that he will get on his desktop screen.

    As an example. if I open my command prompt I can type SHUTDOWN -r , and my machine will reboot. I want to add this function to the reboot botton when the user choses to click on the botton. Any suggestion on how I can do this.

    Thank

    Wajdi Georges

    Monday, July 17, 2006 4:27 PM

Answers

  • I think you meant to throw in:

          System.Diagnostics.Process.Start("ShutDown", "/r")

    to actually call the system's shutdown.exe and pass in the /r flag.

    Monday, July 17, 2006 4:35 PM
    Moderator
  • Just do the same class and function, only replace "ShutDown" with the name (or path & name) of your patch file and remove the "/r" (and preceding comma) (unless you need to specify arguments to it).
    Monday, July 17, 2006 4:51 PM
    Moderator

All replies

  • Private Sub Reboot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    SHUTDOWN -r

    End Sub

    Monday, July 17, 2006 4:30 PM
    Moderator
  • Assuming you've already got a StatusBar or other control(s) that provide you with the buttons to click... take a look at the sample code here on how to shutdown/reboot/logoff a system from VB.NET.
    Monday, July 17, 2006 4:32 PM
    Moderator
  • I think you meant to throw in:

          System.Diagnostics.Process.Start("ShutDown", "/r")

    to actually call the system's shutdown.exe and pass in the /r flag.

    Monday, July 17, 2006 4:35 PM
    Moderator
  • Thanks you, adding the

     System.Diagnostics.Process.Start("ShutDown", "/r") to the function of the botton did the trick,

    Many thanks,

    one more qtion since I am new in this area, how can I call another script buy clicking a botton, I mean a batch file as an example.

    Thanks

     

    Monday, July 17, 2006 4:47 PM
  • Just do the same class and function, only replace "ShutDown" with the name (or path & name) of your patch file and remove the "/r" (and preceding comma) (unless you need to specify arguments to it).
    Monday, July 17, 2006 4:51 PM
    Moderator
  • Thanks again, that worked, another qtion

    1- Is there a way to disable ALT+F4 on the dialouge window?

    thanks

    Monday, July 17, 2006 5:08 PM