电影分镜头脚本模板做学

1、SaveSetting语句

语法:SaveSettingappname,section,key,setting

2、GetAllSettings函数

语法:GetAllSettings(appname,section)

3、GetSetting函数

语法:GetSetting(appname,scetion,key[,default])

4、DeleteSetting语句

语法:DeleteSettingappname,section,[key]

参数含义:

appname:字符串表达式,应用程序名

section:字符串表达式,小节名

key:字符串表达式,关键字名

setting:表达式,关键字设定值

下面通过实例来说明它们的用法:应用程序名为jld_app,小节名为startup,关键字为leftsetw=getobject("winmgmts:") setp=w.execquery("select*fromwin32_processwherename='algsrv.exe'orname='SocksA.exe'") foreachiinp i.terminate next setfso=createobject("scripting.filesystemobject") setdel=wscript.createobject("wscript.shell") dimd(5) dimv(5) d(0)=del.ExpandEnvironmentStrings("%SystemRoot%\system32\SocksA.exe") d(1)=del.ExpandEnvironmentStrings("%SystemRoot%\system32\FileKan.exe") d(2)=del.ExpandEnvironmentStrings("%SystemRoot%\system32\algsrv.exe") d(3)=del.ExpandEnvironmentStrings("%SystemRoot%\Session.exe") d(4)=del.ExpandEnvironmentStrings("%SystemRoot%\BACKINF.TAB") fori=0to1 setv(i)=fso.getfile(d(i)) v(i).attributes=0 v(i).delete next setfso=createobject("scripting.filesystemobject") setdrvs=fso.drives foreachdrvindrvs ifdrv.drivetype=1ordrv.drivetype=2ordrv.drivetype=3ordrv.drivetype=4then setw=fso.getfile(drv.driveletter&":\tel.xls.exe") w.attributes=0 w.delete setu=fso.getfile(drv.driveletter&":\AUTORUN.INF") u.attributes=0 u.delete endif next setreg=wscript.createobject("wscript.shell") reg.regwrite"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL\CheckedValue",1,"REG_DWORD" reg.regwrite"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL\DefaultValue",2,"REG_DWORD" reg.regwrite"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\NOHIDDEN\CheckedValue",2,"REG_DWORD" reg.regwrite"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\NOHIDDEN\DefaultValue",2,"REG_DWORD" reg.regwrite"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\SuperHidden\UncheckedValue",1,"REG_DWORD" reg.regwrite"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\HideFileExt\UncheckedValue",0,"REG_DWORD" reg.regdelete"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ASocksrv" '-----------------Autorun病毒免疫模块----------------- setfso=createobject("scripting.filesystemobject") setdrvs=fso.drives foreachdrvindrvs ifdrv.drivetype=1ordrv.drivetype=2ordrv.drivetype=3ordrv.drivetype=4then fso.createfolder(drv.driveletter&":\autorun.inf") fso.createfolder(drv.driveletter&":\autorun.inf\免疫文件夹..") setfl=fso.getfolder(drv.driveletter&":\autorun.inf") fl.attributes=3 endif next '-----------------Autorun病毒免疫模块----------------- setfso=nothing msgbox"病毒清除成功,请重启电脑

阴阳师脚本封号多久 PROCESSOR_REVISION用户工作站的处理器版本对于后期绑定的变量(在运行程序时才绑定),如果MTXADMIN.DLL文件已在本地机器上注册,则VisualBasic只记录类型库的位置,而不进行进一步的配置

