[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] 求个自动登录摄像头录像机的vbs脚本

最好是能设置一段ip,连续登录的。

回复 1# 窄口牛


    哪里的摄像头呢,办公室的CCTV吗,你手上有管理权限吗?
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

本帖最后由 窄口牛 于 2024-11-28 07:33 编辑

批量修改摄像头的显示名称,有时候录像机的国标协议需要批量修改。还有批量添加低权限的用户,避免不懂的人动坏了设置。

TOP

找深索写了一个,输入的交用户名提交不了,还是登录不上
[code][On Error Resume Next
' 定义摄像头列表,格式为:IP地址,用户名,密码
Dim cameras
cameras = Array("192.168.1.169,admin,12345")

' 遍历摄像头列表
For Each camera In cameras
    ' 分割字符串获取IP、用户名和密码
    Dim cameraInfo
    cameraInfo = Split(camera, ",")
    Dim ip, username, password
    ip = cameraInfo(0)
    username = cameraInfo(1)
    password = cameraInfo(2)

    ' 创建IE对象
    Dim ie
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.Navigate "http://" & ip
   
    ' 等待页面加载完成
    Do While ie.Busy Or ie.ReadyState <> 4
        WScript.Sleep 100
    Loop
   
    ' 确保页面元素加载完成
    On Error Resume Next ' 忽略错误,继续执行
    Dim maxRetries, retryCount
    maxRetries = 10
    retryCount = 0
   
    Do
        WScript.Sleep 1000 ' 等待1秒
        retryCount = retryCount + 1
    Loop Until (Not ie.Document.getElementById("username") Is Nothing And Not ie.Document.getElementById("password") Is Nothing) Or retryCount >= maxRetries
   
    On Error GoTo 0 ' 恢复错误处理
   
    ' 检查是否找到元素
    If ie.Document.getElementById("username") Is Nothing Or ie.Document.getElementById("password") Is Nothing Then
        MsgBox "无法找到登录元素,请检查页面结构或IP地址:" & ip
        ie.Quit
        WScript.Quit
    End If
   
    ' 输入用户名和密码
    ie.Document.getElementById("username").Value = username
    ie.Document.getElementById("password").Value = password
   
    ' 触发输入框的change和input事件(确保AngularJS等框架检测到输入)
    ie.Document.getElementById("username").FireEvent "onchange"
    ie.Document.getElementById("username").FireEvent "oninput"
    ie.Document.getElementById("password").FireEvent "onchange"
    ie.Document.getElementById("password").FireEvent "oninput"
   
    ' 查找登录按钮
    Dim loginButton
    Set loginButton = Nothing
    For Each btn In ie.Document.getElementsByTagName("button")
        ' 检查按钮内部是否包含 <em>登录</em>
        If Not btn.getElementsByTagName("em").Item(0) Is Nothing Then
            If btn.getElementsByTagName("em").Item(0).innerText = "登录" Then
                Set loginButton = btn
                Exit For
            End If
        End If
    Next
   
    ' 检查是否找到登录按钮
    If loginButton Is Nothing Then
        MsgBox "无法找到登录按钮,请检查页面结构或IP地址:" & ip
        ie.Quit
        WScript.Quit
    End If
   
    ' 点击登录按钮
    loginButton.Click
   
    ' 等待登录完成
    Do While ie.Busy Or ie.ReadyState <> 4
        WScript.Sleep 100
    Loop
   
    ' 检查是否登录成功
    If InStr(ie.Document.body.innerHTML, "请输入用户名") > 0 Then
        MsgBox "登录失败:请输入用户名。请检查用户名和密码是否正确。"
    Else
        MsgBox "登录成功!"
    End If
   
    ' 关闭IE窗口
    'ie.Quit
Next

MsgBox "所有摄像头登录完成!"/code]

TOP

  1. ' 定义用户名和密码
  2. username = "用户名"
  3. password = "密码"
  4. ' 定义IP地址范围
  5. IP_First = 16
  6. IP_Last = 18
  7. IP_Range = "192.168.1."
  8. ' 遍历IP范围
  9. For i = IP_First To IP_Last
  10. currentIP = IP_Range & i
  11.     Set ie = CreateObject("InternetExplorer.Application")
  12.     ie.FullScreen = 0
  13.     ie.Visible = True
  14.     ie.Navigate "http://" & currentIP & "/dispatch.asp?user=" & username & "&pass=" & password & "&page=preview.asp"
  15. WScript.Echo currentIP & " 正在打开,请在打开下一个后再关闭前一个."
  16.     ' 释放对象
  17.     Set ie = Nothing
  18. Next
复制代码

TOP

返回列表