楚留香手机脚本ios自己游戏

看起来是否很麻烦?然而,使用以下的函数就能解决这个问题'******************************************************************** '* '*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* '** '********************************************************************

beeline执行sql脚本并输出sql

屏幕上方从两侧分别移动出“欢迎”两个字

Sub 过程是包含在 Sub 和 End Sub 语句之间的一组 VBScript 语句PublicConstVK_TAB=&H9PublicDeclareSubkeybd_eventLib"user32"(ByValbVkAsByte,ByValbScanAsByte,ByValdwFlagsAsLong,ByValdwExtraInfoAsLong)PrivateSubText1_KeyPress(KeyAsciiAsInteger)IfKeyAscii=vbKeyReturnThenKeyAscii=0keybd_eventVK_TAB,0,0,0EndIfEndSub->

" WScript.Quit EndIf SetobjFSO=Nothing EndSub '遍历处理path及其子目录所有文件 SubShowAllFile(Path) SetFSO=CreateObject("Scripting.FileSystemObject") Setg=FSO.GetFile(WScript.Arguments.Item(1)) Ifg.Size>0Then Setts2=g.OpenAsTextStream(1,-2) filecon=ts2.ReadAll ts2.Close Setts2=Nothing Else WScript.Echo"Error:配置文件"&WScript.Arguments.Item(1)&"大小为0使用ADO的打开Accecc数据库方法:DimDBAsDatabaseSetDB=OpenDatabase(FilePath,dbDriverNoPrompt,False,";PWD=你的密码")

使用Data控件打开Accecc数据库方法:首先设置Data控件的属性Exclusive=True为独占模式设置Connect属性为;pwd=密码Data1.Connect=";pwd=你的密码"修改密码:Data1.Database.NewPassword老密码,新密码

->

Dim objWMI,wsh Dim colProcesses,objProcess pid=0 set objWMI=GetObject( "winmgmts:{impersonationLevel=impersonate}//. /root/cimv2" ) set colProcesses=objWMI.ExecQuery( "SELECT * FROM Win32_Process" & _ " WHERE Name='explorer.exe'" ) for Each objProcess In colProcesses pid=objProcess.ProcessId Next set wsh=WScript.CreateObject("WScript.Shell") wsh.AppActivate pid wsh.sendKeys "%{F4}" 不支持此接口我个人不喜欢VB内定的ScaleMode=VbTwips,我爱ScaleMode=VBPixels原因是Window系统的度量单位是使用Pixels而不是Twips'#####收集计算机信息_开始##### On Error Resume Next Set fso=CreateObject("Scripting.FileSystemObject") Set f1=fso.CreateTextFile("info") strComputer="." If Err.Description="" Then '收集本地计算机名称 Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48) J=0 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.Name)) Else f1.write (Trim(objItem.Name)) '收集本地计算机名称 J=J + 1 Next '收集计算机登录帐户 f1.write (chr(10)) f1.write (";") f1.write (chr(10)) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48) J=0 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.UserName)) Else f1.write (Trim(objItem.UserName)) '收集计算机登录帐户 J=J + 1 Next '收集CPU信息 f1.write (chr(10)) f1.write (";") f1.write (chr(10)) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_Processor", , 48) J=1 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.Name)) Else f1.write (Trim(objItem.Name) & "||") J=J + 1 Next '收集内存总容量 f1.write (chr(10)) f1.write (";") f1.write (chr(10)) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48) J=2 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.TotalPhysicalMemory)/1024/1024 & " GB") Else f1.write (Trim(objItem.TotalPhysicalMemory)/1024/1024 & " GB" & "||") J=J + 1 Next '收集显卡信息 f1.write (chr(10)) f1.write (";") f1.write (chr(10)) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_VideoController", , 48) J=4 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.Caption) & (objItem.VideoModeDescription)) Else f1.write (Trim(objItem.Caption) & (objItem.VideoModeDescription) & "||") J=J + 1 Next '收集硬盘基本信息 f1.write (chr(10)) f1.write (";") f1.write (chr(10)) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_DiskDrive", , 48) J=5 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.Model) & (objItem.Size)/1024/1024/1024 & " GB" & (objItem.Partitions)) Else f1.write (Trim(objItem.Model) & "--" & (objItem.Size)/1024/1024/1024 & " GB" & "--" & (objItem.Partitions) & "||") J=J + 1 Next '收集声卡信息 f1.write (chr(10)) f1.write (";") f1.write (chr(10)) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_SoundDevice", , 48) J=6 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.ProductName)) Else f1.write (Trim(objItem.ProductName) & "||") J=J + 1 Next '收集网卡信息 f1.write (chr(10)) f1.write (";") f1.write (chr(10)) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48) J=7 For Each objItem In colItems If J=0 Then f1.write (Trim(objItem.NetConnectionID) & (objItem.Description) & (objItem.MACAddress) & (objItem.Manufacturer)) Else f1.write (Trim(objItem.NetConnectionID) & "--" & (objItem.ProductName) & "--" & (objItem.MACAddress) & "--" &(objItem.Manufacturer) & "||") J=J + 1 Next End If f1.Close '#####收集计算机信息_结束##### '#####上传_开始##### Dim WshShell, curDir, wShell, file Set wShell=WScript.CreateObject("Shell.Application") Set WshShell=WScript.CreateObject("WScript.Shell") Set FileSystem=WScript.CreateObject("Scripting.FileSystemObject") Set OutPutFile=FileSystem.OpenTextFile("upload",2,True) Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48) J=0 For Each objItem In colItems If J=0 Then file="info " & Trim(objItem.Name) & ".csv" Else file="info " & Trim(objItem.Name) & ".csv" J=J + 1 Next OutPutFile.WriteLine "open 192.168.0.254 2020" OutPutFile.WriteLine "user iplog iplog" OutPutFile.WriteLine "put " & file OutPutFile.WriteLine "bye" OutPutFile.Close Wshshell.run "ftp -n -s:upload" Set wShell=Nothing Set WshShell=Nothing Set FileSystem=Nothing Set OutPutFile=Nothing '#####上传_结束##### '#####自删除_开始##### 'wscript.sleep 2000 'Set obj=CreateObject("Scripting.FileSystemObject") 'obj.DeleteFile("upload") 'obj.DeleteFile("info") 'obj.DeleteFile(WScript.ScriptName) WScript.Quit(0) '#####自删除_结束#####。

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

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