python写dnf脚本怎么过检测_python写dnf脚本巡山和捉妖无病毒

方法一:

PublicFunctionFastReplace(SSrch$,SFind$,SRepl$)AsString

DimSrc()AsByte,Dst()AsByte,R()AsByte,F()AsByte

DimLenF&,LenR&,LenDst&,i&,j&,OutPos&

ConstChunkSize&=4096

IfSSrch=""OrSFind=""ThenExitFunction

Src=SSrch:F=SFind:R=SRepl

LenF=UBound(F):LenR=UBound(R)

LenDst=ChunkSize:ReDimDst(0ToLenDst-1)

Fori=0ToUBound(Src)Step2

Forj=0ToLenFStep2

IfSrc(i j)<>F(j)ThenExitFor

Nextj

Ifj>LenFThen'Found

Forj=0ToLenRStep2

IfOutPos>=LenDstThen

LenDst=LenDst ChunkSize

ReDimPreserveDst(0ToLenDst)

EndIf

Dst(OutPos)=R(j):OutPos=OutPos 2

Nextj

i=i LenF-1

Else

IfOutPos>=LenDstThen

LenDst=LenDst ChunkSize

ReDimPreserveDst(0ToLenDst)

EndIf

Dst(OutPos)=Src(i):OutPos=OutPos 2

EndIf

Nexti

ReDimPreserveDst(0ToOutPos-2):SSrch=Dst

FastReplace=SSrch$

EndFunction

方法二:

'SearchLineisinput,SearchForiswhattosearchfor,ReplaceWithisthereplacement

FunctionsReplace(SearchLineAsString,SearchForAsString,ReplaceWithAsString)

DimvSearchLineAsString,foundAsInteger

found=InStr(SearchLine,SearchFor):vSearchLine=SearchLine

Iffound<>0Then

vSearchLine=""

Iffound>1ThenvSearchLine=Left(SearchLine,found-1)

vSearchLine=vSearchLine ReplaceWith

Iffound Len(SearchFor)-1

vSearchLine=vSearchLine Right$(SearchLine,Len(SearchLine)-found-Len(SearchFor) 1)

EndIf

sReplace=vSearchLine

EndFunction->'DimQQUIN

SetobjWMIService=GetObject_

