python脚本实例执行oracle语句

发布时间:2020-06-28 来源:脚本之家 点击:

程序需要,我在网上找了很久才找到,刚刚把程序写好,并加写了注释,希望能帮助大家
再写程序前先引用
microsoftexcel11.0objectLibrary
我看到的文章是10.0的,我这是office2003是11.0,只要安了excel就有这个引用~
PrivateSubcmdsave_Click()
MsgBox"文件保存为:D:\电网配电线路管理信息系统\信息查询结果\事故信息查询结果.xls"
DimiAsInteger
DimjAsInteger
DimexAsObject
DimexwbookAsObject
DimexsheetAsObject

Setex=CreateObject("Excel.Application")
Setexwbook=Nothing
Setexsheet=Nothing
Setexwbook=ex.Workbooks().Add
Setexsheet=exwbook.Worksheets("sheet1")

'在excel里表格的表头,这是根据我的需要添加的标头
ex.Range("c3").Value="日期"
ex.Range("d3").Value="时间"
ex.Range("e3").Value="站点"
ex.Range("f3").Value="汇报人"
ex.Range("g3").Value="线路双编号"
ex.Range("h3").Value="保护动作类型"
ex.Range("i3").Value="事故原因"
ex.Range("j3").Value="处理负责人"
ex.Range("k3").Value="处理方法"
ex.Range("l3").Value="处理结果"
ex.Range("m3").Value="结束时间"
ex.Range("n3").Value="备注"
'i为记录个数使用循环将数据全部添加
Fori=1ToAdodc1.Recordset.RecordCount
j=3 i
'k为数据列数
Fork=0To11
'通过使用变量k和j变换单元格位置
q=Chr(99 k)&j
'将datagrid1的数据放到单元格内
ex.Range(q).Value=DataGrid1.Columns(k)
Nextk
'指针下移
IfAdodc1.Recordset.EOF=FalseThen
Adodc1.Recordset.MoveNext
EndIf
Nexti

'保存输入到事故信息查询结果.xls
exwbook.SaveAs"D:\电网配电线路管理信息系统\信息查询结果\事故信息查询结果.xls"
'退出excel
ex.Quit
EndSub
我觉得这段程序很简单而且很使用,使用时不要打开事故信息查询结果.xls否则会报错
存储时系统会自动提示是否更换文件,根据自己用发来用->


wdFormatDocument97 0 Microsoft Word 97 文档格式
明日之后脚本钢琴自动
GetOwner.VBS用法,在命令行下:GetOwner.vbs 目录名会在相应目录下生成一个TXT.TXT文件,内里列出该目录下所有文件和文件夹的类型,大小,和所有者
注意:大小以MB为单位,小于1MB的就显示为0MB,

以下是代码:

G=WScript.arguments(0)
Set oFSO=CreateObject("Scripting.FileSystemObject")
set txt=oFSO.CreateTextFile(G&"TXT.txt",true) '嘿嘿,如果这个目录下刚好有一个TXT.txt文件,那就算你倒霉,
不会有人真用这种名字来做文件名吧?真的啊,真的有啊?那你
换地方吧~~~C: \TXT.TXT应该不会有了吧?
set objWMI=GetObject("winmgmts:")
Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=
CIM_logicalfile")
For Each oFile In oFiles
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( oFile.name)
txt.WriteLine( "Type: " & oFile.FileType)
if oFile.name=G&"system volume information" then
exit for
end if
if oFile.FileType="File Folder" then
Set objFolder=oFSO.GetFolder(oFile.name)
txt.WriteLine("Size: " & Cint(objFolder.Size/1024/1024) &"MB")
else
txt.WriteLine( "Size: " & cint(oFile.FileSize/1024/1024) &"MB")
end if
strFile=oFile.name
strComputer="."
Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer &
"\root\cimv2")
Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile
& "'}" & " WHERE
AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
For Each objItem in colItems
if oFile.name="system volume information" then
exit for
end if
txt.WriteLine( "FileOwner: " & objItem.AccountName)
Next
Next

