Click here to Skip to main content
15,897,291 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVBA for Excel Need Help Debugging Date Conversion Pin
codeslingerCA17-Feb-09 4:13
codeslingerCA17-Feb-09 4:13 
AnswerRe: VBA for Excel Need Help Debugging Date Conversion Pin
Dave Kreskowiak18-Feb-09 3:58
mveDave Kreskowiak18-Feb-09 3:58 
Questionload report failed while crystal report running in visual studio 2005 Pin
NaliniNagarajan17-Feb-09 2:18
NaliniNagarajan17-Feb-09 2:18 
AnswerRe: load report failed while crystal report running in visual studio 2005 Pin
tosch17-Feb-09 4:27
tosch17-Feb-09 4:27 
Generalprogress bar Pin
Aamir Mustafa17-Feb-09 1:24
Aamir Mustafa17-Feb-09 1:24 
GeneralRe: progress bar Pin
Ashfield17-Feb-09 1:32
Ashfield17-Feb-09 1:32 
QuestionDrag-arrow on usercontrol in designer Pin
vigylant16-Feb-09 23:43
vigylant16-Feb-09 23:43 
QuestionVBScript logoff Pin
JR21216-Feb-09 22:27
JR21216-Feb-09 22:27 
Sub ShutDown(sNodes, sAction)
  Dim sNode, oWMI, colOperatingSystems, obj, oOS, iCMD, nERR, objShell
  Const EWX_LOGOFF = 0
  Const EWX_SHUTDOWN = 1
  Const EWX_REBOOT = 2
  Const EWX_FORCE = 4
  Const EWX_POWEROFF = 8

  For Each sNode In Split(sNodes, ",")
    Set oWMI = GetObject("winmgmts:" _
       & "{impersonationLevel=impersonate,(Shutdown)}!\\" & sNode & "\root\cimv2")
  
    Set colOperatingSystems = oWMI.ExecQuery("Select * from Win32_OperatingSystem")
    For Each obj In colOperatingSystems
      Set oOS = obj:   Exit For
    Next

    sAction = LCase(sAction)  
    Select Case sAction
      Case "logoff"
        iCMD = EWX_LOGOFF
      Case "logoff_force"
        iCMD = EWX_LOGOFF + EWX_FORCE
      Case "shutdown"
        iCMD = EWX_SHUTDOWN
      Case "shutdown_force"
        iCMD = EWX_SHUTDOWN + EWX_FORCE
      Case "reboot"
        iCMD = EWX_REBOOT
      Case "reboot_force"
        iCMD = EWX_REBOOT + EWX_FORCE
      Case "poweroff"
        iCMD = EWX_POWEROFF
      Case "poweroff_force"
        iCMD = EWX_POWEROFF + EWX_FORCE
      Case "hybernate"
        On Error Resume Next
        Set objShell = CreateObject("Wscript.Shell")
        objShell.Run "%windir%\System32\rundll32.exe PowrProf.dll,SetSuspendState"
        self.Close
        exit sub
      Case Else      ' Default value
        iCMD = EWX_POWEROFF
    End Select
  Next
  oOS.Win32shutdown cint(iCmd),cint(0)
End Sub


Hi,

I use this code to shutdown and reboot my PC. However logoff and poweroff will not work on an windows XP. This code came from MS.
Someona has an idee to solve this?
Ths code must be in script
Jan
AnswerRe: VBScript logoff Pin
DaveAuld16-Feb-09 23:20
professionalDaveAuld16-Feb-09 23:20 
GeneralRe: VBScript logoff Pin
JR21216-Feb-09 23:34
JR21216-Feb-09 23:34 
AnswerRe: VBScript logoff Pin
Dave Kreskowiak17-Feb-09 3:49
mveDave Kreskowiak17-Feb-09 3:49 
GeneralRe: VBScript logoff Pin
JR21217-Feb-09 21:14
JR21217-Feb-09 21:14 
GeneralRe: VBScript logoff Pin
Dave Kreskowiak18-Feb-09 2:13
mveDave Kreskowiak18-Feb-09 2:13 
Questionhexa Pin
aswd16-Feb-09 21:11
aswd16-Feb-09 21:11 
AnswerRe: hexa Pin
DaveAuld16-Feb-09 23:23
professionalDaveAuld16-Feb-09 23:23 
GeneralRe: hexa Pin
aswd17-Feb-09 5:03
aswd17-Feb-09 5:03 
GeneralRe: hexa Pin
EliottA17-Feb-09 5:35
EliottA17-Feb-09 5:35 
GeneralRe: hexa Pin
DaveAuld17-Feb-09 5:55
professionalDaveAuld17-Feb-09 5:55 
GeneralRe: hexa Pin
aswd17-Feb-09 15:30
aswd17-Feb-09 15:30 
GeneralRe: hexa Pin
EliottA18-Feb-09 2:21
EliottA18-Feb-09 2:21 
QuestionInserting Graphs in VB using Visual Studio Pin
EvanSaunders16-Feb-09 20:00
EvanSaunders16-Feb-09 20:00 
AnswerRe: Inserting Graphs in VB using Visual Studio Pin
DaveAuld16-Feb-09 23:27
professionalDaveAuld16-Feb-09 23:27 
QuestionProblem with passing UDT array from Excel VBA to C++ dll Pin
eight16-Feb-09 19:51
eight16-Feb-09 19:51 
AnswerRe: Problem with passing UDT array from Excel VBA to C++ dll Pin
Dave Kreskowiak17-Feb-09 1:48
mveDave Kreskowiak17-Feb-09 1:48 
GeneralRe: Problem with passing UDT array from Excel VBA to C++ dll Pin
eight17-Feb-09 3:30
eight17-Feb-09 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.