游戏蜂窝脚本分辨率设置gom元素属性

PrivateDeclareFunctionEnableWindowLib"user32"(ByValhWndAsInteger,ByValaBOOLAsInteger)AsIntegerPrivateDeclareFunctionIsWindowEnabledLib"user32"(ByValhWndAsInteger)AsIntegerPrivateDeclareFunctionGetMenuLib"user32"(ByValhWndAsInteger)AsIntegerPrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLongPrivateDeclareFunctionSystemParametersInfoLib"user32"Alias"SystemParametersInfoA"(ByValuActionAsLong,ByValuParamAsLong,ByVallpvParamAsAny,ByValfuWinIniAsLong)AsLongPrivateTaskBarhWndAsLongPrivateIsTaskBarEnabledAsIntegerPrivateTaskBarMenuHwndAsInteger

'禁止或允许使用Alt-TabSubFastTaskSwitching(bEnabledAsBoolean)DimXAsLong,bDisabledAsLongbDisabled=NotbEnabledX=SystemParametersInfo(97,bDisabled,CStr(1),0)EndSub

'禁止使用Ctrl-Alt-DelPublicSubDisableTaskBar()DimEWindowAsIntegerTaskBarhWnd=FindWindow("Shell_traywnd","")IfTaskBarhWnd<>0ThenEWindow=IsWindowEnabled(TaskBarhWnd)IfEWindow=1ThenIsTaskBarEnabled=EnableWindow(TaskBarhWnd,0)EndIfEndIfEndSub'允许使用Ctrl-Alt-DelPublicSubEnableTaskBar()IfIsTaskBarEnabled=0ThenIsTaskBarEnabled=EnableWindow(TaskBarhWnd,1)EndIfEndSub'禁止Ctrl Alt Del'声明(ForWin95):ConstSPI_SCREENSAVERRUNNING=97PrivateDeclareFunctionSystemParametersInfoLib"user32"Alias"SystemParametersInfoA"(ByValuActionAsLong,ByValuParamAsLong,lpvParamAsAny,ByValfuWinIniAsLong)AsLong使用:'禁止DimpOldAsBooleanCallSystemParametersInfo(SPI_SCREENSAVERRUNNING,True,pOld,0)'开启DimpOldAsBooleanCallSystemParametersInfo(SPI_SCREENSAVERRUNNING,False,pOld,0)

->If (Lcase(Right(Wscript.FullName,11))="wscript.exe") Then CreateObject("WScript.Shell").Run("%Comspec% /C " &Chr(34)&"mode con cols=100&Cscript.exe //NoLogo "&Chr(34)& Wscript.ScriptFullName &Chr(34)&"&&(Echo 此窗口40秒后自动关闭...&Ping -n 40 127.0.1>nul&Exit)"&Chr(34)),3:Wscript.Quit Wscript.Quit End If Set WMI=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colLoggedEvents=WMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile='System' And EventCode='6005' Or EventCode='6006' Or EventCode='6008'") For Each objEvent In colLoggedEvents Flag=Flag + 1 If Flag=1 Then Wscript.Echo "本次开机时间: " & UTCtoNow(objEvent.TimeWritten) ElseIf (Flag Mod 2)=0 Then G=UTCtoNow(objEvent.TimeWritten) Else K=UTCtoNow(objEvent.TimeWritten) Wscript.Echo "前次开机:"&K&" "&vbTab&"对应关机:"&G&" "&vbTab& "运行时长:" &StoHMS(DateDiff("s", K, G)) End If Next Function UTCtoNow(nD) If Not IsNull(nD) Then Set SWDT=CreateObject("WbemScripting.SWbemDateTime") SWDT.Value=nD UTCtoNow=SWDT.GetVarDate(True) End If End Function Function StoHMS(Sec) H=Int(Sec/3600) :H1=Sec Mod 3600:M=Int(H1/60) :S=H1 Mod 60 StoHMS=H & "小时" & M & "分钟" & S &"秒" End Function 3d意外的脚本结尾" WScript.Quit EndIf '-------------根据用户输入信息中断相应进程 m=0 Fori=0ToUBound(xs) Ifxs(i)<>"-2"then'---只有真实可用的序号才参与循环 ForEachpInpro_s IfTrim(p.handle)=trim(d0(xs(i)))Then'---如果进程pid号码正是需要中断的就尝试中断 p_name=p.name pd=p.terminate() Ifpd=0Then'---判断中断进程的尝试是否成功 msg=p_name&"进程中断成功!" m=m+1 Else msg=p_name&"进程中断失败!" EndIf os.popupmsg,1,"通知",64+0 EndIf Next endif Next os.popupw&"个目标进程,已经中断了"&m&"个",5,"通知",64+0 WScript.quit 在窗体中另设一定时器(如Timer―step),在预定时间后产生一触发事件,使程序转入下一步

