14 Replies - 4035 Views - Last Post: 14 March 2012 - 08:27 AM

#1 born2c0de   User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 187
  • View blog
  • Posts: 4,673
  • Joined: 26-November 04

Shutdown Computer from VB

Posted 05 March 2005 - 05:30 AM

Description: Shows how to Shutdown,LogOff and Force Shutdown using VB
' SHUT DOWN AND RESTART IN VB6
       Const EWX_LogOff As Long = 0
       Const EWX_SHUTDOWN = 1
       Const EWX_REBOOT = 2
       Const EWX_FORCE = 4
       Private Declare Function ExitWindows _
               Lib "User32" Alias "ExitWindowsEx" _
               (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
      
     Private Sub Command1_Click()

          'Shut down windows
          ExitWindows EWX_SHUTDOWN, &HFFFFFFFF
      
      
     End Sub
      
     Private Sub Command2_Click()
     
          
          ExitWindows EWX_REBOOT, &HFFFFFFFF
      
      
     End Sub
      
      




Is This A Good Question/Topic? 0
  • +

Replies To: Shutdown Computer from VB

#2 born2c0de   User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 187
  • View blog
  • Posts: 4,673
  • Joined: 26-November 04

Re: Shutdown Computer from VB

Posted 05 March 2005 - 05:30 AM

Description: Shows how to Shutdown,LogOff and Force Shutdown using VB
' SHUT DOWN AND RESTART IN VB6
       Const EWX_LogOff As Long = 0
       Const EWX_SHUTDOWN As Long = 1
       Const EWX_REBOOT As Long = 2
       Const EWX_FORCE As Long = 4
       Private Declare Function ExitWindows _
               Lib "User32" Alias "ExitWindowsEx" _
               (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long
      
     Private Sub Command1_Click()

          'Shut down windows
          ExitWindows EWX_SHUTDOWN, &HFFFFFFFF
      
      
     End Sub
      
     Private Sub Command2_Click()
     
          
          ExitWindows EWX_REBOOT, &HFFFFFFFF
      
      
     End Sub
      
      



Was This Post Helpful? 0
  • +
  • -

#3 shankarpatil   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 19-August 08

Re: Shutdown Computer from VB

Posted 19 August 2008 - 01:34 AM

hi sir, iam shankar patil from - kolhapur disctic please me option button socurce code vb 6.0 in a program. example : exam form & 4 option button, then click the one button msgbox("you are wrong answer?" & "You are carrect answer?")
Was This Post Helpful? 0
  • +
  • -

#4 kasc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-October 08

Re: Shutdown Computer from VB

Posted 26 October 2008 - 12:24 PM

this is a task i've been trying to solve but i need it in VB.net 2005. my e-mail [email protected] i will be greatful to have the solution. thank you
Was This Post Helpful? 0
  • +
  • -

#5 Ricendithas   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 59
  • Joined: 12-July 08

Re: Shutdown Computer from VB

Posted 26 December 2008 - 05:18 PM

Hello there, I was wondering, how come only logoff only works while the others don't?
Was This Post Helpful? 0
  • +
  • -

#6 born2c0de   User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 187
  • View blog
  • Posts: 4,673
  • Joined: 26-November 04

Re: Shutdown Computer from VB

Posted 27 December 2008 - 06:19 AM

Fixed. It should work now.
Was This Post Helpful? 0
  • +
  • -

#7 naruto3650   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 04-August 09

Re: Shutdown Computer from VB

Posted 04 August 2009 - 06:07 AM

nothing happen!
Was This Post Helpful? 0
  • +
  • -

#8 senthilds08   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-November 09

Re: Shutdown Computer from VB

Posted 18 November 2009 - 03:48 AM

hello friends its not working for me. pls help
Was This Post Helpful? 0
  • +
  • -

#9 NAVEEN48049   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 22-April 10

Re: Shutdown Computer from VB

Posted 22 April 2010 - 10:08 PM

it doesn't work.
Was This Post Helpful? 0
  • +
  • -

#10 Victorybiz   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 04-April 10

Re: Shutdown Computer from VB

Posted 05 May 2010 - 04:34 PM

I need combo box code to shutdown window
Was This Post Helpful? 0
  • +
  • -

#11 WgJauharah   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-August 10

Re: Shutdown Computer from VB

Posted 04 August 2010 - 03:11 PM

how it work? we have to click a button? i need code that control by timer..please help me.thx.
Was This Post Helpful? 0
  • +
  • -

#12 haithamshao   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 16-January 11

Re: Shutdown Computer from VB

Posted 16 January 2011 - 04:20 AM

hai,i'm trying do this in windows 7 but no work how i can do it in windows7 thankk
Was This Post Helpful? 0
  • +
  • -

#13 zafcom   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 09-July 11

Re: Shutdown Computer from VB

Posted 09 July 2011 - 01:27 AM

sir, it did work on my project... so how can i add a delay before it logs off the computer?
Was This Post Helpful? 0
  • +
  • -

#14 zafcom   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 09-July 11

Re: Shutdown Computer from VB

Posted 09 July 2011 - 01:30 AM

i wanted to give it at least 60 seconds before the program logs off the PC...
Was This Post Helpful? 0
  • +
  • -

#15 itsniL   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-July 11

Re: Shutdown Computer from VB

Posted 22 July 2011 - 04:32 AM

why you are going for API calls. Just try Run commands, just one line code. Type Shell "shutdown -r -t 25" to Restart computer in 25 seconds. (note that Coundown is displayed.) You may try similar run commands. like Shell "shutdown -l -f" to logoff. for details Type shutdown in command prompt.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1