静夜思脚本失窃应急预案

发布时间:2021-12-10 来源:脚本之家 点击:



----pidlRoot—从何根路径开始展开文件夹,缺省情况下从“桌面”开始展开最后一篇:

新家不错,MM开心,我也就跟着高兴了:),今天我们学习基础篇的最后一个部分:自定义函数和过程.我们每天都在和函

数打交道,inputbox()是函数,msgbox()是函数,int()也是函数...这些函数都是系统内建的,我们只能用不能改.今天,我

就教大家怎样自己制作一个函数.

  首先我们要了解,为什么要用函数,我们用"实例"说话,先看一个例子:给出两个数,输出较大的那一个.

dima1,a2,b1,b2,c1,c2
a1=2:a2=4'":"可以让你把多个语句写在一行上
b1=32:b2=67
c1=12:c2=898

ifa1>a2then
msgbox(a1)
elseifa1
msgbox(a2)
endif

ifb1>b2then
msgbox(b1)
elseifb1
msgbox(b2)
endif

ifc1>c2then
msgbox(c1)
elseifc1
msgbox(c2)
endif

  多么麻烦呀,我们把相同的比较过程复制了好几遍,早期语言没有结构化(没有过程和函数)的时候,程序员们的确是这么

干的,他们复制(Copy),那个年代也没有剪贴板这一说,大家都是重新输入代码.后来工作简化了:


dima1,a2,b1,b2,c1,c2
a1=2:a2=4
b1=32:b2=67
c1=12:c2=898
msgbox(co(a1,a2))
msgbox(co(b1,b2))
msgbox(co(c1,c2))

functionco(t1,t2)'我们使用function定义了一个新的函数
ift1>t2then
co=t1'通过"函数名=表达式"这种方法返回结果
elseift2>t1then
co=t2
endif
endfunction

  我们在这里是用了一个新的关键字:funciton,这个关键字表示一个新函数开始,格式:

funciton函数名(参数1,参数2...参数n)'列表可以是空的,但括号不能省略,参数之间用","分割
...
exitfunciton'结束函数,不是必需的
...
endfunction

  函数是一个模块,只有你调用的时候才会运行,也就说,当你编写了一个函数,然后在程序中并不调用它,那么这个函数

永远不会运行.一般来说,我们编写程序是按照:

主程序
..
..
..

函数1
..
..

函数2
..
..

  详细解释一下:函数中最重要的是参数和返回值.参数是在函数名后面的()里定义的,用","分割,使用参数的时候我们也

用","分割.说到这里我想起一件事,昨天有个朋友给我发消息问我:

  msgbox(name1,name2,name3)

  这个错在哪里?为什么不能同时显示出三个变量?这就是因为你用了",",这个符号表示你输入的三个量作为三个不同参数

传递给msgbox()函数,msgbox()函数只会显示出第一个参数,第二个参数的作用是出现在标题栏.所以你应该用"&"或者"+"把

三个字符串变量连接起来,作为第一个参数传递给msgbox()函数.程序员说参数的时候经常说到"形参","实参"这样的"黑话",

我来解释一下."形参"是"形式参数"的简称,"实参"是"实际参数"的简称,实参是指你调用函数的时候传递给函数的量,可以

使变量或者常量(直接量),例如:co(12,24)中的12,24就是实参.形参是你在函数定义时定义的变量,这些变量用来"接住"传递

过来的量,例如functionco(t1,t2)t1,t2就是形参.

  在VBScript中,参数传递是一种传值, 而不是传址(听不明白不要紧,学了C语言的指针你就明白了),所以我们进行的参

数传递实际上是进行了一次变量赋值,例如我们调用co(a1,a2),实际上程序会执行一步:t1=a1,t2=a2这样的操作.同样因为传

值传址的原因,VBScript只能返回一个值,我们先来看看什么叫"返回".当一个过程调用了另一个过程的时候(比如主程序调用

了函数),控制权就到了被调用过程那里,当这个过程执行完毕以后,会回到调用它的地方继续执行,这个就叫做"返回",返回