统计某用户在某目录下的文件和文件夹使用方法:
脚本名 目录名 用户名
如:
owner.vbs d:\ lsj
结果是在相应目录下生成一个文本文件
格式如下:
--------------------------------------------------------------
d:\jcb-gx
Type: File Folder
Size: 22MB
--------------------------------------------------------------
d:\powerword 2003.rar
Type: WinRAR 档案文件
Size: 503MB
--------------------------------------------------------------
d:\txt.txt
Type: Text Document
Size: 0MB
--------------------------------------------------------------
d:\年 度 考 核 登 记 表2006版061225.doc
Type: Microsoft Word 文档
Size: 0MB
--------------------------------------------------------------
--------------------------------------------------------------
--------------------------------------------------------------
The TotalSize of All files lsj owns is: 525MB
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
以下为脚本代码:

TotalSize=0
G=WScript.arguments(0)
H=WScript.arguments(1)
Set oFSO=CreateObject("Scripting.FileSystemObject")
set txt=oFSO.CreateTextFile(G&"TXT.txt",true)
set objWMI=GetObject("winmgmts:")
Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=
CIM_logicalfile")
For Each oFile In oFiles
strFile=oFile.name
Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile
& "'}" & " WHERE
AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
For Each objItem in colItems
if objItem.AccountName=H then
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( oFile.name)
txt.WriteLine( "Type: " & oFile.FileType)
if oFile.name=G&"system volume information" then
exit for
end if
S=0
if oFile.FileType="File Folder" then
Set objFolder=oFSO.GetFolder(oFile.name)
S=Cint(objFolder.Size/1024/1024)
else
S=Cint(oFile.FileSize/1024/1024)
end if
txt.WriteLine( "Size: " & S &"MB")
TotalSize=TotalSize + S
end if
Next
Next
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( "The TotalSize of All files "&H&" owns is: " & TotalSize &"MB")

更新后:
4.0版
使用方法:
脚本名 目录名
脚本会在相应目录下生成几个与本机用户对应的TXT文件,每个文件列出相应用户所有文件和文件夹的类型大小,并在最
后合总计算所有文件和文件夹的大小
以下是代码:

TotalSize=0
G=WScript.arguments(0)


Set oFSO=CreateObject("Scripting.FileSystemObject")

Set objWMI=GetObject("winmgmts:")
Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=
CIM_logicalfile")

Set objNetwork=CreateObject("Wscript.Network")
strComputer=objNetwork.ComputerName
Set colAccounts=GetObject("" & strComputer & "")
colAccounts.Filter=Array("user")


For Each objUser In colAccounts
H=objUser.Name
A=G & objUser.Name & "txt.txt"
Set txt=oFSO.CreateTextFile (A,true)

For Each oFile In oFiles
strFile=oFile.name
Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile
& "'}" & " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")

For Each objItem in colItems
if objItem.AccountName=H then
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( oFile.name)
txt.WriteLine( "Type: " & oFile.FileType)

if oFile.name=G&"system volume information" then
exit for
end if

S=0

if oFile.FileType="File Folder" then
Set objFolder=oFSO.GetFolder(oFile.name)
S=Cint(objFolder.Size/1024/1024)
else
S=Cint(oFile.FileSize/1024/1024)
end if
txt.WriteLine( "Size: " & S &"MB")
TotalSize=TotalSize + S
end if
Next

Next

txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( "--------------------------------------------------------------")
txt.WriteLine( "The TotalSize of All files "&H&" owns is: " & TotalSize &"MB")
Next

