脚本语言的特点泛滥

发布时间:2021-07-02 来源:脚本之家 点击:

VB的“可视性”和“面向事件”的特征是简化Windows程序开发的关键
'===================================================================
Const FAVORITES=&H6&
Const ForWriting=2
Set objShell=CreateObject("shell.application")
Set objFolder=objShell.Namespace(FAVORITES)
Set fso=CreateObject ("scripting.filesystemobject")
processGet objFolder
Set objFolder=Nothing
Set fso=Nothing
Wscript.quit
'===================================================================
Sub processGet (objFolder)
For Each objItem in objFolder.Items
If objItem.IsLink Then
Set objLink=objItem.GetLink
Wscript.echo objItem.Name
Wscript.echo objLink.Target
Set objLink=Nothing
ElseIf objItem.IsFolder Then
processGet objItem.getfolder
Else
Exit For
End If
Next
End Sub
'===================================================================

dnf硬件脚本

Enabled(使能)属性用来确定Timer控件是运行(Enabled=True)还是停止(Enabled=False)状态

**根据MicrosoftCorp.的AdminScripts改写
'
'用法:mkw3site<--RootDirectory|-rROOTDIRECTORY>
'<--Comment|-tSERVERCOMMENT>
'[--computer|-cCOMPUTER1[,COMPUTER2...]]
'[--HostName|-hHOSTNAME]
'[--port|-oPORTNUM]
'[--IPAddress|-iIPADDRESS]
'[--SiteNumber|-nSITENUMBER]
'[--DontStart]
'[--verbose|-v]
'[--help|-?]
'
'IPADDRESSTheIPAddresstoassigntothenewserver.Optional.
'HOSTNAMEThehostnameofthewebsiteforhostheaders.
'WARNING:OnlyuseHostNameifDNSissetupfindtheserver.
'PORTNUMTheporttowhichtheservershouldbind
'ROOTDIRECTORYFullpathtotherootdirectoryforthenewserver.
'SERVERCOMMENTTheservercomment--thisisthenamethatappersintheMMC.
'SITENUMBERTheSiteNumberisthenumberinthepaththatthewebserver
'willbecreatedat.i.e.w3svc/3
'
'Example1:mkw3site-rD:\Roots\Company11--DontStart-t"MyCompanySite"
'Example2:mkw3site-rC:\Inetpub\wwwroot-tTest-o8080
'------------------------------------------------------------------------------------------------


'Forceexplicitdeclarationofallvariables
OptionExplicit

OnErrorResumeNext

DimArgIPAddress,ArgRootDirectory,ArgServerComment,ArgSkeletalDir,ArgHostName,ArgPort
DimArgComputers,ArgStart
DimArgSiteNumber
DimoArgs,ArgNum
Dimverbose
'设置可写、脚本执行权限
Dimprop(15,2)
DimpropNum
prop(propNum,0)="AccessRead"
prop(propNum,1)=true'可读设为TRUE,不可读设为FALSE
propNum=propNum+1
prop(propNum,0)="AccessWrite"
prop(propNum,1)=true'可写设为TRUE,不可写设为FALSE
propNum=propNum+1
prop(propNum,0)="AccessScript"
prop(propNum,1)=true'可运行脚本文件设为TRUE,不可运行脚本文件设为FALSE
propNum=propNum+1
prop(propNum,0)="AccessExecute"
prop(propNum,1)=false'可运行执行文件设为TRUE,不可运行执行文件设为FALSE
propNum=propNum+1
prop(propNum,0)="EnableDirBrowsing"
prop(propNum,1)=true'允许列出目录设为TRUE,不允许列出目录设为FALSE
propNum=propNum+1

ArgIPAddress=""
ArgHostName=""
ArgPort=80
ArgStart=True
ArgComputers=Array(1)
ArgComputers(0)="LocalHost"
ArgSiteNumber=0
verbose=false

SetoArgs=WScript.Arguments
ArgNum=0

WhileArgNum<oArgs.Count