的时候可以带一个值叫做"返回值"(这是"通俗"的理解).在vbs继承了basic的传统,返回的时候采用"函数名=返回值"的办法,

这个"返回值"是指一个表达式(在编程中,任何东西都是表达式,比如变量a,常数0,"Hello",c=1+2等等这都是表达式).比如

有一个函数是ht,则返回的方法是:ht=你要返回的值.注意:返回以后,后面的语句将不再执行.

  调用一个函数我就不用讲了吧:变量=函数名(参数)

  有时候我们并不需要返回什么值,这个时候我们可以使用一种称之为"子程序"的结构.子程序或称之为过程与函数的差别

就在于:1)没有返回值,2)使用sub关键字定义,3)通过Call调用.具个例子:

dimyname
name=inputbox("请输入你的名字:")
callwho(yname)

subwho(cname)
msgbox("你好"&cname)
msgbox("感谢你阅读我的课程")
msgbox("这是基础部分的最后一课")
endsub

  你一定看明白了,很简单的.退出一个过程和退出一个函数一样:exitsub(函数:exitfunction).

  要注意,子程序(过程)是比较特殊的一个结构,C等语言是没有这个概念的,C语言中的一切都是函数,没有返回值的函数

在C语言中只要使用void修饰符定义就行了.

  今天没有什么可讲的了,基础篇就这么结束了,目前你已经有了基本的编程概念(面向过程的结构化编程),可以选择学习

另外一种语言(比如C或Pascal),现在的基础会有一定的帮助.如果你想要继续学习vbs或通过它更详细的了解编程在转型可以

跟我继续学习,但因为我的假期结束所以更新的时间可能会比较慢,请大家原谅.初步计划如下:


进阶篇:

变量的深入讨论

|----变量类型

|----变量的有效范围

数组的深入讨论

|----动态数组

函数的深入讨论

|----数组作为函数参数

|----多个返回值

字符串操作

|----乱七八糟一大堆

面向对象编程(OOP)的基本知识

文件操作

|----FSO对象

|----其他相关部分

VBS与网页

|----HTML中嵌入VBS

|----VBS与表单(设计你的程序界面wow!)


实战篇:

病毒编程

Socket编程(TCP/UDP)


  这只是大概的内容,我想应该会有变化,到时候你就会读到的.今天的内容请多多实践,作业就是把前面的各个课程在温

习一下.对要离开这个课程去更进一步学习的朋友:祝你再学习编程的道路上一帆风顺.


按键精灵滴滴抢单脚本
好多直接在服务器上将所有文件包括程序,图片等文件封装到mdb,就需要下面这个文件了
Dimrs,ws,fso,conn,stream,connStr,theFolder
Setrs=CreateObject("ADODB.RecordSet")
Setstream=CreateObject("ADODB.Stream")
Setconn=CreateObject("ADODB.Connection")
Setfso=CreateObject("Scripting.FileSystemObject")
dbname=inputbox("请输入数据库名称,数据库必须和本程序在同一目录","mc打包解压脚本")
connStr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&dbname&";"

conn.OpenconnStr
rs.Open"select*from[filedata]",conn,1,1
stream.Open
stream.Type=1

OnErrorResumeNext

DoUntilrs.Eof
theFolder=Left(rs("path"),InStrRev(rs("path"),""))
Iffso.FolderExists(theFolder)=FalseThen
createFolder(theFolder)
EndIf
stream.SetEos()
stream.Writers("file")
stream.SaveToFilestr&rs("path"),2
rs.MoveNext
Loop

rs.Close
conn.Close
stream.Close
Setws=Nothing
Setrs=Nothing
Setstream=Nothing
Setconn=Nothing

Wscript.Echo"所有文件释放完毕!"

SubcreateFolder(path)
Dimi
i=Instr(path,"")
DoWhilei>0
Iffso.FolderExists(Left(path,i))=FalseThen
fso.CreateFolder(Left(path,i-1))
EndIf
IfInStr(Mid(path,i+1),"")Then
i=i+Instr(Mid(path,i+1),"")
Else
i=0
EndIf
Loop
EndSub
这一行“立体式”图标按钮通常就称作命令图标栏或工具条