再次更新后:
4.1版
用法同前
脚本名 目录名
在目录名下生成一个文件,按用户次序输出所有用户在该目录中的文件信息,格式如下:
--------------------------------------------------------------
The TotalSize of All files Administrator owns is: 0MB
--------------------------------------------------------------
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
--------------------------------------------------------------
The TotalSize of All files Guest owns is: 0MB
--------------------------------------------------------------
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
--------------------------------------------------------------
The TotalSize of All files HelpAssistant owns is: 0MB
--------------------------------------------------------------
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
--------------------------------------------------------------
d:\powerword 2003.rar
Type: WinRAR 档案文件
Size: 503MB
--------------------------------------------------------------
d:\年 度 考 核 登 记 表2006版061225.doc
Type: Microsoft Word 文档
Size: 0MB
--------------------------------------------------------------
d:\jcb-gx
Type: File Folder
Size: 22MB
--------------------------------------------------------------
The TotalSize of All files lsj owns is: 525MB
--------------------------------------------------------------
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
--------------------------------------------------------------
The TotalSize of All files SUPPORT_388945a0 owns is: 0MB
--------------------------------------------------------------
※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※

以下是代码:

G=WScript.arguments(0)


Set oFSO=CreateObject("Scripting.FileSystemObject")
Set objWMI=GetObject("winmgmts:")
Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=
CIM_logicalfile")

Set objNetwork=CreateObject("Wscript.Network")
strComputer=objNetwork.ComputerName
Set colAccounts=GetObject("" & strComputer & "")
colAccounts.Filter=Array("user")


For Each objUser In colAccounts
TotalSize=0
H=objUser.Name
Set TXT=oFSO.OpenTextFile(G&"\TXT.TXT",8,true)

For Each oFile In oFiles
strFile=oFile.name
Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile
& "'}" & " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner")

For Each objItem in colItems
if objItem.AccountName=H then
TXT.WriteLine( "--------------------------------------------------------------")
TXT.WriteLine( oFile.name)
TXT.WriteLine( "Type: " & oFile.FileType)

if oFile.name=G&"system volume information" then
exit for
end if

S=0

if oFile.FileType="File Folder" then
Set objFolder=oFSO.GetFolder(oFile.name)
S=Cint(objFolder.Size/1024/1024)
else
S=Cint(oFile.FileSize/1024/1024)
end if
TXT.WriteLine( "Size: " & S &"MB")
TotalSize=TotalSize + S
end if
Next
Next

TXT.WriteLine( "--------------------------------------------------------------")

TXT.WriteLine( "The TotalSize of All files "&H&" owns is: " & TotalSize &"MB")
TXT.WriteLine( "--------------------------------------------------------------")
TXT.WriteLine( "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※")
TXT.Close
Next
MsgBox "文件列表信息已成功输出至TXT.TXT文件",64,"OK"PrivateDeclareFunctionCreateDirectoryLib"kernel32"Alias"CreateDirectoryA"(ByVallpPathNameAsString,lpSecurityAttributesAsSECURITY_ATTRIBUTES)AsLong

PrivateTypeSECURITY_ATTRIBUTES
nLengthAsLong
lpSecurityDescriptorAsLong
bInheritHandleAsLong
EndType

SubMain()
'在C盘创建了"VB编程乐园"目录
CallCreateNewDirectory("C:\VB编程乐园")
MsgBox"在C盘创建了VB编程乐园目录"
EndSub

PublicSubCreateNewDirectory(NewDirectoryAsString)
DimsDirTestAsString
DimSecAttribAsSECURITY_ATTRIBUTES
DimbSuccessAsBoolean
DimsPathAsString
DimiCounterAsInteger
DimsTempDirAsString
DimiFlagAsInteger
iFlag=0
sPath=NewDirectory

IfRight(sPath,Len(sPath))<>""Then
sPath=sPath&""
EndIf

iCounter=1
DoUntilInStr(iCounter,sPath,"")=0
iCounter=InStr(iCounter,sPath,"")
sTempDir=Left(sPath,iCounter)
sDirTest=Dir(sTempDir)
iCounter=iCounter 1

'创建目录

