通过批处理文件自动登录到 Windows 7/Chrome 上的网站 [英] Automatic login to a website on windows 7/Chrome via batch file

查看:31
本文介绍了通过批处理文件自动登录到 Windows 7/Chrome 上的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理文件.我有案例选择.如果用户键入 26,它将打开链接 1 chrome.如果用户输入 27,它将在 chrome 中打开链接 2.

I have a batch file. I have case select. if user types 26 it will open link 1 chrome. if user types 27 it will open link 2 in chrome.

但是我还是想不通,如何用用户名和密码自动批量登录网站.

But I still can't figure out, how can I make batch login automatically into website with username and password.

我在谷歌上寻找这样的脚本,但没有找到任何有用的东西.我知道一点 C++,unix,(还有一些 html 和 java 脚本)我不知道是否可以使用这些语言在 windows 机器上完成,但即使可以完成,我认为与 VB 或C## 或其他一些高级语言.

I looked for such a script on the google but didn't find anything useful. I know a bit of C++, unix,(also some html and java script) I don't know if it can be done on windows machine using these languages but even if it could be done I think it would be difficult compared to VB or C## or some other high level languages.

我学会了如何使用包含在 bat 文件中的基本 Windows 批处理命令打开多个站点,例如:

I learned how to open multiple sites using basic windows batch commands enclosed in a bat file like:

start chrome.exe http://yahoo.com
start chrome.exe http://www.google.tv

但我仍然不知道单击 bat 文件实际上如何帮助我登录网站,甚至无需输入用户名和密码.

But still I can't figure out how would actually a click on the bat file would help me to login to the sites also without even typing the username and password.

我需要开始学习 VB(visual basic)、dot net 或 windows 批处理编程才能做到这一点.这太难了.. 请帮忙.

Do I need to start learning VB(visual basic),dot net, or windows batch programming to do this.is this so dificult.. Please help.

推荐答案

可以试试下面的代码:

set WshShell = WScript.CreateObject("WScript.Shell")
call WshShell.Run("http://www.gmail.com", 1, false) 'This will open your default browser

WScript.Sleep 2000
WshShell.SendKeys "username"
WScript.Sleep 1000
WshShell.SendKeys "{TAB}"
WScript.Sleep 1000
WshShell.SendKeys "password"
WshShell.SendKeys "{TAB}"
WScript.Sleep 1000
WshShell.SendKeys "{ENTER}"
WScript.Quit()

代码打开浏览器,等待页面加载,然后输入用户名和密码,假设光标在右边的输入框中(例如,在Gmail中,它将是在用户名输入框中).否则,您必须使用 TAB 导航到正确的输入框.

The code opens your browser, waits for the page to load, and then enters the username and password assuming that the cursor is in the right input box (for example, in Gmail, it will be on the username input box). Else you have to navigate to the right input box by using TAB.

如果您反对在脚本文件中写入密码,请将其保存在浏览器中并使用适当的 SendKeys 方法登录.

If you are against writing the password in the script file, save it on you browser and use the appropriate SendKeys method for logging in.

这篇关于通过批处理文件自动登录到 Windows 7/Chrome 上的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