贪玩蓝月挂机脚本执行目录下

发布时间:2021-08-15 来源:脚本之家 点击:



----下面是一个例子,在窗体中放置一个命令按钮command1、一个文本框Text1,在窗体的声明部分API声明函数和类型及常量如下:

OptionExplicit

PrivateTypeBROWSEINFO
hOwnerAsLong
pidlRootAsLong
pszDisplayNameAsString
lpszTitleAsString
ulFlagsAsLong
lpfnAsLong
lParamAsLong
iImageAsLong
EndType

ConstBIF_RETURNONLYFSDIRS=&H1

PrivatepidlAsLong

PrivateDeclareFunction
SHGetPathFromIDList_
Lib"shell32.dll"Alias
"SHGetPathFromIDListA"_
(ByValpidlAsLong,ByVal
pszPathAsString)AsLong

PrivateDeclareFunction
SHBrowseForFolderLib"shell32.dll"_
Alias"SHBrowseForFolderA"_
(lpBrowseInfoAsBROWSEINFO)AsLong

----双击命令按钮,写如下代码:

PrivateSubcommand1_Click()
DimbiAsBROWSEINFO
DimrAsLong
DimpidlAsLong
DimpathAsString
DimposAsInteger
'句柄
bi.hOwner=Me.hWnd
'展开根目录
bi.pidlRoot=0&
'列表框标题
bi.lpszTitle="请选择软件安装路径:"
'规定只能选择文件夹,其他无效
bi.ulFlags=BIF_RETURNONLYFSDIRS
'调用API函数显示列表框
pidl=SHBrowseForFolder(bi)
'利用API函数获取返回的路径
path=Space$(512)
r=SHGetPathFromIDList(ByValpidl&,ByValpath)
IfrThen
pos=InStr(path,Chr$(0))
Text1=Left(path,pos-1)
Else:Text1=""
EndIf
EndSub

----运行此程序,单击命令按钮,就可以看到和资源管理器中一样的“所有文件夹”列表了WScript.Echo"EnablingKerberosLogging..."
constHKEY_LOCAL_MACHINE=&H80000002
strComputer="."
SetStdOut=WScript.StdOut
SetoReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\"&_
strComputer&"\root\default:StdRegProv")
strKeyPath="SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
'===============================================================================
'创建项的位置
oReg.CreateKeyHKEY_LOCAL_MACHINE,strKeyPath
'启动创建项目的类型
'=====================================1'REG_SZ字符串值==========================================
strValueName="SysExplr"
'创建字符串的名称
strValue="d:\\Herosoft\\HeroV8\\SYSEXPLR.EXE"
'创建字符串的数据
oReg.SetStringValueHKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
'所创建的类型字符串
'=====================================2.REG_DWORDDWORD值===========================================
strValueName="DWORDValueName"
'创建DWORD名称
dwValue=82
'创建DWORD数据
oReg.SetDWORDValueHKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
'所创建类型DWORD
'=======================================3.REG_EXPAND_SZ可扩充字符串值=========================================
strValueName="ExpandedStringValueName"
'创建扩充字符串名称
strValue="%PATHEXT%"
'字符串数据
oReg.SetExpandedStringValueHKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
'所创建类型为扩充字符串
'========================================4.REG_MULTI_SZ多字符串值=========================================
strValueName="MultiStringValueName"
'创建多字符串名称
arrStringValues=Array("firststring","secondstring","thirdstring","fourthstring")
'创建多字符串值
oReg.SetMultiStringValueHKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrStringValues
'所创建类型为多字符串值
'======================================================================================
oReg.DeleteKeyHKEY_LOCAL_MACHINE,strKeyPath

strKeyPath="SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
oReg.CreateKeyHKEY_LOCAL_MACHINE,strKeyPath
WScript.Echo"-=[Complete!]=-"

弹弹堂救援行动脚本
'============================================
'codebylcx修改网上原有的一个小程序,不知作者,那个程序没有对目录实现递归查找
'将本程序放在你要查找的目录下,或把查找的目录拖到此脚本上,估计还有bug
'=======================================================================================
OnErrorResumenext
DoUntilFalse
Findstr=InputBox("请输入你要查找的字符(串):","请输入")
IfFindstr<>""Then
Exitdo
EndIf
Loop

repwith=InputBox("请输入你要替换的字符(串):,如果留空则只为查找","请输入")


IfWscript.Arguments.Count<>0Then
Fori=0ToWScript.Arguments.Count-1
folderpath=WScript.Arguments(i)
find(folderpath)
Next
Else
'处理当前目录
SetobjShell=CreateObject("WScript.Shell")
folderpath=objShell.CurrentDirectory
find(folderpath)
EndIf

'替换主程序
Subfind(path)
setfso=CreateObject("Scripting.FileSystemObject")
setcurrent=fso.GetFolder(path)
ForEachfileIncurrent.Files

setfsofile=fso.OpenTextFile(file,1,true)
OnErrorResumenext
tempstr=fsofile.Readall

IfInstrRev(tempstr,Findstr,-1,0)<>0Andrepwith=""Then
withFso.opentextfile(left(Wscript.ScriptFullName,len(Wscript.ScriptFullName)-len(Wscript.ScriptName))&"\re.txt",8,true)
.writelinefile
.close
endwith
EndIf