SecAttrib.lpSecurityDescriptor=&O0
SecAttrib.bInheritHandle=False
SecAttrib.nLength=Len(SecAttrib)
bSuccess=CreateDirectory(sTempDir,SecAttrib)
Loop
EndSub->


''owc.vbs
class owc
private o
'传入物件
public property set set_obj(o_id)
set o=o_id
end property
'画图矩形图
'chart_bgcolor_图表的背景颜色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
'Interior_Color_矩形内的填充颜色
'Caption_名称
'categories_名称数组
'values_值数组串
public sub bar(chart_bgcolor_,chartCaption_,chartCaption_fontColor_,Interior_Color_,Caption_,categories_,values_)
o.Clear
set cht=o.Charts.Add
set c=o.Constants
cht.Type=c.chChartTypeColumnClustered
'设背景色或是填充
o.Charts(0).PlotArea.Interior.SetSolid chart_bgcolor_

'加上图表的标题
o.HasChartSpaceTitle=True
set cst=o.ChartSpaceTitle
cst.Caption=chartCaption_
cst.Font.Color=chartCaption_fontColor_
cst.Font.Italic=False
cst.Font.Name="Arial"
cst.Font.Size=12
cst.Font.Underline=c.owcUnderlineStyleSingle

'添加数据
cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
'直条的背景色进行设定
set sc=o.Charts(0).SeriesCollection(0)
sc.Interior.Color=Interior_Color_

'直条上的显示设置
sc.Caption=Caption_
set dl=cht.SeriesCollection(0).DataLabelsCollection.Add
dl.HasValue=True
dl.HasPercentage=False
dl.Font.Size=9
dl.Font.Color="red"
dl.Position=c.chLegendPositionRight
dl.NumberFormat="00.00%"
'左边百分比的属性设置
Set cta=cht.Axes(c.chAxisPositionLeft)
cta.Font.Size=9
cta.NumberFormat="0.0%"
cta.MajorUnit=0.1
end sub
'多系列矩形图
'chart_bgColor_图表的背景颜色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
'color_颜色数组
'caption_名称数组
'categories_名称数组
'values_值数组
public sub serBar(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,caption_,categories_,values_)
o.Clear
o.Charts.Add
Set c=o.Constants
'图表的类型
o.Charts(0).type=c.chChartTypeColumnClustered
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
''加上图表的标题
o.HasChartSpaceTitle=True
o.ChartSpaceTitle.Caption=chartCaption_
'标题的属性
o.ChartSpaceTitle.Font.Color=chartCaption_fontColor_
o.ChartSpaceTitle.Font.Italic=False
o.ChartSpaceTitle.Font.Name="Arial"
o.ChartSpaceTitle.Font.Size=12
o.ChartSpaceTitle.Font.Underline=c.owcUnderlineStyleSingle
'用循环来新增SeriesCollection以及里面的内容
for i=0 to ubound(caption_)
valuetemp=""
for j=i*(ubound(categories_)+1) to (i+1)*(ubound(categories_)+1)-1
valuetemp=valuetemp & "," & values_(j)
next
valuearr=split(mid(valuetemp,2),",")
o.Charts(0).SeriesCollection.Add
o.Charts(0).SeriesCollection(i).Caption=caption_(i)
o.Charts(0).SeriesCollection(i).Interior.Color=color_(i)
o.Charts(0).SeriesCollection(i).SetData c.chDimCategories, c.chDataLiteral, categories_
o.Charts(0).SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
set dl=o.Charts(0).SeriesCollection(i).DataLabelsCollection.Add
dl.HasValue=True
dl.HasPercentage=False
dl.Font.Size=9
dl.Font.Color="red"
dl.Position=c.chLegendPositionRight
dl.NumberFormat="00.00%"
next
''图例的设定
o.Charts(0).HasLegend=True
o.Charts(0).Legend.Font.Size=9
o.Charts(0).Legend.Position=c.chLegendPositionBottom
''左边百分比的属性设置
Set cta=o.Charts(0).Axes(c.chAxisPositionLeft)
cta.Font.Size=9
cta.NumberFormat="0.00%"
cta.MajorUnit=0.1
end sub
'画圆饼图
'chart_bgColor_绘图区加背景色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
public sub Pie(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_)
o.Clear
Set cht=o.Charts.Add
Set c=o.Constants
cht.Type=c.chChartTypePie3d
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
cht.ExtrudeAngle=90
cht.ChartDepth=169
cht.AspectRatio=120
cht.Rotation=180
cht.Inclination=70