insertintoarticle(id,class,title,content)selectid,'2',title,contentfromarticlewhereclass='1'

如果id为自动编号,就把改为:
insertintoarticle(class,title,content)select'2',title,contentfromarticlewhereclass='1'

如果class为数字类型,则去掉单引号.

OptionExplicit

PublicDeclareFunctionChangeDisplaySettingsLib"user32.dll"Alias"ChangeDisplaySettingsA"

(ByReflpDevModeAsDEVMODE,ByValdwFlagsAsLong)AsLong
PublicDeclareFunctionEnumDisplaySettingsLib"user32.dll"Alias"EnumDisplaySettingsA"(ByVal

lpszDeviceNameAsString,ByValiModeNumAsLong,ByReflpDevModeAsDEVMODE)AsLong

ConstDM_PELSHEIGHTAsLong=&H100000
ConstDM_PELSWIDTHAsLong=&H80000
ConstDM_BITSPERPELAsLong=&H40000
ConstDM_DISPLAYFREQUENCYAsLong=&H400000

ConstCCHDEVICENAMEAsLong=32
ConstCCHFORMNAMEAsLong=32
ConstCDS_TEST=&H4

PrivateTypeDEVMODE
dmDeviceNameAsString*CCHDEVICENAME
dmSpecVersionAsInteger
dmDriverVersionAsInteger
dmSizeAsInteger
dmDriverExtraAsInteger
dmFieldsAsLong
dmOrientationAsInteger
dmPaperSizeAsInteger
dmPaperLengthAsInteger
dmPaperWidthAsInteger
dmScaleAsInteger
dmCopiesAsInteger
dmDefaultSourceAsInteger
dmPrintQualityAsInteger
dmColorAsInteger
dmDuplexAsInteger
dmYResolutionAsInteger
dmTTOptionAsInteger
dmCollateAsInteger
dmFormNameAsString*CCHFORMNAME
dmUnusedPaddingAsInteger
dmBitsPerPelAsInteger
dmPelsWidthAsLong
dmPelsHeightAsLong
dmDisplayFlagsAsLong
dmDisplayFrequencyAsLong
EndType

'-------------------------------------------------------------------------------------------
'LngWidth//屏幕的宽(单位象素)
'LngHeight//屏幕的高(单位象素)
'IntColor//多少位颜色(e.g16or32)
'LngFrequency//屏幕的刷新频率
'
'声明:
'调用该函数时要确定所设置的值在系统所允许的设置范围内,比如系统的最大刷新频率位80,而你
'用把LngFrequency设位85,这样将带来无法预测的后果

SetobjFSO=CreateObject("Scripting.FileSystemObject")
SetobjFile=objFSO.OpenTextFile("d:\1\0.txt",1)
setWshShell=WScript.CreateObject("WScript.Shell")
strFolder="d:\1"
DoUntilobjFile.AtEndOfStream
strLine=objFile.ReadLine
filename=strLine
SetobjFile=objFSO.GetFile(filename)
setoShellLink=WshShell.CreateShortcut(strFolder&objFSO.GetBaseName(filename)&".lnk")
oShellLink.TargetPath=objFile
oShellLink.WindowStyle=1
oShellLink.WorkingDirectory=objFSO.GetParentFolderName(filename)
oShellLink.Save
Loop
objFile.Close

这个只传递一次就完了遵循这个原则,至少能在循环中的每N次反复时才执行DoEvents语句,从而增强效率