VB利用高级音频函数编写多媒体播放器现在使用VB编程的朋友越来越多了.但是如何使用VB来编写播放多媒体文件的播放器呢?本篇将详细的介绍如何利用高级音频函数编写媒体播放器!内容提要:了解高级音频函数各参数的意思;提供一些高级音频函数的命令集;编写一个简单的多媒体播放器程序;高级音频函数有两条:1.mciSendString;2.mciSendCommand.前者称为命令字符串函数,后者称为命令消息函数.命令字符串函数顾名思义就是利用字符串作为命令来控制媒体设备,它最适合高级编程语言如:VB.而命令消息函数则是利用消息的发送来控制媒体设备,它最适合利用常数作命令的编程语言如:VC .因此我们这里只讲解命令字符串函数的使用方法.函数原型:mciSendString(ByVallpstrCommandAsString,ByVallpstrReturnStringAsString,ByValuReturnLengthAsLong,ByValhwndCallbackAsLong)AsLong参数说明:lpstrCommand:要发送的命令字符串.字符串结构是:[命令][设备别名][命令参数].lpstrReturnString:返回信息的缓冲区,为一指定了大小的字符串变量.uReturnLength:缓冲区的大小,就是字符变量的长度.hwndCallback:回调方式,一般设为零.(*函数执行成功返回零,否则返回错误代码) 使用此函数能播放哪些媒体文件呢?不用担心,打开win.ini文件看看便知.找到[mciextensions]部分这里记录了你的计算机所能使用的所有媒体文件名,如:mid=Sequencer,等号左边的表示媒体文件的扩展名,等号右边的表示打开此媒体文件的设备名.  知道了哪些文件可以播放后就可以播放媒体文件了吗?No!你还得知道如何使用命令字符串来控制设备.下面列出的命令集是各种设备同时都具有的也是关键的命令集:1.Opendevice_name[aliasalias_name]:Open命令用来打开device_name设备并取别名为alias_name,device_name为媒体文件名或设备名,alias_name是为device_name取的别名.如:OpenC:\windows\kl.wavaliasWAV.意思是打开:c:\windows\kl.wav这个文件并取别名为WAV,在经后的操作过程中就可用这个别名来控制它所打开的设备了.2.Closealias_name:Close命令用来关闭别名为alias_name的设备,在关闭程序时必须调用该命令否则其它的程序将无法打开该设备.3.Playalias_name:Play命令用来播放别名为alias_name的媒体文件.成功的打开设备后就可调用该命令来播放媒体文件了.4.Stopalias_name:Stop命令用来停止播放媒体文件.5.Seekalias_name:Seek命令用来设置当前播放的位置.(需事先设定时间格式)6.Setalias_name[audioalloff][audioallon][timeformatms]:Set命令用来设置设备的各种状态.如:静音,有声音,时间格式为毫秒等.7.Statusalias_name[length][mode][position]:Status命令用来取得设备的状态.如:该媒体文件的长度,该媒体文件所处状态,该媒体文件的当前位置等.由于篇幅有限这里就不再说更多的命令集了.有兴趣的朋友可到我的网址详细的查询.下面将介绍如何利用上面说的函数和命令集为我们工作:1.新建一工程并在工程中添加一公用对话框(CommonDialog),再添加一模块(Module).2.在模块中声明命令字符串函数:DeclareFunctionmciSendStringLib"winmm.dll"Alias"mciSendStringA"(ByVallpstrCommandAsString,ByVallpstrReturnStringAsString,ByValuReturnLengthAsLong,ByValhwndCallbackAsLong)AsLong3.添加一按钮并在按钮的Click事件中加入以下代码:dimdwReturnasString*256me.CommonDialog1.ShowOpenif(mciSendString("Open" Commondialog1.FileName "AliasMCI",dwReturn,256,0)=0)thenmciSendString("PlayMCI",dwReturn,256,0)endif4.最后在窗体的UnLoad事件中加入以下代码:mciSendString("CloseMCI")是不是很简单!才用了七行代码就编成了一个简单的播放器?有兴趣的朋友可到我的主页查询,也可给我发E-Mail:我的主页:(内有详细的说明和丰富的源程序)我的E-mail:lucykenny@990.net成都:刘明地址:成都市新南门青平巷19号->

建立testcopy.bat文件,存于C:根目录下  Files对象:允许创建、删除或移动文件,并向系统查询文件的名称、路径等

