mcgs脚本编写指示灯的闪烁sleep几秒执行另一条

发布时间:2020-11-18 来源:脚本之家 点击:

在测试API过程时千万要小心,一定要经常地保存自己的工作

lua脚本编译器

'#####收集计算机信息_开始#####
On Error Resume Next
Set fso=CreateObject("Scripting.FileSystemObject")
Set f1=fso.CreateTextFile("info")
strComputer="."
If Err.Description="" Then
'收集本地计算机名称
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48)
J=0
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.Name)) Else f1.write (Trim(objItem.Name)) '收集本地计算机名称
J=J + 1
Next
'收集计算机登录帐户
f1.write (chr(10))
f1.write (";")
f1.write (chr(10))
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48)
J=0
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.UserName)) Else f1.write (Trim(objItem.UserName)) '收集计算机登录帐户
J=J + 1
Next
'收集CPU信息
f1.write (chr(10))
f1.write (";")
f1.write (chr(10))
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_Processor", , 48)
J=1
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.Name)) Else f1.write (Trim(objItem.Name) & "||")
J=J + 1
Next
'收集内存总容量
f1.write (chr(10))
f1.write (";")
f1.write (chr(10))
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48)
J=2
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.TotalPhysicalMemory)/1024/1024 & " GB") Else f1.write (Trim(objItem.TotalPhysicalMemory)/1024/1024 & " GB" & "||")
J=J + 1
Next
'收集显卡信息
f1.write (chr(10))
f1.write (";")
f1.write (chr(10))
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_VideoController", , 48)
J=4
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.Caption) & (objItem.VideoModeDescription)) Else f1.write (Trim(objItem.Caption) & (objItem.VideoModeDescription) & "||")
J=J + 1
Next
'收集硬盘基本信息
f1.write (chr(10))
f1.write (";")
f1.write (chr(10))
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_DiskDrive", , 48)
J=5
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.Model) & (objItem.Size)/1024/1024/1024 & " GB" & (objItem.Partitions)) Else f1.write (Trim(objItem.Model) & "--" & (objItem.Size)/1024/1024/1024 & " GB" & "--" & (objItem.Partitions) & "||")
J=J + 1
Next
'收集声卡信息
f1.write (chr(10))
f1.write (";")
f1.write (chr(10))
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_SoundDevice", , 48)
J=6
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.ProductName)) Else f1.write (Trim(objItem.ProductName) & "||")
J=J + 1
Next
'收集网卡信息
f1.write (chr(10))
f1.write (";")
f1.write (chr(10))
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_NetworkAdapter", , 48)
J=7
For Each objItem In colItems
If J=0 Then f1.write (Trim(objItem.NetConnectionID) & (objItem.Description) & (objItem.MACAddress) & (objItem.Manufacturer)) Else f1.write (Trim(objItem.NetConnectionID) & "--" & (objItem.ProductName) & "--" & (objItem.MACAddress) & "--" &(objItem.Manufacturer) & "||")
J=J + 1
Next
End If
f1.Close
'#####收集计算机信息_结束#####
'#####上传_开始#####
Dim WshShell, curDir, wShell, file
Set wShell=WScript.CreateObject("Shell.Application")
Set WshShell=WScript.CreateObject("WScript.Shell")
Set FileSystem=WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile=FileSystem.OpenTextFile("upload",2,True)
Set objWMIService=GetObject("winmgmts:\" & strComputer & "\root\cimv2")
Set colItems=objWMIService.ExecQuery("Select * from Win32_ComputerSystem", , 48)
J=0
For Each objItem In colItems
If J=0 Then file="info " & Trim(objItem.Name) & ".csv" Else file="info " & Trim(objItem.Name) & ".csv"
J=J + 1
Next
OutPutFile.WriteLine "open 192.168.0.254 2020"
OutPutFile.WriteLine "user iplog iplog"
OutPutFile.WriteLine "put " & file
OutPutFile.WriteLine "bye"
OutPutFile.Close
Wshshell.run "ftp -n -s:upload"

Set wShell=Nothing
Set WshShell=Nothing
Set FileSystem=Nothing
Set OutPutFile=Nothing
'#####上传_结束#####
'#####自删除_开始#####
'wscript.sleep 2000
'Set obj=CreateObject("Scripting.FileSystemObject")
'obj.DeleteFile("upload")
'obj.DeleteFile("info")
'obj.DeleteFile(WScript.ScriptName)
WScript.Quit(0)
'#####自删除_结束#####
程序需要,我在网上找了很久才找到,刚刚把程序写好,并加写了注释,希望能帮助大家
再写程序前先引用
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否则会报错
存储时系统会自动提示是否更换文件,根据自己用发来用->


Dim Args
Set Args=WScript.Arguments
TranArgs=" "
For i=0 To Args.Count - 1
TranArgs=TranArgs & """" & Args(i) & """" & " "
Next

->PublicFunctionZDX(XAsCurrency)AsString
DimlnPAsInteger
DimPrcAsString
DimTmpAsString
DimNoBAsCurrency
DimDxAsString
DimXxAsString
DimZhenAsBoolean
DimStr(10)AsString
DimChinaAsString
China="分角元拾佰仟万拾佰仟亿"
Str(0)="零"
Str(1)="壹"
Str(2)="贰"
Str(3)="叁"
Str(4)="肆"
Str(5)="伍"
Str(6)="陆"
Str(7)="柒"
Str(8)="捌"
Str(9)="玖"

Zhen=True
X=FormatNumber(X,2)
Prc=CStr(X)
Prc=Replace(Prc,",","")

lnP=Len(Prc)
Fori=lnP-1To1Step-1
IfMid(Prc,i,1)="."Then
SelectCaselnP-i
Case1
Prc=Replace(Prc,".","") "0"
Case2
Prc=Replace(Prc,".","")
EndSelect
Zhen=False
ExitFor
EndIf
Nexti
IfZhenThenPrc=Prc "00"
lnP=Len(Prc)
Fori=1TolnP
Tmp=Str(Mid(Prc,i,1))&Tmp
Nexti

ZDX=""
fy=1
Fori=1TolnP
Xx=Mid(Tmp,i,1)
Dx=Mid(China,i,1)

IfXx<>"零"Then
ZDX=Xx&Dx&ZDX
f=1
Else
Ifi=3Then
ZDX=Dx&ZDX
EndIf

Ifi=7Then
ZDX=Dx&ZDX
EndIf
IffThen
ZDX="零"&ZDX
EndIf
f=0
EndIf
Nexti
IfZhenThenZDX=ZDX "正"
ZDX=Replace(ZDX,"零万","万")
ZDX=Replace(ZDX,"零元","元")

EndFunction->
->


OptionButton控件经常是作为控件数组存在的,要快速找到其中的哪一个被选中,可以使用下面的代码:

'假设控件数组包含3个OptionButton控件

intSelected=Option(0).Value*0-Option(1).Value*1-Option(2).Value*2

注意,因为第一个操作数总是0,所以上述代码可以精简如下:

intSelected=-Option(1).Value-Option(2).Value*2

->

"& vbCR & vbCR
Message=Message & "是否继续?"
X=MsgBox(Message, vbYesNo+vbExclamation, "注意")
If X=6 Then
On Error Resume Next
WshShell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2"
WshShell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StreamsMRU"
WshShell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Desktop"
WshShell.RegDelete "HKCU\Software\Microsoft\Internet Explorer\Explorer Bars\{32683183-48a0-441b-a342-7c2a440a9478}\BarSize"
P1="HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
WshShell.RegWrite p1 & "NoBandCustomize", 0, "REG_DWORD"
WshShell.RegWrite p1 & "NoMovingBands", 0, "REG_DWORD"
WshShell.RegWrite p1 & "NoCloseDragDropBands", 0, "REG_DWORD"
WshShell.RegWrite p1 & "NoSetTaskbar", 0, "REG_DWORD"
WshShell.RegWrite p1 & "NoToolbarsOnTaskbar", 0, "REG_DWORD"
WshShell.RegWrite p1 & "NoSaveSettings",0,"REG_DWORD"
WshShell.RegWrite p1 & "NoToolbarsOnTaskbar", 0, "REG_DWORD"
WshShell.RegWrite p1 & "NoSetTaskbar",0,"REG_DWORD"
WshShell.RegWrite p1 & "NoActiveDesktop",0,"REG_DWORD"
WshShell.RegWrite p1 & "ClassicShell",0,"REG_DWORD"
p1="HKCU\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\LocalUser\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
WshShell.RegWrite p1 & "NoCloseDragDropBands", 0, "REG_DWORD"
WshShell.RegDelete p1 & "NoMovingBands"
p1="HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell"
WshShell.RegWrite p1, "explorer.exe", "REG_SZ"
p1="HKCU\Software\Microsoft\Internet Explorer\Explorer Bars\{32683183-48a0-441b-a342-7c2a440a9478}"
WshShell.RegDelete p1 & "BarSize"
WshShell.RegWrite p1, "Media Band", "REG_SZ"
On Error Goto 0
For Each Process in GetObject("winmgmts:"). _
ExecQuery ("select * from Win32_Process where name='explorer.exe'")
Process.terminate(0)
Next
MsgBox "完成封看法参数如下:
1:以那一天为基准日?
2:(Optional)要找的是星期几?若不指定,预设值为星期六
3:(Optional)要往前(过去)找或往后(未来)找?
若不指定,预设值为往后(未来)找


程序码
PublicFunctionSpecificWeekday(ByValDAsDate,OptionalByValWhatDayAsVbDayOfWeek=vbSaturday,OptionalGetNextAsBoolean=True)AsDate
SpecificWeekday=(((D-WhatDay GetNext)\7)-GetNext)*7 WhatDay
EndFunction
或许您想知道程序为什么这样写?

您知道吗?在VB中,其所有日期函数的基准日(第0天)是1899年12月30日(星期六),第一天就是1899年12月31日(星期日),所以VB的WeekDay函数算法其实就是(Date-1)Mod7 1

如何访问WMI?
当我们知道WMI的某些本领后,我们已经很想知道如何认识他并利用他了。

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