Vbscript 登录到网站登录名和密码

Vbscript 登录到网站登录名和密码,vbscript,Vbscript,我尝试创建一个VBS脚本,它自动启动了一个网站。这部分我可以解决。 但是现在我需要在这个脚本中输入函数login作为 这就是我一直被绊倒的原因 所以我希望你能帮助我。 这是我打开网站的脚本 Dim objExplorer Set objExplorer = WScript.CreateObject("InternetExplorer.Application") Do While (objExplorer.Busy) Wscript.Sleep 250 Loop objExplo

我尝试创建一个VBS脚本,它自动启动了一个网站。这部分我可以解决。 但是现在我需要在这个脚本中输入函数login作为 这就是我一直被绊倒的原因

所以我希望你能帮助我。 这是我打开网站的脚本

Dim objExplorer


 Set objExplorer = WScript.CreateObject("InternetExplorer.Application")

 Do While (objExplorer.Busy)
 Wscript.Sleep 250
 Loop

 objExplorer.TheaterMode = False
 objExplorer.AddressBar = True
 objExplorer.MenuBar = True
 objExplorer.StatusBar = True
 objExplorer.ToolBar = False
 objExplorer.Resizable = True


 objExplorer.Height = 600
 objExplorer.Width = 800
 objExplorer.Left = 0
 objExplorer.Top = 0
 ' objExplorer.FullScreen = True
 objExplorer.Silent = False
 objExplorer.Visible = True


 objExplorer.Navigate https://mi-xxxxx-xxx-xxxxx.xxx.com/xxxxxxxxxxxxx/login.aspx

objExplorer.Login = User
ObjExplorer.Password = Password

 wscript.sleep 6000

Set objShell = CreateObject("Wscript.Shell")
 objShell.Run("taskkill /F /IM iexplore.exe /T")

 Set objExplorer = nothing
我希望有一个简单的方法来取得结果

非常感谢你在这件事上的帮助。 顺致敬意,
Martin

不要尝试通过GUI自动登录,而是尝试使用类似的方法检查登录过程。这将为您提供将凭据从客户端传递到服务器的实际请求。有了这些信息,您可以使用自动登录:

url = "https://mi-xxxxx-xxx-xxxxx.xxx.com/xxxxxxxxxxxxx/login.asp"

user = "..."
pass = "..."
credentials = "username=" & user & "&password=" & pass

Set req = CreateObject("Msxml2.XMLHttp.6.0")
req.open "POST", url, False
req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
req.send credentials

If req.status = 200 Then
  'login successful
Else
  'login failed
End If
您可能需要根据Fiddler显示的内容调整
url
credentials
字符串。您可能还需要对用户名和/或密码进行如下编码:

Function Encode(ByVal str)
  Set re = New RegExp
  re.Pattern = "[^a-zA-Z0-9_.~-]"

  enc = ""
  For i = 1 To Len(str)
    c = Mid(str, i, 1)
    If re.Test(c) Then c = "%" & Right("0" & Hex(Asc(c)), 2)
    enc = enc & c
  Next

  Encode = enc
End Function

我找到了一个很好的方法来达到需要的结果

WScript.Sleep 5000
WshShell.SendKeys "******"
WScript.Sleep 3000
WshShell.SendKeys "{TAB}"
WScript.Sleep 3000
WshShell.SendKeys "*********"
WshShell.SendKeys "{TAB}"
WScript.Sleep 3000
WshShell.SendKeys "{ENTER}"

wscript.sleep 10000
所以这个任务就解决了。 非常感谢你的命令。 顺致敬意,
马丁这是一个很好的建议。您是否知道任何不需要安装软件的替代方案?我所处的工作环境禁止安装软件,但我们仍然可以运行可执行文件。我很想将此合并到我已经存在的一些脚本中。@BHart否。您需要一个SSL代理来断开SSL连接,以便检查HTTPS请求。我认为在没有管理员权限的情况下不可能设置这样的东西!