Results 1 to 4 of 4

Thread: how to do this in vb?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    how to do this in vb?

    Hi I need to make my exe call exact same thing as the batch file below:

    @ECHO OFF
    LOGOFF

    How do I call this in Vb? It needs to be exact same thing. I tried shell shutdown /l but that logs off everything. The batch file above doesn't logoff everything.

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: how to do this in vb?

    Try this
    Code:
    Option Explicit
    Private Const EWX_LOGOFF = 0
    Private Const EWX_SHUTDOWN = 1
    Private Const EWX_REBOOT = 2
    Private Const EWX_FORCE = 4
    Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    
    Private Sub Command1_Click()
        Dim a As Integer
        a = MsgBox("Are you sure you want to logoff?", vbQuestion + vbYesNo + vbDefaultButton2)
        If a = vbOK Then
            ExitWindowsEx EWX_FORCE Or EWX_LOGOFF, 0
        End If
    End Sub



  3. #3
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: how to do this in vb?

    Try:
    Code:
    Shell("cmd /c C:\YourFolder\YourFile.bat", AppWinStyle.NormalFocus)
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: how to do this in vb?

    Here's another way without using a batch file:

    Code:
    Shell "CMD /C @ECHO OFF & LOGOFF", vbHide
    The switch /C tells cmd.exe to execute the succeeding arguments. The ampersand (&) concatenates multiple commands on one line.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

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