|
楼主 |
发表于 2010-5-14 23:23
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
========保存下面代码为XXX.VBS
Set WshShell = WScript.CreateObject("WScript.Shell")
'WshShell.run("D:\VBS\tsmmc.msc /s")
WScript.Sleep 3000
dim oExcel,oWb,oSheet
Set oExcel= CreateObject("Excel.Application")
'VBS读取的表格路径,如果表带有密码的话请输入密码,没有请删除“密码”
Set oWb = oExcel.Workbooks.Open("E:\重要文档\工作表.xlsm",,,,"密码")
Set oSheet = oWb.Sheets("核心帐户")
dim i
dim stname,stip,stus,stpass,strCopy
For i=3 to 500
'读取计算机名;如果无计算机名则用IP替换
If oSheet.Range("A" & i).Value="" Then
stname=oSheet.Range("B" & i).Value
else
stname=oSheet.Range("A" & i).Value
End If
'读取IP
stip=oSheet.Range("B" & i).Value
'读取帐号;
stus=oSheet.Range("C" & i).Value
'读取密码;
stpass=oSheet.Range("D" & i).Value
if stip<>"" And stus<>"0" And stus<>"" Then
WScript.Sleep 300
WshShell.SendKeys "+{F10}"
WScript.Sleep 100
WshShell.SendKeys "A"
WScript.Sleep 100
WshShell.SendKeys stip
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
'这里将输入中文的服务器名
strCopy = stname
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
objIE.document.parentwindow.clipboardData.SetData "text", strCopy
objIE.Quit
WScript.Sleep 200
WshShell.SendKeys "^{V}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys stus
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys stpass
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "%{V}"
WScript.Sleep 100
WshShell.SendKeys "{ENTER}"
end if
Next
oExcel.WorkBooks.Close
oExcel.Quit
===========================
打开tsmmc.msc
运行VBS 然后让TSMMC至于顶层,VBS会自动倒入服务器信息到控制台 |
|