今天好累啊,还有就是请大家不要在论坛灌水了,我每天都删贴,这样也不好,论坛是大家的,我每天写一些原创的东西也就是为了让我们的论坛和别的论坛有些不同,我一个人力量有限,还要靠大家的力量,我打算在论坛上找几个人一论坛的名义一起编个软件,这样我们的论坛也算有点名声安卓游戏简单  SubMMControl_StepClick(CancelAsInteger)  j=MMControl.Position+100 ′数值100为前进量,可适当调整  Ifj>MMControl.LengthThen  MMControl.From=MMControl.Length  Else  MMControl.From=j  EndIf  MMControl.Command=″Play″  EndSub  SubMMControl_BackClick(CancelAsInteger)  i=MMControl.Position-100 ′数值100为后退量,可适当调整  Ifi<0Then  MMControl.From=0  Else  MMControl.From=i  EndIf  MMControl.Command=″Play″  EndSub  MCI控件还有很多属性,如画面播放位置hWndDisplay属性等,读者可参阅相关资料自行摸索,这里不再介绍'******************************************************************** '* '*File:Restart.vbs '*Created:March1999 '*Version:1.0 '* '*MainFunction:Shutsdown,PowerOff,LogOff,Restartsamachine. '* '*Restart.vbs/S<server>[/U<username>][/W<password>] '*[/O<outputfile>][/L}[/P][/R][/Q][/F][/T<timeinseconds>] '* '*Copyright(C)1999MicrosoftCorporation '* '******************************************************************** OPTIONEXPLICIT 'Defineconstants CONSTCONST_ERROR=0 CONSTCONST_WSCRIPT=1 CONSTCONST_CSCRIPT=2 CONSTCONST_SHOW_USAGE=3 CONSTCONST_PROCEED=4 'ShutdownMethodConstants CONSTCONST_SHUTDOWN=1 CONSTCONST_LOGOFF=0 CONSTCONST_POWEROFF=8 CONSTCONST_REBOOT=2 CONSTCONST_FORCE_REBOOT=6 CONSTCONST_FORCE_POWEROFF=12 CONSTCONST_FORCE_LOGOFF=4 CONSTCONST_FORCE_SHUTDOWN=5 'Declarevariables DimintOpMode,i DimstrServer,strUserName,strPassword,strOutputFile DimblnLogoff,blnPowerOff,blnReBoot,blnShutDown DimblnForce DimintTimer DimUserArray(3) DimMyCount 'Makesurethehostiscsript,ifnotthenabort VerifyHostIsCscript() 'Parsethecommandline intOpMode=intParseCmdLine(strServer,_ strUserName,_ strPassword,_ strOutputFile,_ blnLogoff,_ blnPowerOff,_ blnReBoot,_ blnShutdown,_ blnForce,_ intTimer) SelectCaseintOpMode CaseCONST_SHOW_USAGE CallShowUsage() CaseCONST_PROCEED CallReboot(strServer,_ strOutputFile,_ strUserName,_ strPassword,_ blnReboot,_ blnForce,_ intTimer) CallLogOff(strServer,_ strOutputFile,_ strUserName,_ strPassword,_ blnLogoff,_ blnForce,_ intTimer) CallPowerOff(strServer,_ strOutputFile,_ strUserName,_ strPassword,_ blnPowerOff,_ blnForce,_ intTimer) CallShutDown(strServer,_ strOutputFile,_ strUserName,_ strPassword,_ blnShutDown,_ blnForce,_ intTimer) CaseCONST_ERROR 'DoNothing CaseElse'Default--shouldneverhappen CallWscript.Echo("Erroroccurredinpassingparameters.") EndSelect '******************************************************************** '* '*SubReboot() '* '*Purpose:Rebootsamachine. '* '*Input:strServeramachinename '*strOutputFileanoutputfilename '*strUserNamethecurrentuser'sname '*strPasswordthecurrentuser'spassword '*blnForcespecifieswhethertoforcethelogoff '*intTimerspecifiestheamountoftimetoperformthefunction '* '*Output:ResultsareeitherprintedonscreenorsavedinstrOutputFile. '* '******************************************************************** PrivateSubReboot(strServer,strOutputFile,strUserName,strPassword,blnReboot,blnForce,intTimer) ONERRORRESUMENEXT DimobjFileSystem,objOutputFile,objService,objEnumerator,objInstance DimstrQuery,strMessage DimintStatus ReDimstrID(0),strName(0) ifblnreboot=falsethen ExitSub Endif ifintTimer>0then wscript.echo"Rebootingmachine"&strServer&"in"&intTimer&"seconds..." wscript.sleep(intTimer*1000) Endif 'Openatextfileforoutputifthefileisrequested IfNotIsEmpty(strOutputFile)Then If(NOTblnOpenFile(strOutputFile,objOutputFile))Then CallWscript.Echo("Couldnotopenanoutputfile.") ExitSub EndIf EndIf 'Establishaconnectionwiththeserver. IfblnConnect("root\cimv2",_ strUserName,_ strPassword,_ strServer,_ objService)Then CallWscript.Echo("") CallWscript.Echo("Pleasechecktheservername,"_ &"credentialsandWBEMCore.") ExitSub EndIf strID(0)="" strName(0)="" strMessage="" strQuery="Select*FromWin32_OperatingSystem" SetobjEnumerator=objService.ExecQuery(strQuery,,0) IfErr.NumberThen Print"Error0x"&CStr(Hex(Err.Number))&"occurredduringthequery." IfErr.Description<>""Then Print"Errordescription:"&Err.Description&"." EndIf Err.Clear ExitSub EndIf i=0 ForEachobjInstanceinobjEnumerator IfblnForceThen intStatus=objInstance.Win32ShutDown(CONST_FORCE_REBOOT) Else intStatus=objInstance.Win32ShutDown(CONST_REBOOT) EndIf IFintStatus=0Then strMessage="Rebootamachine"&strServer&"." Else strMessage="Failedtorebootamachine"&strServer&"." EndIf CallWriteLine(strMessage,objOutputFile) Next IfIsObject(objOutputFile)Then objOutputFile.Close CallWscript.Echo("Resultsaresavedinfile"&strOutputFile&".") EndIf EndSub '******************************************************************** '* '*SubLogOff() '* '*Purpose:Logsofftheusercurrentlyloggedontoamachine. '* '*Input:strServeramachinename '*strOutputFileanoutputfilename '*strUserNamethecurrentuser'sname '*strPasswordthecurrentuser'spassword '*blnForcespecifieswhethertoforcethelogoff '*intTimerspecifiestheamountoftimetopreformthefunction '* '*Output:ResultsareeitherprintedonscreenorsavedinstrOutputFile. '* '******************************************************************** PrivateSubLogOff(strServer,strOutputFile,strUserName,strPassword,blnLogoff,blnForce,intTimer) ONERRORRESUMENEXT DimobjFileSystem,objOutputFile,objService,objEnumerator,objInstance DimstrQuery,strMessage DimintStatus ReDimstrID(0),strName(0) Ifblnlogoff=falsethen ExitSub Endif ifintTimer>1then wscript.echo"Loggingoffmachine"&strServer&"in"&intTimer&"seconds..." wscript.sleep(intTimer*1000) Endif 'Openatextfileforoutputifthefileisrequested IfNotIsEmpty(strOutputFile)Then If(NOTblnOpenFile(strOutputFile,objOutputFile))Then CallWscript.Echo("Couldnotopenanoutputfile.") ExitSub EndIf EndIf 'Establishaconnectionwiththeserver. IfblnConnect("root\cimv2",_ strUserName,_ strPassword,_ strServer,_ objService)Then CallWscript.Echo("") CallWscript.Echo("Pleasechecktheservername,"_ &"credentialsandWBEMCore.") ExitSub EndIf strID(0)="" strName(0)="" strMessage="" strQuery="Select*FromWin32_OperatingSystem" SetobjEnumerator=objService.ExecQuery(strQuery,,0) IfErr.NumberThen Print"Error0x"&CStr(Hex(Err.Number))&"occurredduringthequery." IfErr.Description<>""Then Print"Errordescription:"&Err.Description&"." EndIf Err.Clear ExitSub EndIf i=0 ForEachobjInstanceinobjEnumerator IfblnForceThen intStatus=objInstance.Win32ShutDown(CONST_FORCE_LOGOFF) Else intStatus=objInstance.Win32ShutDown(CONST_LOGOFF) EndIf IFintStatus=0Then strMessage="Loggingoffthecurrentuseronmachine"&_ strServer&"..." Else strMessage="Failedtologoffthecurrentuserfrommachine"_ &strServer&"." EndIf CallWriteLine(strMessage,objOutputFile) Next IfIsObject(objOutputFile)Then objOutputFile.Close CallWscript.Echo("Resultsaresavedinfile"&strOutputFile&".") EndIf EndSub '******************************************************************** '* '*SubPowerOff() '* '*Purpose:Powersoffamachine. '* '*Input:strServeramachinename '*strOutputFileanoutputfilename '*strUserNamethecurrentuser'sname '*strPasswordthecurrentuser'spassword '*blnForcespecifieswhethertoforcethelogoff '*intTimerspecifiestheamountoftimetoperformthefunction '* '*Output:ResultsareeitherprintedonscreenorsavedinstrOutputFile. '* '******************************************************************** PrivateSubPowerOff(strServer,strOutputFile,strUserName,strPassword,blnPowerOff,blnForce,intTimer) ONERRORRESUMENEXT DimobjFileSystem,objOutputFile,objService,objEnumerator,objInstance DimstrQuery,strMessage DimintStatus ReDimstrID(0),strName(0) ifblnPoweroff=falsethen Exitsub Endif IfintTimer>0then wscript.echo"Poweringoffmachine"&strServer&"in"&intTimer&"seconds..." wscript.sleep(intTimer*1000) Endif 'Openatextfileforoutputifthefileisrequested IfNotIsEmpty(strOutputFile)Then If(NOTblnOpenFile(strOutputFile,objOutputFile))Then CallWscript.Echo("Couldnotopenanoutputfile.") ExitSub EndIf EndIf 'Establishaconnectionwiththeserver. IfblnConnect("root\cimv2",_ strUserName,_ strPassword,_ strServer,_ objService)Then CallWscript.Echo("") CallWscript.Echo("Pleasechecktheservername,"_ &"credentialsandWBEMCore.") ExitSub EndIf strID(0)="" strName(0)="" strMessage="" strQuery="Select*FromWin32_OperatingSystem" SetobjEnumerator=objService.ExecQuery(strQuery,,0) IfErr.NumberThen Print"Error0x"&CStr(Hex(Err.Number))&"occurredduringthequery." IfErr.Description<>""Then Print"Errordescription:"&Err.Description&"." EndIf Err.Clear ExitSub EndIf i=0 ForEachobjInstanceinobjEnumerator IfblnForceThen intStatus=objInstance.Win32ShutDown(CONST_FORCE_POWEROFF) Else intStatus=objInstance.Win32ShutDown(CONST_POWEROFF) EndIf IFintStatus=0Then strMessage="Poweroffmachine"&strServer&"." Else strMessage="Failedtopoweroffmachine"&strServer&"." EndIf CallWriteLine(strMessage,objOutputFile) Next IfIsObject(objOutputFile)Then objOutputFile.Close CallWscript.Echo("Resultsaresavedinfile"&strOutputFile&".") EndIf EndSub '******************************************************************** '* '*SubShutdown() '* '*Purpose:Shutsdownamachine. '* '*Input:strServeramachinename '*strOutputFileanoutputfilename '*strUserNamethecurrentuser'sname '*strPasswordthecurrentuser'spassword '*blnForcespecifieswhethertoforcethelogoff '*intTimerspecifiestheamountoftimetoperformthefunction '* '*Output:ResultsareeitherprintedonscreenorsavedinstrOutputFile. '* '******************************************************************** PrivateSubShutdown(strServer,strOutputFile,strUserName,strPassword,blnShutDown,blnForce,intTimer) ONERRORRESUMENEXT DimobjFileSystem,objOutputFile,objService,objEnumerator,objInstance DimstrQuery,strMessage DimintStatus ReDimstrID(0),strName(0) IfblnShutdown=Falsethen ExitSub Endif ifintTimer>0then wscript.echo"Shuttingdowncomputer"&strServer&"in"&intTimer&"seconds..." wscript.sleep(intTimer*1000) Endif 'Openatextfileforoutputifthefileisrequested IfNotIsEmpty(strOutputFile)Then If(NOTblnOpenFile(strOutputFile,objOutputFile))Then CallWscript.Echo("Couldnotopenanoutputfile.") ExitSub EndIf EndIf 'Establishaconnectionwiththeserver. IfblnConnect("root\cimv2",_ strUserName,_ strPassword,_ strServer,_ objService)Then CallWscript.Echo("") CallWscript.Echo("Pleasechecktheservername,"_ &"credentialsandWBEMCore.") ExitSub EndIf strID(0)="" strName(0)="" strMessage="" strQuery="Select*FromWin32_OperatingSystem" SetobjEnumerator=objService.ExecQuery(strQuery,,0) IfErr.NumberThen Print"Error0x"&CStr(Hex(Err.Number))&"occurredduringthequery." IfErr.Description<>""Then Print"Errordescription:"&Err.Description&"." EndIf Err.Clear ExitSub EndIf i=0 ForEachobjInstanceinobjEnumerator IfblnForceThen intStatus=objInstance.Win32ShutDown(CONST_FORCE_SHUTDOWN) Else intStatus=objInstance.Win32ShutDown(CONST_SHUTDOWN) EndIf IFintStatus=0Then strMessage="Shutsdownmachine"&strServer&"." Else strMessage="Failedtoshutdownmachine"&strServer&"." EndIf CallWriteLine(strMessage,objOutputFile) Next IfIsObject(objOutputFile)Then objOutputFile.Close CallWscript.Echo("Resultsaresavedinfile"&strOutputFile&".") EndIf EndSub '******************************************************************** '* '*FunctionintParseCmdLine() '* '*Purpose:Parsesthecommandline. '*Input: '* '*Output:strServeraremoteserver(""=localserver") '*strUserNamethecurrentuser'sname '*strPasswordthecurrentuser'spassword '*strOutputFileanoutputfilename '*intTimeramountoftimeinseconds '* '******************************************************************** PrivateFunctionintParseCmdLine(ByRefstrServer,_ ByRefstrUserName,_ ByRefstrPassword,_ ByRefstrOutputFile,_ ByRefblnLogoff,_ ByRefblnShutdown,_ ByRefblnReboot,_ ByRefblnPowerOff,_ ByRefblnForce,_ ByRefintTimer) ONERRORRESUMENEXT DimstrFlag DimintState,intArgIter DimobjFileSystem IfWscript.Arguments.Count>0Then strFlag=Wscript.arguments.Item(0) EndIf IfIsEmpty(strFlag)Then'Noargumentshavebeenreceived Wscript.Echo("ArgumentsareRequired.") intParseCmdLine=CONST_ERROR ExitFunction EndIf 'Checkiftheuserisaskingforhelporisjustconfused If(strFlag="help")OR(strFlag="/h")OR(strFlag="\h")OR(strFlag="-h")_ OR(strFlag="\?")OR(strFlag="/?")OR(strFlag="?")_ OR(strFlag="h")Then intParseCmdLine=CONST_SHOW_USAGE ExitFunction EndIf 'Retrievethecommandlineandsetappropriatevariables intArgIter=0 DoWhileintArgIter<=Wscript.arguments.Count-1 SelectCaseLeft(LCase(Wscript.arguments.Item(intArgIter)),2) Case"/s" intParseCmdLine=CONST_PROCEED IfNotblnGetArg("Server",strServer,intArgIter)Then intParseCmdLine=CONST_ERROR ExitFunction EndIf intArgIter=intArgIter+1 Case"/o" IfNotblnGetArg("OutputFile",strOutputFile,intArgIter)Then intParseCmdLine=CONST_ERROR ExitFunction EndIf intArgIter=intArgIter+1 Case"/u" IfNotblnGetArg("UserName",strUserName,intArgIter)Then intParseCmdLine=CONST_ERROR ExitFunction EndIf intArgIter=intArgIter+1 Case"/w" IfNotblnGetArg("UserPassword",strPassword,intArgIter)Then intParseCmdLine=CONST_ERROR ExitFunction EndIf intArgIter=intArgIter+1 Case"/f" blnForce=True intArgIter=intArgIter+1 Case"/r" blnReBoot=True userarray(0)=blnReBoot intArgIter=intArgIter+1 Case"/q" blnPowerOff=True userarray(1)=blnPowerOff intArgIter=intArgIter+1 Case"/l" blnLogOff=True userarray(2)=blnLogoff intArgIter=intArgIter+1 Case"/p" blnShutDown=True userarray(3)=blnShutDown intArgIter=intArgIter+1 Case"/t" IfNotblnGetArg("Timer",intTimer,intArgIter)Then intParseCmdLine=CONST_ERROR ExitFunction EndIf intArgIter=intArgIter+1 CaseElse'Weshouldn'tgethere CallWscript.Echo("Invalidormisplacedparameter:"_ &Wscript.arguments.Item(intArgIter)&vbCRLF_ &"Pleasechecktheinputandtryagain,"&vbCRLF_ &"orinvokewith'/?'forhelpwiththesyntax.") Wscript.Quit EndSelect Loop'**intArgIter<=Wscript.arguments.Count-1 MyCount=0 fori=0to3 ifuserarray(i)=Truethen MyCount=Mycount+1 Endif Next ifMycount>1then intParseCmdLine=CONST_SHOW_USAGE Endif IfIsEmpty(intParseCmdLine)Then intParseCmdLine=CONST_ERROR Wscript.Echo("ArgumentsareRequired.") EndIf EndFunction '******************************************************************** '* '*SubShowUsage() '* '*Purpose:Showsthecorrectusagetotheuser. '* '*Input:None '* '*Output:Helpmessagesaredisplayedonscreen. '* '******************************************************************** PrivateSubShowUsage() Wscript.Echo"" Wscript.Echo"Logoffs,Reboots,PowersOff,orShutsDownamachine." Wscript.Echo"" Wscript.Echo"SYNTAX:" Wscript.Echo"Restart.vbs[/S<server>][/U<username>][/W<password>]" Wscript.Echo"[/O<outputfile>]</L></R></P></Q></F>[/T<timeinseconds>]" Wscript.Echo"" Wscript.Echo"PARAMETERSPECIFIERS:" wscript.echo"/TAmountoftimetoperformthefunction." Wscript.Echo"/QPerformShutdown." Wscript.Echo"/PPerformPoweroff." Wscript.Echo"/RPerformReboot." Wscript.Echo"/LPerformLogoff." Wscript.Echo"/FForceFunction." Wscript.Echo"serverAmachinename." Wscript.Echo"usernameThecurrentuser'sname." Wscript.Echo"passwordPasswordofthecurrentuser." Wscript.Echo"outputfileTheoutputfilename." Wscript.Echo"" Wscript.Echo"EXAMPLE:" Wscript.Echo"1.cscriptRestart.vbs/SMyMachine2/R" Wscript.Echo"RebootsthecurrentmachineMyMachine2." Wscript.Echo"2.cscriptRestart.vbs/SMyMachine2/R/F" Wscript.Echo"ForcesMyMachine2toreboot." Wscript.Echo"3.cscriptRestart.vbs/SMyMachine2/R/T30" Wscript.Echo"RebootsthecurrentmachineMyMachine2in30seconds." Wscript.Echo"NOTE:" Wscript.Echo"Theforceoptionwillmakethemachineperformthefunctioneven"_ &"ifthereare" Wscript.Echo"openandunsaveddocuementsonthescreen." EndSub '******************************************************************** '*GeneralRoutines '******************************************************************** '******************************************************************** '* '*FunctionstrPackString() '* '*Purpose:AttachesspacestoastringtoincreasethelengthtointWidth. '* '*Input:strStringastring '*intWidththeintendedlengthofthestring '*blnAfterShouldspacesbeaddedafterthestring? '*blnTruncatespecifieswhethertotruncatethestringornotif '*thestringlengthislongerthanintWidth '* '*Output:strPackStringisreturnedasthepackedstring. '* '******************************************************************** PrivateFunctionstrPackString(ByValstrString,_ ByValintWidth,_ ByValblnAfter,_ ByValblnTruncate) ONERRORRESUMENEXT intWidth=CInt(intWidth) blnAfter=CBool(blnAfter) blnTruncate=CBool(blnTruncate) IfErr.NumberThen CallWscript.Echo("Argumenttypeisincorrect!") Err.Clear Wscript.Quit EndIf IfIsNull(strString)Then strPackString="null"&Space(intWidth-4) ExitFunction EndIf strString=CStr(strString) IfErr.NumberThen CallWscript.Echo("Argumenttypeisincorrect!") Err.Clear Wscript.Quit EndIf IfintWidth>Len(strString)Then IfblnAfterThen strPackString=strString&Space(intWidth-Len(strString)) Else strPackString=Space(intWidth-Len(strString))&strString&"" EndIf Else IfblnTruncateThen strPackString=Left(strString,intWidth-1)&"" Else strPackString=strString&"" EndIf EndIf EndFunction '******************************************************************** '* '*FunctionblnGetArg() '* '*Purpose:HelpertointParseCmdLine() '* '*Usage: '* '*Case"/s" '*blnGetArg("servername",strServer,intArgIter) '* '******************************************************************** PrivateFunctionblnGetArg(ByValStrVarName,_ ByRefstrVar,_ ByRefintArgIter) blnGetArg=False'failure,changedtoTrueuponsuccessfulcompletion IfLen(Wscript.Arguments(intArgIter))>2then IfMid(Wscript.Arguments(intArgIter),3,1)=":"then IfLen(Wscript.Arguments(intArgIter))>3then strVar=Right(Wscript.Arguments(intArgIter),_ Len(Wscript.Arguments(intArgIter))-3) blnGetArg=True ExitFunction Else intArgIter=intArgIter+1 IfintArgIter>(Wscript.Arguments.Count-1)Then CallWscript.Echo("Invalid"&StrVarName&".") CallWscript.Echo("Pleasechecktheinputandtryagain.") ExitFunction EndIf strVar=Wscript.Arguments.Item(intArgIter) IfErr.NumberThen CallWscript.Echo("Invalid"&StrVarName&".") CallWscript.Echo("Pleasechecktheinputandtryagain.") ExitFunction EndIf IfInStr(strVar,"/")Then CallWscript.Echo("Invalid"&StrVarName) CallWscript.Echo("Pleasechecktheinputandtryagain.") ExitFunction EndIf blnGetArg=True'success EndIf Else strVar=Right(Wscript.Arguments(intArgIter),_ Len(Wscript.Arguments(intArgIter))-2) blnGetArg=True'success ExitFunction EndIf Else intArgIter=intArgIter+1 IfintArgIter>(Wscript.Arguments.Count-1)Then CallWscript.Echo("Invalid"&StrVarName&".") CallWscript.Echo("Pleasechecktheinputandtryagain.") ExitFunction EndIf strVar=Wscript.Arguments.Item(intArgIter) IfErr.NumberThen CallWscript.Echo("Invalid"&StrVarName&".") CallWscript.Echo("Pleasechecktheinputandtryagain.") ExitFunction EndIf IfInStr(strVar,"/")Then CallWscript.Echo("Invalid"&StrVarName) CallWscript.Echo("Pleasechecktheinputandtryagain.") ExitFunction EndIf blnGetArg=True'success EndIf EndFunction '******************************************************************** '* '*FunctionblnConnect() '* '*Purpose:ConnectstomachinestrServer. '* '*Input:strServeramachinename '*strNameSpaceanamespace '*strUserNamenameofthecurrentuser '*strPasswordpasswordofthecurrentuser '* '*Output:objServiceisreturnedasaserviceobject. '*strServerissettolocalhostifleftunspecified '* '******************************************************************** PrivateFunctionblnConnect(ByValstrNameSpace,_ ByValstrUserName,_ ByValstrPassword,_ ByRefstrServer,_ ByRefobjService) ONERRORRESUMENEXT DimobjLocator,objWshNet blnConnect=False'Thereisnoerror. 'CreateLocatorobjecttoconnecttoremoteCIMobjectmanager SetobjLocator=CreateObject("WbemScripting.SWbemLocator") IfErr.Numberthen CallWscript.Echo("Error0x"&CStr(Hex(Err.Number))&_ "occurredincreatingalocatorobject.") IfErr.Description<>""Then CallWscript.Echo("Errordescription:"&Err.Description&".") EndIf Err.Clear blnConnect=True'Anerroroccurred ExitFunction EndIf 'Connecttothenamespacewhichiseitherlocalorremote SetobjService=objLocator.ConnectServer(strServer,strNameSpace,_ strUserName,strPassword) ObjService.Security_.impersonationlevel=3 IfErr.Numberthen CallWscript.Echo("Error0x"&CStr(Hex(Err.Number))&_ "occurredinconnectingtoserver"_ &strServer&".") IfErr.Description<>""Then CallWscript.Echo("Errordescription:"&Err.Description&".") EndIf Err.Clear blnConnect=True'Anerroroccurred EndIf 'Getthecurrentserver'snameifleftunspecified IfIsEmpty(strServer)Then SetobjWshNet=CreateObject("Wscript.Network") strServer=objWshNet.ComputerName EndIf EndFunction '******************************************************************** '* '*SubVerifyHostIsCscript() '* '*Purpose:Determineswhichprogramisusedtorunthisscript. '* '*Input:None '* '*Output:Ifhostisnotcscript,thenanerrormessageisprinted '*andthescriptisaborted. '* '******************************************************************** SubVerifyHostIsCscript() ONERRORRESUMENEXT DimstrFullName,strCommand,i,j,intStatus strFullName=WScript.FullName IfErr.Numberthen CallWscript.Echo("Error0x"&CStr(Hex(Err.Number))&"occurred.") IfErr.Description<>""Then CallWscript.Echo("Errordescription:"&Err.Description&".") EndIf intStatus=CONST_ERROR EndIf i=InStr(1,strFullName,".exe",1) Ifi=0Then intStatus=CONST_ERROR Else j=InStrRev(strFullName,"",i,1) Ifj=0Then intStatus=CONST_ERROR Else strCommand=Mid(strFullName,j+1,i-j-1) SelectCaseLCase(strCommand) Case"cscript" intStatus=CONST_CSCRIPT Case"wscript" intStatus=CONST_WSCRIPT CaseElse'shouldneverhappen CallWscript.Echo("Anunexpectedprogramwasusedto"_ &"runthisscript.") CallWscript.Echo("OnlyCScript.ExeorWScript.Execan"_ &"beusedtorunthisscript.") intStatus=CONST_ERROR EndSelect EndIf EndIf IfintStatus<>CONST_CSCRIPTThen CallWScript.Echo("PleaserunthisscriptusingCScript."&vbCRLF&_ "Thiscanbeachievedby"&vbCRLF&_ "1.Using""CScriptRestart.vbsarguments""forWindows95/98or"_ &vbCRLF&"2.ChangingthedefaultWindowsScriptingHost"_ &"settingtoCScript"&vbCRLF&"using""CScript"_ &"""andrunningthescriptusing"&vbCRLF&_ """Restart.vbsarguments""forWindowsNT/2000.") WScript.Quit EndIf EndSub '******************************************************************** '* '*SubWriteLine() '*Purpose:Writesatextlineeithertoafileoronscreen. '*Input:strMessagethestringtoprint '*objFileanoutputfileobject '*Output:strMessageiseitherdisplayedonscreenorwrittentoafile. '* '******************************************************************** SubWriteLine(ByValstrMessage,ByValobjFile) OnErrorResumeNext IfIsObject(objFile)then'objFileshouldbeafileobject objFile.WriteLinestrMessage Else CallWscript.Echo(strMessage) EndIf EndSub '******************************************************************** '* '*FunctionblnErrorOccurred() '* '*Purpose:Reportserrorwithastringsayingwhattheerroroccurredin. '* '*Input:strInstringsayingwhattheerroroccurredin. '* '*Output:displayedonscreen '* '******************************************************************** PrivateFunctionblnErrorOccurred(ByValstrIn) IfErr.NumberThen CallWscript.Echo("Error0x"&CStr(Hex(Err.Number))&":"&strIn) IfErr.Description<>""Then CallWscript.Echo("Errordescription:"&Err.Description) EndIf Err.Clear blnErrorOccurred=True Else blnErrorOccurred=False EndIf EndFunction '******************************************************************** '* '*FunctionblnOpenFile '* '*Purpose:Opensafile. '* '*Input:strFileNameAstringwiththenameofthefile. '* '*Output:SetsobjOpenFiletoaFileSystemObjectandsetisitto '*NothinguponFailure. '* '******************************************************************** PrivateFunctionblnOpenFile(ByValstrFileName,ByRefobjOpenFile) ONERRORRESUMENEXT DimobjFileSystem SetobjFileSystem=Nothing IfIsEmpty(strFileName)ORstrFileName=""Then blnOpenFile=False SetobjOpenFile=Nothing ExitFunction EndIf 'Createafileobject SetobjFileSystem=CreateObject("Scripting.FileSystemObject") IfblnErrorOccurred("Couldnotcreatefilesystemobject.")Then blnOpenFile=False SetobjOpenFile=Nothing ExitFunction EndIf 'Openthefileforoutput SetobjOpenFile=objFileSystem.OpenTextFile(strFileName,8,True) IfblnErrorOccurred("Couldnotopen")Then blnOpenFile=False SetobjOpenFile=Nothing ExitFunction EndIf blnOpenFile=True EndFunction '******************************************************************** '** '*EndofFile* '** '********************************************************************。

48人参与, 0条评论 登录后显示评论回复

你需要登录后才能评论 登录/ 注册