[Server 2003] 请教一个vbs脚本问题

weixin_38051012 2008-08-22 06:44:56

从网上找了个脚本,自动添加tsmmc的远程桌面列表,但是里面没有域那一项,手动改了下,却发现,偶尔可以执行成功,很多时候执行不了,也没有错误提示。代码如下:Set WshShell = WScript.CreateObject(\"WScript.Shell\")
WshShell.run(\"%SystemRoot%\\system32\\tsmmc.msc /s\")
WScript.Sleep 2000

Dim ip(100)
\'ip(0)=Array(\"服务器远程桌面IP\",\"服务器远程桌面用户名\",\"服务器远程桌面密码\",\"服务器远程桌面网域\")
ip(0)=Array(\"192.168.100.6\",\"administrator\",\"abc123\",\"domain\")
ip(1)=Array(\"192.168.100.7\",\"administrator\",\"abc123\",\"domain\")
ip(2)=Array(\"192.168.100.11\",\"administrator\",\"abc123\",\"domain\")
ip(3)=Array(\"192.168.100.16\",\"administrator\",\"abc123\",\"domain\")
ip(4)=Array(\"192.168.100.17\",\"administrator\",\"abc123\",\"domain\")
ip(5)=Array(\"192.168.100.18\",\"administrator\",\"abc123\",\"domain\")
ip(6)=Array(\"192.168.100.19\",\"administrator\",\"abc123\",\"domain\")
ip(7)=Array(\"192.168.100.20\",\"administrator\",\"abc123\",\"domain\")
ip(8)=Array(\"192.168.100.21\",\"administrator\",\"abc123\",\"domain\")
ip(9)=Array(\"192.168.100.31\",\"administrator\",\"abc123\",\"domain\")
ip(10)=Array(\"192.168.100.32\",\"administrator\",\"abc123\",\"domain\")
ip(11)=Array(\"192.168.100.34\",\"administrator\",\"abc123\",\"domain\")
ip(12)=Array(\"192.168.100.60\",\"administrator\",\"abc123\",\"domain\")
ip(13)=Array(\"192.168.100.66\",\"administrator\",\"abc123\",\"domain\")
ip(14)=Array(\"192.168.100.85\",\"administrator\",\"abc123\",\"domain\")
ip(15)=Array(\"192.168.100.100\",\"administrator\",\"abc123\",\"domain\")
ip(16)=Array(\"192.168.100.101\",\"administrator\",\"abc123\",\"domain\")
ip(17)=Array(\"192.168.3.150\",\"administrator\",\"abc123\",\"domain\")
ip(18)=Array(\"192.168.100.189\",\"administrator\",\"abc123\",\"domain\")
ip(19)=Array(\"192.168.3.190\",\"administrator\",\"abc123\",\"domain\")
ip(20)=Array(\"192.168.3.191\",\"administrator\",\"abc123\",\"domain\")
ip(21)=Array(\"192.168.100.210\",\"administrator\",\"abc123\",\"domain\")
ip(22)=Array(\"192.168.100.238\",\"administrator\",\"abc123\",\"domain\")
ip(23)=Array(\"192.168.3.100\",\"administrator\",\"abc123\",\"domain\")


For i=0 To 23
        WshShell.SendKeys \"+{F10}\"  
        WshShell.SendKeys \"A\"      
        WshShell.SendKeys ip(i)(0)  
        WshShell.SendKeys \"{TAB}\"   
        WshShell.SendKeys \"{TAB}\"   
        WshShell.SendKeys \"{TAB}\"   
        WshShell.SendKeys \"{TAB}\"   
        WshShell.SendKeys ip(i)(1)  
        WshShell.SendKeys \"{TAB}\"     
        WshShell.SendKeys ip(i)(2)
        WshShell.SendKeys \"{TAB}\"     
        WshShell.SendKeys ip(i)(3)
        WshShell.SendKeys \"{TAB}\"
        WshShell.SendKeys \"{ }\"
        WshShell.SendKeys \"{ENTER}\"
Next    复制代码在网上找到的源码如下:  1. \'/*=========================================================================  
   2. \' * Intro       解决win2003远程桌面连接多台服务器时,重做系统后还得一个一个得加半天。效率非常低的问题  
   3. \' * FileName    批量添加远程桌面.vbs  
   4. \' * Author      yongfa365  
   5. \' * Version     v1.0  
   6. \' * WEB         http://www.yongfa365.com  
   7. \' * Email       yongfa365[at]qq.com  
   8. \' * FirstWrite  http://www.yongfa365.com/Item/PiLiangTianJiaYuanChengZhuoMian.vbs.html  
   9. \' * MadeTime    2007-11-29 00:46:30  
  10. \' * LastModify  2007-11-29 00:46:30  
  11. \' *==========================================================================*/  
  12.   
  13. Set WshShell = WScript.CreateObject(\"WScript.Shell\")  
  14. WshShell.run(\"%SystemRoot%\\system32\\tsmmc.msc /s\")   
  15. WScript.Sleep 3000  
  16.   
  17. Dim ip(100)  
  18. \'ip(0)=Array(\"服务器远程桌面IP\",\"服务器远程桌面用户名\",\"服务器远程桌面密码\")  
  19. ip(0)=Array(\"100.110.111.112\",\"UserName0\",\"PassWord0\")  
  20. ip(1)=Array(\"111.222.111.121:3389\",\"UserName1\",\"PassWord1\")  
  21. ip(2)=Array(\"111.222.111.211:1234\",\"UserName2\",\"PassWord2\")  
  22. ip(3)=Array(\"111.222.111.222\",\"UserName3\",\"PassWord3\")  
  23.   
  24. For i=0 To 3  
  25.     WshShell.SendKeys \"+{F10}\"  
  26.     WshShell.SendKeys \"A\"  
  27.     WshShell.SendKeys ip(i)(0)  
  28.     WshShell.SendKeys \"{TAB}\"  
  29.     WshShell.SendKeys \"{TAB}\"  
  30.     WshShell.SendKeys \"{TAB}\"  
  31.     WshShell.SendKeys \"{TAB}\"  
  32.     WshShell.SendKeys ip(i)(1)  
  33.     WshShell.SendKeys \"{TAB}\"  
  34.     WshShell.SendKeys ip(i)(2)  
  35.     WshShell.SendKeys \"{ENTER}\"  
  36. Next  复制代码哪位朋友能告诉我,问题出在哪里?
...全文
浏览 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
其他技术讨论专区
创建于2021-05-12

120

社区成员

其他技术讨论专区
申请成为版主
帖子事件
创建了帖子
2008-08-22 06:44
社区公告
暂无公告