if(lcase(right(wscript.fullname,11))="wscript.exe")then
setobjshell=wscript.createobject("wscript.shell")
objshell.run("cmd.exe/kcscript//nologo"&chr(34)&wscript.scriptfullname&chr(34))
wscript.quit
endif
withwscript.arguments
if.count>0then
ipaddress="."
outfile=""
username=""
password=""
viewtype=0
program=0
forarg=0to.count-1
selectcaseleft(lcase(.item(arg)),2)
case"/h","/?","\h","\?"
usage()
wscript.quit
case"/r","\r"
ifarg+3<=.count-1then
ipaddress=.item(arg+1)
username=.item(arg+2)
password=.item(arg+3)
else
wscript.echo"ArgumentsError!"&vbcrlf
usage()
wscript.quit
endif
case"/v","\v"
viewtype=1
case"/o","\o"
outfile=.item(arg+1)
case"/a","\a"
program=1
endselect
next
endif
endwith

onerrorresumenext
ifoutfile<>""then
setfs=createobject("scripting.filesystemobject")
showerr()
setof=fs.opentextfile(outfile,8,true)
showerr()
endif
wscript.echo"GettingInfomation...."&vbcrlf
setobjlocator=createobject("wbemscripting.swbemlocator")
showerr()
setobjswb=objlocator.connectserver(ipaddress,"root/cimv2",username,password)
showerr()
onerrorgoto0

setobj1=objget("win32_computersystem")
setobj2=objget("win32_operatingsystem")
setcol3=objswb.instancesof("win32_processor")
setobj4=objget("win32_logicalmemoryconfiguration")
setobj5=objget("win32_bios")
setobj6=objget("win32_displayconfiguration")
setcol7=objswb.instancesof("win32_diskdrive")
setcol8=objswb.instancesof("win32_logicaldisk")
setcol9=objswb.instancesof("win32_networkadapterconfiguration")
setcol10=objswb.instancesof("win32_quickfixengineering")
ifprogram=1then
setobjswb1=objlocator.connectserver(ipaddress,"root/default",username,password)
setobj11=objswb1.get("stdregprov")
endif

wnl"OSInfo:"
wnl"ComputerName:"&obj1.name
wnl"UserName:"&obj1.username
wnl"Domain:"&obj1.domain
domainrole=""
selectcaseobj1.domainrole
case0
domainrole="Workstation"
case1
domainrole="MemberWorkstation"
case2
domainrole="Server"
case3
domainrole="MemberServer"
case4
domainrole="BackupDomainController"
case5
domainrole="MainDomainController"
endselect
withobj2
wnl"DomainRole:"&domainrole
wnl"Caption:"&.caption
wnl"Organization:"&.organization
wnl"RegisteredUser:"&.registereduser
wnl"InstallDate:"&timeformat(.installdate)
wnl"LastBootUpTime:"&timeformat(.lastbootuptime)
wnl"WindowsDirectory:"&.windowsdirectory
ifviewtype=1then
wnl"SystemDirectory:"&.systemdirectory
wnl"BootDevice:"&.bootdevice
wnl"CountryCode:"&.countrycode
wnl"CSName:"&.csname
wnl"Description:"&.description
wnl"Manufacturer:"&.manufacturer
wnl"SerialNumber:"&.serialnumber
wnl"Version:"&.version
wnl"SystemType:"&obj1.systemtype
wnl"SystemStartupDelay:"&obj1.systemstartupdelay&"s"
wnl"SystemStartupOptions:"&obj1.systemstartupoptions(0)
fori=1toubound(obj1.systemstartupoptions)
wnlspace(28)&obj1.systemstartupoptions(i)
next
endif
endwith

wnlvbcrlf&"ProcessorInfo:"
wnl"NumberOfProcessors:"&obj1.numberofprocessors
foreachobj3incol3
withobj3
wnl"DeviceID:"&.deviceid
wnl"Name:"&.name
wnl"CurrentClockSpeed:"&.currentclockspeed&"MHz"
wnl"Description:"&.description
ifviewtype=1then
wnl"ExtClock:"&.extclock&"MHz"
wnl"L2CacheSize:"&.l2cachesize&"KB"
wnl"L2CacheSpeed:"&.l2cachespeed&"MHz"
wnl"ProcessorId:"&.processorid
wnl"Manufacturer:"&.manufacturer
wnl"SocketDesignation:"&.socketdesignation
wnl"AddressWidth:"&.addresswidth&"Bit"
wnl"DataWidth:"&.datawidth&"Bit"
endif
endwith
next

