|
-
Oct 31st, 2012, 06:20 PM
#1
Thread Starter
Frenzied Member
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.
-
Oct 31st, 2012, 06:34 PM
#2
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
-
Oct 31st, 2012, 06:36 PM
#3
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 ...
-
Nov 2nd, 2012, 07:59 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|