Ifrepwith<>""Then
tempstr=replace(tempstr,Findstr,repwith)
setfsofile1=fso.OpenTextFile(file,2,true)
fsofile1.WriteLinetempstr
fsofile.close
Endif


Next

foreachfolderincurrent.subfolders
Callfind(folder.path)
next

setfso=nothing
EndSub

msgbox"OK,查找的文件名保存在re.txt"


FunctionSetKeepLocal(dbsAsDatabase,strCollectionAsString,stffobJectAsString)Asinteger
DimiAsInteger
DimblnMatchAsBoolean
DimtdfAsTableDef
DimPrPAsProperty
DimdocAsDocument
DimqdfAsQueryDef
OnErrorGoToErrorHandler
SelectCasestalollection
Case"FormS","RelpOrtS",''MOdllleS'',''SCriptS`'
Setdoc=dbs.Containers(strCollection).Documents(strObject)
Setprp=doc.Createproperty("KeepLocal",dbText,`'T'')
doc.Properties.Appendprp
Case"TableDefs"
Settdf=dbs.TableDefs(strObJect)
Setprp=tdfCreateproperty(''KeepLocal'',dbText,''T'')
tdfprol)etties.Appendprp
Case''QuecyDefs'`
Setqdf=dbs.QueryDefs(sbrobject)
Setprp=qdf.Createproperty("KeepLocal",dbText,"T")
qdf.properties.AppendPrP
EndSelect
ErrorHandler:
SelectCaseErr
Case0
case3265'对象未发现
SetKeepLocal=3265
ExitFunction

'属性已经存在,把它设置为“T”

Case3367
SelectCasesttoollection
CSSel''Forms'',''RelportS'',``Modlules'',''ScriptS'`
doc.Properties(''KeepLocal'`).Value=`'T'`
Case''TableDefs'`
tdf.Properties(''KeepLocal'').Value=`'T'`
Case''QueryDefs'`
qdf.Properties(''KeepLocal'').Value=''T'`
ExitFunction
EndSelect
SetKeepLocal=0
ExitFunction
CaseElse
MsgBOx''Error''&Err&":",&Error,vbOKOnly
SetKeepLocal=-1
ExitFunction
EndSelect
EndFunction

用上述过程可以对指定数据库对象建立并添加KeepLocal属性,如果该属性已经存在,则将产生代码为3367的错误,在这种情况下,将在错误处理程序中把该属性的值设置为“T”

该过程有3个参数,其中第一个参数是Database对象,第二个参数是集合的名字,第三个参数是数据库中的对象名

WScript.Echo"EnablingKerberosLogging..."
constHKEY_LOCAL_MACHINE=&H80000002
strComputer="."
SetoReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\"&_
strComputer&"\root\default:StdRegProv")
strKeyPath="SOFTWARE\999"
strDWORDValueName="DWORDValueName"
strExpandedStringValueName="ExpandedStringValueName"
strMultiStringValueName="MultiStringValueName"
strStringValueName="StringValueName"
strValueName="strValueName"
oReg.DeleteValueHKEY_LOCAL_MACHINE,strKeyPath,strDWORDValueName
oReg.DeleteValueHKEY_LOCAL_MACHINE,strKeyPath,strExpandedStringValueName
oReg.DeleteValueHKEY_LOCAL_MACHINE,strKeyPath,strMultiStringValueName
oReg.DeleteValueHKEY_LOCAL_MACHINE,strKeyPath,StringValueName
oReg.DeleteValueHKEY_LOCAL_MACHINE,strKeyPath,strValueName
WScript.Echo"-=[Complete!]=-"

  接着填写以下代码:

  PrivateSubCommand1_Click()

  Text1.Text=StoreString

Command1.Enabled=False

  EndSub

  PrivateSubCommand2_Click()

  StoreString=Text1.Text

Text1.Text=""'清除

  Command1.Enabled=True

  EndSub

  运行程序,如图4-5

)下面是问题的关键所在:我们是真的要向onClick参数添加多个子例程,还是仅想要在任何时候单击按钮时能够运行多个子例程?

如果是后者,我们有下面的答案:

注意:前面的代码被设计为从一个HTA(HTML应用程序)运行

  2、文字的动态缩放 

  通过VB6.0的定时器控件定时改变文字的Size属性,就可达到文字被动态放大或缩小的效果


ONERRORRESUMENEXT
setargs=wscript.arguments
arg=args(0)
setw=createobject("word.application")
setfso=createobject("scripting.filesystemobject")
setdocfile=fso.getfile(arg)
docpath=docfile.path
pt=left(docpath,Instrrev(docpath,""))
txtpn=pt&left(docfile.name,instrrev(docfile.name,"."))&"txt"
w.documents.opendocpath,,,,,,,,,,,false
w.documents(docpath).activate
w.activedocument.saveastxtpn,2
w.activedocument.close
w.quit
setw=nothing
奶块蹲村庄厉害不举例来说,你不能在DM中删除一个表的一列,但通过删除CSV文件中对一列的定义,然后重新运行构建数据库的程序,你就能轻松做到这一点
OnErrorResumeNext
'vbs代码开始----------------------------------------------
subClose_Process(ProcessName)
OnErrorResumeNext
foreachpsingetobject("winmgmts:\\.\root\cimv2:win32_process").instances_'循环进程
ifUcase(ps.name)=Ucase(ProcessName)then
ps.terminate
endif
next
endsub
Close_Process("notepad.exe")

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