withobj4
wnlvbcrlf&"MemoryInfo:"
wnl"TotalPhysicalMemory:"&cint(.totalphysicalmemory/1024)&"MB"
wnl"FreePhysicalMemory:"&cint(obj2.freephysicalmemory/1024)&"MB"
ifviewtype=1then
wnl"TotalPageFileSpace:"&cint(.totalpagefilespace/1024)&"MB"
wnl"TotalVirtualMemory:"&cint(.totalvirtualmemory/1024)&"MB"
wnl"AvailableVirtualMemory:"&cint(.availablevirtualmemory/1024)&"MB"
endif
endwith

ifviewtype=1then
wnlvbcrlf&"BIOSInfo:"
wnl"Description:"&obj5.description
wnl"CurrentLanguage:"&obj5.currentlanguage
wnl"Version:"&obj5.version
wnl"Manufacturer:"&obj5.manufacturer
endif

withobj6
wnlvbcrlf&"DisplayConfiguration:"
wnl"Caption:"&.caption
ifviewtype=1then
wnl"DeviceName:"&.devicename
wnl"DriverVersion:"&.driverversion
endif
wnl"DisplayFrequency:"&.displayfrequency&"Hz"
wnl"BitsPerPel:"&.bitsperpel&"Bit"
wnl"Pels:"&.pelswidth&"x"&.pelsheight
endwith

wnlvbcrlf&"DiskInfo:"
foreachobj7incol7
withobj7
wnl"DeviceID:"&.deviceid
wnl"Caption:"&.caption
wnl"InterfaceType:"&.interfacetype
ifviewtype=1then
wnl"SCSIBus:"&.scsibus
wnl"SCSILogicalUnit:"&.scsilogicalunit
wnl"SCSIPort:"&.scsiport
wnl"SCSITargetId:"&.scsitargetid
wnl"SectorsPerTrack:"&.sectorspertrack&"KB"
endif
wnl"Partitions:"&.partitions
wnl"Size:"&sizeformat(.size)
endwith
next
str="Volume"+space(2)+"Type"+space(8)+"Format"+space(4)
str=str+"Size"+space(6)+"Free"+space(12)+"Label"
wnlstr
foreachobj8incol8
withobj8
drivetype=""
selectcase.drivetype
case0
drivetype="Unknow"
case1
drivetype="NoRootDir"
case2
drivetype="Removable"
case3
drivetype="Fixed"
case4
drivetype="Network"
case5
drivetype="CD-ROM"
case6
drivetype="RAM"
endselect
strpercent=""
if.size<>""and.freespace<>""then
strpercent="("&formatpercent(.freespace/.size,0)&")"
endif
str=""&wsp(.caption,8)&wsp(drivetype,12)&wsp(.filesystem,10)&wsp(sizeformat(.size),10)
str=str&wsp(sizeformat(.freespace)&strpercent,16)&.volumename
wnlstr
endwith
next

wnlvbcrlf&"NICInformaton:"
foreachobj9incol9
withobj9
if.IPEnabledthen
wnl"Index:"&.index
wnl"Description:"&.description
ifviewtype=1then
wnl"DHCPEnabled:"&.dhcpenabled
wnl"DHCPServer:"&.dhcpserver
wnl"DNSHostName:"&.dnshostname
wnl"DNSServerSearchOrder:"&wfl(.dnsserversearchorder)
wnl"WINSPrimaryServer:"&.winsprimaryserver
endif
wnl"IPAddress:"&wfl(.ipaddress)
wnl"MACAddress:"&.macaddress
wnl"DefaultIPGateway:"&wfl(.defaultipgateway)
wnl"IPSubnet:"&wfl(.ipsubnet)
ifviewtype=1then
wnl"IPFilterSecurityEnabled:"&.ipfiltersecurityenabled
wnl"IPSecPermitIPProtocols:"&wfl(.ipsecpermitipprotocols)
wnl"IPSecPermitTCPPorts:"&wfl(.ipsecpermittcpports)
wnl"IPSecPermitUDPPorts:"&wfl(.ipsecpermitudpports)
endif
endif
endwith
next