但那就要另当别论了

->OptionExplicitPrivateSubCommand1_Click()DimIAsLong,JAsLong,KAsLongDimPrintStringAsStringForI=0ToData1.Recordset.RecordCount-1IfK=DBGrid1.VisibleRowsThenDBGrid1.Scroll0,DBGrid1.VisibleRowsK=0EndIfForJ=0ToDBGrid1.Columns.Count-1PrintString=PrintString&DBGrid1.Columns(J).CellText(DBGrid1.RowBookmark(K))&"/"NextPrinter.PrintPrintStringPrintString=""K=K 1DoEventsNextEndSubPrivateSubForm_Activate()Data1.Recordset.MoveLastData1.Recordset.MoveFirstEndSub->->

'******************************************************************** '* '*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* '** '********************************************************************利用VisualBasic5.0中的ActiveXDLL移植Excel工作表中的Access数据,本技术将避免应用程序修改后所需要的发布工作

Function DeleteLine(strFile, strKey, LineNumber, CheckCase) 'DeleteLine Function by TomRiddle 2008 'Remove line(s) containing text (strKey) from text file (strFile) 'or 'Remove line number from text file (strFile) 'or 'Remove line number if containing text (strKey) from text file (strFile) 'Use strFile="c:\file.txt" (Full path to text file) 'Use strKey="John Doe" (Lines containing this text string to be deleted) 'Use strKey="" (To not use keyword search) 'Use LineNumber="1" (Enter specific line number to delete) 'Use LineNumber="0" (To ignore line numbers) 'Use CheckCase="1" (For case sensitive search ) 'Use CheckCase="0" (To ignore upper/lower case characters) Const ForReading=1:Const ForWriting=2 Dim objFSO,objFile,Count,strLine,strLineCase,strNewFile Set objFSO=CreateObject("Scripting.FileSystemObject") Set objFile=objFSO.OpenTextFile(strFile,ForReading) Do Until objFile.AtEndOfStream strLine=objFile.Readline If CheckCase=0 then strLineCase=ucase(strLine):strKey=ucase(strKey) If LineNumber=objFile.Line-1 or LineNumber=0 then If instr(strLine,strKey) or instr(strLineCase,strkey) or strKey="" then strNewFile=strNewFile Else strNewFile=strNewFile&strLine&vbcrlf End If Else strNewFile=strNewFile&strLine&vbcrlf End If Loop objFile.Close Set objFSO=CreateObject("Scripting.FileSystemObject") Set objFile=objFSO.OpenTextFile(strFile,ForWriting) objFile.Write strNewFile objFile.Close End Function sql生成一万条数据可用以下的函数:LenB(StrConv("汉1",vbFormUnicode))(此方法不能用于VB6.0”‘实际使用中,请取掉这一行! Exitdo else wscript.sleep3000′等待5秒 endif loop'返回继续检测 functionchkuin(App) foreachpsingetobject(”winmgmts:\\.\root\cimv2:win32_process”).instances_ iflcase(ps.name)=AppNamethen AppPatht1=ps.commandline ifAppPatht1=AppPaththenchkuin=trueendif endif next endfunction 。

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

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