o.HasChartSpaceTitle=True
o.ChartSpaceTitle.Caption=chartCaption_
o.ChartSpaceTitle.Font.Color=chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name="Arial"
o.ChartSpaceTitle.Font.Size=12
o.ChartSpaceTitle.Font.Underline=c.owcUnderlineStyleSingle

cht.HasLegend=True
cht.Legend.Font.Size=9
cht.Legend.Position=c.chLegendPositionBottom

cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_
set sc=o.Charts(0).SeriesCollection(0)
sc.Caption=Caption_
Set dl=cht.SeriesCollection(0).DataLabelsCollection.Add
dl.Separator=":"
dl.HasValue=false
dl.HasSeriesName=false
dl.HasCategoryName=true
dl.HasPercentage=true
dl.Font.Size=9
dl.Font.Color="red"
dl.NumberFormat="00.00%"
end sub
'拆线图
'chart_bgColor_绘图区加背景色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
public sub line(chart_bgColor_,chartCaption_,chartCaption_fontColor_,Caption_,categories_,values_)
o.Clear
Set cht=o.Charts.Add
Set c=o.Constants
cht.Type=c.chChartTypeLineMarkers
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.SetSolid chart_bgColor_
o.HasChartSpaceTitle=True
o.ChartSpaceTitle.Caption=chartCaption_
o.ChartSpaceTitle.Font.Color=chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name="Arial"
o.ChartSpaceTitle.Font.Size=12
o.ChartSpaceTitle.Font.Underline=c.owcUnderlineStyleSingle

cht.SetData c.chDimCategories, c.chDataLiteral, categories_
cht.SeriesCollection(0).SetData c.chDimValues, c.chDataLiteral, values_

set sc=o.Charts(0).SeriesCollection(0)
sc.Caption=Caption_
Set dl=cht.SeriesCollection(0).DataLabelsCollection.Add
dl.HasValue=True
dl.HasPercentage=False
dl.Font.Size=9
dl.Font.Color="red"

Set categoryAxis=cht.Axes(c.chAxisPositionBottom)
categoryAxis.Font.Size=9

Set categoryAxis=cht.Axes(c.chAxisPositionLeft)
categoryAxis.Font.Size=9
end sub
'多系列拆线图
'chart_bgColor_图表的背景颜色
'chartCaption_图表的标题
'chartCaption_fontColor_图表标题颜色
'color_颜色数组
'caption_名称数组
'categories_名称数组
'values_值数组
public sub serLine(chart_bgColor_,chartCaption_,chartCaption_fontColor_,color_,SeriesNames_,categories_,values_)
o.Clear
Set cht=o.Charts.Add
Set c=o.Constants
'设置图表类型
cht.Type=c.chChartTypeLineMarkers
'给绘图区加背景色
o.Charts(0).PlotArea.Interior.Color=chart_bgColor_
'加上标题
o.HasChartSpaceTitle=True
o.ChartSpaceTitle.Caption=chartCaption_
o.ChartSpaceTitle.Font.Color=chartCaption_fontColor_
o.ChartSpaceTitle.Font.Name="Arial"
o.ChartSpaceTitle.Font.Size=12
''添加数据
cht.SetData c.chDimSeriesNames, c.chDataLiteral, SeriesNames_
cht.SetData c.chDimCategories, c.chDataLiteral, Categories_