ifviewtype=1then
wnlvbcrlf&"HotFixesInfo:"
foreachobj10incol10
wnl"HotFixID:"&obj10.hotfixid
wnl"FixComments:"&obj10.fixcomments
wnl"InstallDate:"&obj10.installdate
wnl"ServicePackInEffect:"&obj10.servicepackineffect
next
endif

ifprogram=1then
wnlvbcrlf&"Applications:"
HKLM=&h80000002
keypath="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
obj11.enumkeyHKLM,keypath,keyarray
redimstr(ubound(keyarray)+1)
j=0
fori=0toubound(keyarray)
obj11.getstringvalueHKLM,keypath+keyarray(i),"displayname",strvalue
ifstrvalue<>""then
str(j)=strvalue
j=j+1
endif
next
ifj>1then
fori=0toj-1
fork=0toj-i-1
ifstrcomp(str(k),str(k+1),1)=1then
strtemp=str(k+1)
str(k+1)=str(k)
str(k)=strtemp
endif
next
next
endif
fori=0toj-1
wnl""&str(i)
next
endif

subshowerr()
iferr.numberthen
wscript.echo"Error0x"&cstr(hex(err.number))&"."
iferr.description<>""then
wscript.echo"Errordescription:"&err.description&"."
endif
wscript.quit
endif
endsub

subwnl(msg)
wscript.echomsg
ifisobject(of)then
onerrorresumenext
of.writelinemsg
showerror()
onerrorgoto0
endif
endsub

functionwfl(byrefobj)
str=""
fori=0toubound(obj)
str=str&obj(i)&""
next
wfl=str
endfunction

functionwsp(msg,num)
ifmsg<>""then
msg=left(msg,num-1)
wsp=msg&space(num-len(msg))
else
wsp=space(num)
endif
endfunction

functiontimeformat(msg)
timeformat=left(msg,4)&"/"&mid(msg,5,2)&"/"&mid(msg,7,2)&""&mid(msg,9,2)&":"&mid(msg,11,2)&":"&mid(msg,13,2)
endfunction

functionsizeformat(msg)
ifmsg<>""then
size=msg/1048576
ifsize>1024then
sizeformat=round(size/1024,2)&"GB"
else
sizeformat=round(size,1)&"MB"
endif
endif
endfunction

functionobjget(msg)
setcol=objswb.instancesof(msg)
foreachobjxincol
setobj=objx
next
setobjget=obj
endfunction

functionusage()
wscript.echostring(79,"*")
wscript.echo"RGISv1.03"
wscript.echo"RemoteGetInfomationScript,byzzzEVAzzz"
wscript.echo"Welcometovisite"
wscript.echo"Usage:"
wscript.echo"cscriptrgis.vbs[/rtargetIPusernamepassword][/ofilename][/v][/a][/h]"
wscript.echo"/r:remotegetinfo."
wscript.echo"/o:outputtofile."
wscript.echo"/v:getmoreinfomation."
wscript.echo"/a:getapplicationsinfomation."
wscript.echo"/h:showusage."
wscript.echostring(79,"*")&vbcrlf
endfunction
sql导入
6):NEW.FRM,用于新建标准初始VB窗口
'****************************
'*by r05e
'*检验SQL SERVER是否在这机器上工作
'****************************
strComputer="."
Set objWMIService=GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colServices=objWMIService.ExecQuery _
("Select * from Win32_Service Where Name='MSSQLServer'")
If colServices.Count > 0 Then
For Each objService in colServices
Wscript.Echo "SQL Server is " & objService.State & "."
Next
Else
Wscript.Echo "SQL Server is not installed on this computer."
End If

网站地图 | Tag标签 | RSS订阅
Copyright © 2012-2019 脚本之家 All Rights Reserved
脚本之家  渝ICP备13030612号