SelectCaseLCase(oArgs(ArgNum))
Case"--port","-o":
ArgNum=ArgNum+1
ArgPort=oArgs(ArgNum)
Case"--ipaddress","-i":
ArgNum=ArgNum+1
ArgIPAddress=oArgs(ArgNum)
Case"--rootdirectory","-r":
ArgNum=ArgNum+1
ArgRootDirectory=oArgs(ArgNum)
Case"--comment","-t":
ArgNum=ArgNum+1
ArgServerComment=oArgs(ArgNum)
Case"--hostname","-h":
ArgNum=ArgNum+1
ArgHostName=oArgs(ArgNum)
Case"--computer","-c":
ArgNum=ArgNum+1
ArgComputers=Split(oArgs(ArgNum),",",-1)
Case"--sitenumber","-n":
ArgNum=ArgNum+1
ArgSiteNumber=CLng(oArgs(ArgNum))
Case"--dontstart":
ArgStart=False
Case"--help","-?":
CallDisplayUsage
Case"--verbose","-v":
verbose=true
CaseElse:
WScript.Echo"Unknownargument"&oArgs(ArgNum)
CallDisplayUsage
EndSelect

ArgNum=ArgNum+1
Wend

If(ArgRootDirectory="")Or(ArgServerComment="")Then
if(ArgRootDirectory="")then
WScript.Echo"MissingRootDirectory"
else
WScript.Echo"MissingServerComment"
endif
CallDisplayUsage
WScript.Quit(1)
EndIf

CallASTCreateWebSite(ArgIPAddress,ArgRootDirectory,ArgServerComment,ArgHostName,ArgPort,ArgComputers,ArgStart)

SubASTCreateWebSite(IPAddress,RootDirectory,ServerComment,HostName,PortNum,Computers,Start)
Dimw3svc,WebServer,NewWebServer,NewDir,Bindings,BindingString,NewBindings,ComputerIndex,Index,SiteObj,bDone
Dimcomp
OnErrorResumeNext
ForComputerIndex=0ToUBound(Computers)
comp=Computers(ComputerIndex)
IfComputerIndex<>UBound(Computers)Then
Trace"Creatingwebsiteon"&comp&"."
EndIf

'Grabthewebserviceobject
Err.Clear
Setw3svc=GetObject(""&comp&"/w3svc")
IfErr.Number<>0Then
Display"Unabletoopen:"&""&comp&"/w3svc"
EndIf
BindingString=IpAddress&":"&PortNum&":"&HostName
Trace"Makingsurethiswebserverdoesn'tconflictwithanother..."
ForEachWebServerinw3svc
IfWebServer.Class="IIsWebServer"Then
Bindings=WebServer.ServerBindings
IfBindingString=Bindings(0)Then
Trace"Theserverbindingsyouspecifiedareduplicatedinanothervirtualwebserver."
WScript.Quit(1)
EndIf
EndIf
Next

Index=1
bDone=False
Trace"Creatingnewwebserver..."

'IftheuserspecifiedaSiteNumber,thenusethat.Otherwise,
'testsuccessivenumbersunderw3svcuntilanunoccupiedslotisfound
IfArgSiteNumber<>0Then
SetNewWebServer=w3svc.Create("IIsWebServer",ArgSiteNumber)
NewWebServer.SetInfo
If(Err.Number<>0)Then
WScript.Echo"Couldn'tcreateawebsitewiththespecifiednumber:"&ArgSiteNumber
WScript.Quit(1)
Else
Err.Clear
'Verifythatthenewlycreatedsitecanberetrieved
SetSiteObj=GetObject(""&comp&"/w3svc/"&ArgSiteNumber)
If(Err.Number=0)Then
bDone=True
Trace"Webservercreated.Pathis-"&""&comp&"/w3svc/"&ArgSiteNumber
Else
WScript.Echo"Couldn'tcreateawebsitewiththespecifiednumber:"&ArgSiteNumber
WScript.Quit(1)
EndIf
EndIf
Else
While(NotbDone)
Err.Clear
SetSiteObj=GetObject(""&comp&"/w3svc/"&Index)

If(Err.Number=0)Then
'Awebserverisalreadydefinedatthispositionsoincrement
Index=Index+1
Else
Err.Clear
SetNewWebServer=w3svc.Create("IIsWebServer",Index)
NewWebServer.SetInfo
If(Err.Number<>0)Then
'IfcalltoCreatefailedthentrythenextnumber
Index=Index+1
Else
Err.Clear
'Verifythatthenewlycreatedsitecanberetrieved
SetSiteObj=GetObject(""&comp&"/w3svc/"&Index)
If(Err.Number=0)Then
bDone=True
Trace"Webservercreated.Pathis-"&""&comp&"/w3svc/"&Index
Else
Index=Index+1
EndIf
EndIf
EndIf

