Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shell "shutdown.exe -s" not working/spawning random button
#1
I made a program to shutdown my computer. It has two buttons, one to shut it down, the other to exit the program.

When I run it out of visual basic, everything runs fine. When I compile it, it spawns a random button which, when clicked, opens another copy of the program (shutdown.exe) and then halts.

Here is the code used on the shutdown button:
Code:
Private Sub Picture1_Click(Index As Integer)
'Shutdown the computer
Shell ("shutdown.exe -s")

End Sub

Is this my dodgey copy of VB or an error?

Maybe someone else could compile for me?
Reply
#2
Maybe you could post your full source code ( Unless you dont want any one having it ) So they can examine more closely.
Reply
#3
Lol nah, I don't care! here it is:

Form:
Code:
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000

Option Explicit

Dim TLevel As Integer

Private Sub Command1_Click()

    Timer1.Enabled = False
                              
    Timer2.Enabled = True

End Sub

Private Sub Form_Load()

    Timer2.Enabled = False

    TLevel = 5
  
    TransForm Me, Val(TLevel)

End Sub


Private Sub picture2_Click(Index As Integer)
End
End Sub

Private Sub Timer1_Timer()

TLevel = TLevel + 5

TransForm Me, Val(TLevel)

    If TLevel = 255 Then
        Timer1.Enabled = False
    End If

End Sub

Private Sub Timer2_Timer()

TLevel = TLevel - 5

TransForm Me, Val(TLevel)

    If TLevel = 5 Then
        Unload Me
    End If
  
End Sub
Private Sub Command99_Click()
    Dim lStyle As Long
    lStyle = GetWindowLong(Me.hWnd, GWL_STYLE)
    SetWindowLong Me.hWnd, GWL_STYLE, lStyle And Not WS_CAPTION
End Sub


Private Sub Picture1_Click(Index As Integer)
'Shutdown the computer
Shell ("shutdown.exe -s")
'close program
End
End Sub

Module (for fade effect):
Code:
Option Explicit

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2

Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) _
As Long

Private Declare Function SetLayeredWindowAttributes Lib _
"user32" (ByVal hWnd As Long, ByVal crKey As Long, _
ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Public Function TransForm(Form As Form, TransLevel As Byte) As Boolean
SetWindowLong Form.hWnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Form.hWnd, 0, TransLevel, LWA_ALPHA
TransForm = Err.LastDllError = 0
End Function
Reply
#4
Just use this:

Private Sub btnShutdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShutdown.Click
System.Diagnostics.Process.Start("shutdown", "-s -t 00")
'This will make the computer Shutdown
End Sub

Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click
System.Diagnostics.Process.Start("shutdown", "-r -t 00")
'This will make the computer Restart
End Sub

Private Sub btnLogOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogOff.Click
System.Diagnostics.Process.Start("shutdown", "-l -t 00")
'This will make the computer Log Off
End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
End
'This will make the program to terminate(end the program)
End Sub

Change "00" to "1000" , and it will execute your command after 1 minute
Reply
#5
Appreciated... +Rep
Turns out it was my compiler... having issues with that program...

Works fine now :S Made a restart one and it works fine!
Reply
#6
Np m8 , hope you got it working
Reply
#7
Lol Vorfin, I see your post made it into the rite thread but.
Reply
#8
(11-06-2009, 07:31 AM)Fail Ninja Wrote: Lol Vorfin, I see your post made it into the rite thread but.

:S
Reply
#9
Huh? Im also confused. Vorfin posted the code for a fade in application in here. But he must have deleted his post.
Reply
#10
Haha, its in the other thread now Tongue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  dfsvc.exe crashing eXtremer 0 730 11-15-2012, 05:45 AM
Last Post: eXtremer
  Good Button :) HF~Legend 5 2,069 09-28-2012, 01:21 AM
Last Post: rqmok
  Button firefox Menu HF~Legend 2 1,524 09-08-2012, 04:20 PM
Last Post: spesificrelax
  vLoader 1.0 - File Uploader - Exe to Web - Easy - MediaFire Link Die 2 1,630 01-07-2012, 02:57 PM
Last Post: Die
  [Release] Shutdown Timer (My Version) euverve 13 4,611 12-11-2011, 10:53 PM
Last Post: euverve

Forum Jump:


Users browsing this thread: 2 Guest(s)