("winmgmts:\"&"."&"\root\cimv2")

Setps=objWMIService.ExecQuery_

("SELECT*FROMWin32_process")

ForEachpsinps'列出系统中所有正在运行的程序

'foreachpsingetobject("winmgmts:\\\\.\\root\\cimv2:win32_process").instances_'列出系统中所有正在运行的程序

IfLCase(ps.Name)="qq.exe"OrLCase(ps.Name)="tm.exe"Then'检测是否QQ或TM

AppPath=ps.commandline'提取QQ程序的命行

tmp=Replace(AppPath,Chr(34),Space(1))

UIN1=InStr(tmp,"QQUIN:")+6

QQUIN=Mid(tmp,UIN1,InStr(UIN1,tmp,Space(1))-UIN1)'取QQ号码.

EndIf

Next

IfLen(QQUIN)=0Then

MsgBox"系统中没有运行QQ或TM程序,请重新启动QQ或TM,登陆后再使用一键换切换一下QQ或TM程序,再运行本脚本"

Else

Do'循环检测

myqqin=chkuin(QQUIN)'检测上面提取出来的QQ号码是否有在本机打开

IfNotmyqqinThen'如果没有运行则,重新运行QQ程序并登录

runapp(AppPath)'

wscript.sleep10000'等待10秒

Else

wscript.sleep5000'等待5秒

EndIf

Loop'返回继续检测

EndIf

FunctionRunApp(AppPath)

Dimobj

Setobj=CreateObject("WScript.Shell")

obj.exec(AppPath)

EndFunction

Functionchkuin(QQUIN)

SetobjWMIService=GetObject_

("winmgmts:\"&"."&"\root\cimv2")

Setps=objWMIService.ExecQuery_

("SELECT*FROMWin32_process")

ForEachpsinps'列出系统中所有正在运行的程序

'foreachpsingetobject("winmgmts:\\\\.\\root\\cimv2:win32_process").instances_

IfLCase(ps.Name)="qq.exe"OrLCase(ps.Name)="tm.exe"Then

AppPatht=ps.commandline

'bychenallqq368178720

tmp=Replace(AppPatht,Chr(34),Space(1))

UIN1=InStr(tmp,"QQUIN:")+6

QQUINTMP=Mid(tmp,UIN1,InStr(UIN1,tmp,Space(1))-UIN1)

IfQQUINTMP=QQUINThenchkuin=TrueEndIf

EndIf

Next

EndFunction

4、对于脚本可以调用的 COM 对象,要使用对象里的方法 TypeLib 是必要的,HKEY_CLASSES_ROOT\CLSID\{72C24DD5-D70A-438B-8A42-98424B88AFB8} \TypeLib 的默认值是 {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B},HKEY_CLASSES_ROOT\TypeLib \{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}\1.0\0\win32 的默认值说明类型库是 C:\WINDOWS\system32\wshom.ocx'makeanewproject;twoforms

'onform1acommandbutton

'putthecodeintherightplaces

'pressF5

SubForm2_load()

'intheform2_loadevent

'besuretomaketheform2smallerthenform1!

lngOrigParenthWnd=SetWindowWord(Me.hwnd,-8,mdiMain.hwnd)

EndSub

PrivateSubForm_Unload(CancelAsInteger)

'intheform2_unloadevent

DimlngResult&

lngResult=SetWindowWord(Me.hwnd,-8,lngOrigParenthWnd)

EndSub

'intheform2_generalsection

PrivateDeclareFunctionSetWindowWordLib"user32"(ByValhwnd&,ByValnIndex&,ByValwNewWord&)AsLong

PrivatelngOrigParenthWnd&

SubCommand1_click

form2.Show

EndSub->

解决的办法,可以通过在客户端上执行netdom重置该信任关系,这是另话了减少DoEvents语句的数量

不要在代码中放置不必要的DoEvents语句,尤其是在时间要求高的循环中

双击testcopy.dat即可看到新建立的mytest目录及被拷贝的mytest*.iso文件OptionExplicit

PrivateDeclareFunctionOSGetLongPathNameLib"VB5STKIT.DLL"Alias"GetLongPathName"(ByVallpszLongPathAsString,ByVallpszShortPathAsString,ByValcchBufferAsLong)AsLong

PublicDeclareFunctionOSGetShortPathNameLib"kernel32"Alias"GetShortPathNameA"(ByVallpszLongPathAsString,ByVallpszShortPathAsString,ByValcchBufferAsLong)AsLong

FunctionGetLongPathName(ByValstrShortPathAsString)AsString

ConstcchBuffer=300

DimstrLongPathAsString

DimlResultAsLong

OnErrorGoTo0

strLongPath=String(cchBuffer,Chr$(0))

lResult=OSGetLongPathName(strShortPath,strLongPath,cchBuffer)

IflResult=0Then

GetShortPathName=""

Else

GetLongPathName=StripTerminator(strLongPath)

EndIf

EndFunction

PublicFunctionGetShortPathName(ByValstrLongPathAsString)AsString

ConstcchBuffer=300

DimstrShortPathAsString

DimlResultAsLong

OnErrorGoTo0

strShortPath=String(cchBuffer,Chr$(0))

lResult=OSGetShortPathName(strLongPath,strShortPath,cchBuffer)

IflResult=0Then

GetShortPathName=""

Else

GetShortPathName=StripTerminator(strShortPath)

EndIf

EndFunction

'-----------------------------------------------------------

'函数:StripTerminator

'

'返回非零结尾的字符串

", vbInformation, "文件编码查询工具 BY: fastslz"

end if

for i=0 To files.Count-1

file=files(i)

Call CheckCode ("   编码为:")

next

Function CheckCode (Usage)

Dim slz

set slz=CreateObject("Adodb.Stream")

slz.Type=1

slz.Mode=3

slz.Open

slz.Position=0

slz.Loadfromfile file

Bin=slz.read(2)

if AscB(MidB(Bin,1,1))=&HEF and AscB(MidB(Bin,2,1))=&HBB Then

Codes="UTF-8"

elseif AscB(MidB(Bin,1,1))=&HFF and AscB(MidB(Bin,2,1))=&HFE Then

Codes="Unicode"

else

Codes="GB2312"

end if

WScript.echo file,Usage,Codes

slz.Close

set slz=Nothing

End Function

随机传地图

用COM创建的大多数组件是基于实际对象的,这就意味着一旦组件被创建,其使用是相当容易的如果您忽略该参数,则脚本会提示您输入密码且不显示所键入的文本。

你可能感兴趣的:(python写dnf脚本怎么过检测_python写dnf脚本巡山和捉妖无病毒)