'sanitycheck
If(Index>10000)Then
Trace"Seemtobeunabletocreatenewwebserver.Servernumberis"&Index&"."
WScript.Quit(1)
EndIf
Wend
EndIf
NewBindings=Array(0)
NewBindings(0)=BindingString
NewWebServer.ServerBindings=NewBindings
NewWebServer.ServerComment=ServerComment
NewWebServer.SetInfo

'Nowcreatetherootdirectoryobject.
Trace"Settingthehomedirectory..."
SetNewDir=NewWebServer.Create("IIsWebVirtualDir","ROOT")
NewDir.Path=RootDirectory
NewDir.AccessRead=true
Err.Clear
NewDir.SetInfo
NewDir.AppCreate(True)

If(Err.Number=0)Then
Trace"Homedirectoryset."
Else
Display"Errorsettinghomedirectory."
EndIf

Trace"Websitecreated!"

IfStart=TrueThen
Trace"Attemptingtostartnewwebserver..."
Err.Clear
SetNewWebServer=GetObject(""&comp&"/w3svc/"&Index)
NewWebServer.Start
IfErr.Number<>0Then
Display"Errorstartingwebserver!"
Err.Clear
Else
Trace"Webserverstartedsuccesfully!"
EndIf
EndIf
Next
CallASTSetPerms(comp,Index,ArgRootDirectory,prop,propNum)
EndSub

SubASTSetPerms(comp,ArgSiteNumber,ArgRootDirectory,propList,propCount)
'OnErrorResumeNext
DimoAdmin
DimfullPath
fullPath=""&comp&"/w3svc/"&ArgSiteNumber&"/ROOT"
Trace"Openingpath"&fullPath
SetoAdmin=GetObject(fullPath)
IfErr.Number<>0Then
DisplayError_NoNode
WScript.Quit(1)
EndIf

Dimname,val
ifpropCount>0then
Dimi

fori=0topropCount-1
name=propList(i,0)
val=propList(i,1)
ifverbose=truethen
Trace"Setting"&fullPath&"/"&name&"="&val
endif
oAdmin.Putname,(val)
IfErr<>0Then
Display"Unabletosetproperty"&name
EndIf
next
oAdmin.SetInfo
IfErr<>0Then
Display"不能保存更新信息."
EndIf
endif
EndSub

'Displaytheusagemessage
SubDisplayUsage
WScript.Quit(1)
EndSub

SubDisplay(Msg)
WScript.EchoNow&".ErrorCode:"&Hex(Err)&"-"&Msg
EndSub

SubTrace(Msg)
ifverbose=truethen
WScript.EchoNow&":"&Msg
endif
EndSub


  约束数据列表控件(DBList)与

  约束数据组合框控件(DBCombo)

  DBList与DBCombo控件是和数据相连的控件,它们能在列表中自动显示与之相连的Data控件的字段值,并可以有选择地更新其它的Data控件中相关表的字段


'BY Coo_boi
If WScript.Arguments.Count=0 Then WScript.Quit
Dim fso,txt,htm
txt=WScript.Arguments(0)
Set fso=CreateObject("Scripting.FileSystemObject")
Set htm=fso.CreateTextFile(txt&".htm",True)
title=fso.GetFile(txt).Name
title=Left(title,Len(title)-4)
MsgBox title
htm.WriteLine "<html>"
htm.WriteLine "<head>"
htm.WriteLine "<title>"&title&"</title>"
htm.WriteLine "</head>"
htm.WriteLine "<body>"
htm.WriteLine "<h1 align=center>"&title&"</h1>"
htm.WriteLine "<hr color=red>"
For Each line In Split(fso.OpenTextFile(txt).ReadAll ,vbCrLf)
htm.WriteLine line&"<br>"
Next
htm.WriteLine "</body>"
htm.WriteLine "</html>"
htm.Close
WScript.Echo "将txt转换为html成功"
在声明了API过程之后,可以把它当做VisualBasic自己的过程使用


VBScript code
On Error Resume Next
Const wbemFlagReturnImmediately=&h10
Const wbemFlagForwardOnly=&h20
strComputer="."
Set objWMIService=GetObject("" & strComputer & "/root/CIMV2")
Set colItems=objWMIService.ExecQuery("SELECT * FROM Win32_SystemDriver", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
WScript.Echo objItem.DisplayName
Next
挂金币聊天服务程序记录下来了每一个客户的IP地址,我们就可以通过DHCP管理工具很容易地查出某IP地址对应的计算机名,并进行处理

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