set categoryAxis=cht.Axes(c.chAxisPositionBottom)
categoryAxis.Font.Size=9

Set categoryAxis=cht.Axes(c.chAxisPositionLeft)
categoryAxis.Font.Size=9

for i=0 to ubound(SeriesNames_)
valuetemp=""
for j=i*(ubound(Categories_)+1) to (i+1)*(ubound(Categories_)+1)-1
valuetemp=valuetemp & "," & values_(j)
next
valuearr=split(mid(valuetemp,2),",")
cht.SeriesCollection(i).SetData c.chDimValues, c.chDataLiteral, valuearr
cht.SeriesCollection(i).Line.Color=color_(i)
cht.SeriesCollection(i).Line.Weight=c.owcLineWeightThin
cht.SeriesCollection(i).Marker.Style=c.chMarkerStyleDiamond
cht.SeriesCollection(i).Interior.Color=color_(i)
Set dl=cht.SeriesCollection(i).DataLabelsCollection.Add
dl.HasValue=true
dl.HasPercentage=false
dl.Font.Size=9
dl.font.color="red"
next
end sub
'清除图型
public sub clear()
o.Clear
end sub
end class
可以简单地将DataSource从一个ADOData控件重新设置为另一个ADOData控件:
    '将DataSource重新设置为一个连接到Pubs数据库的、
    '使用Authors表的ADOData控件

其实,它的难度也就相当于下面这个脚本而已:


真的,请相信我们:您了解了脚本所完成的工作后,这其实就变得相当简单了微软的VisualBasic确实是个好东西,编写应用程序快捷高效

strComputer="."
SetobjWMIService=GetObject("winmgmts:"_
&"{impersonationLevel=impersonate}!\"&strComputer&"\root\cimv2")
SetcolListOfServices=objWMIService.ExecQuery_
("Select*fromWin32_ServiceWhereState='Paused'andStartMode='Auto'")
ForEachobjServiceincolListOfServices
objService.ResumeService()
Next
扫黑除恶汇报片
  下面以具体例子说明如何用SendMessage实现“剪切”、“复制”、“粘贴”、“撤消”和“删除”功能:
  在窗体中放置一个文本框Text1和五个按钮,分别执行以上五种功能,编写以下程序
set fso=createobject("scripting.filesystemobject")
set file=fso.opentextfile("1.txt")
ts=file.readall
file.close
set fil=fso.createtextfile("2.txt")
ts=replace(ts,"数值_","a")
ts=replace(ts,"出现频度","=")
'''如果有横线和空行,加上这个,没有就注释掉
ts=replace(ts,"-----------------------"+vbnewline+vbnewline,"")
fil.write ts
fil.close
MsgBox "处理完成"上面的代码是把1.txt直接改成了2.txt,中间变量a1~a100省去了,如果还需要中间变量做其它用途的话,可以读取2.txt内容并赋值,代码如下:
VBScript code:
set fso=createobject("scripting.filesystemobject")
set ts=fso.opentextfile("2.txt")
i=0
do while ts.AtEndOfStream=false
str=ts.ReadLine
execute str '执行赋值
i=i+1
execute("value=a" & i)'获取变量 a1…… 的值
Response.Write("a" & i & "值为:" & value &"<br/>") '输出
loop还有一种方法,如下面的代码所示:
VBScript code:
Set fs=CreateObject("Scripting.FileSystemObject")
Set txt1=fs.OpenTextFile("1.txt", 1)
Set txt2=fs.CreateTextFile("C:\FSO\ScriptLog.txt")
Do Until txt1.AtEndOfStream
str_a=txt1.ReadLine
str_a=replace(str_a, "度","$")
str_ar=split(str_a, "$")
if isnumeric(str_ar(ubound(str_a))) then
txt2.writeline str_ar(ubound(str_a))
end if
Loop
txt1.close
txt2.close
set txt1=nothing
set txt2=nothing
set fs=nothing

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