batch-file - Windows security log-in using batch file
问题描述
I want to open a page using batch command file so that I can schedule it to open once per day. My problem is: to go to the page, I need to enter my windows access manually.
Is there any way to automatically type username and password using batch file?
My current batch script:
@echo off
start/min iexplore http://server/SEMs/Actions/SendNotifications.aspx
timeout 5
taskkill /fi "WindowTitle eq SEMsNotification - Internet Explorer"
解决方案
我找到了一个解决方案,使用此代码自动插入我的用户名和密码。
@if (@CodeSection == @Batch) @then
@echo off
set SendKeys=CScript //nologo //E:JScript "%~F0"
start "" /B cmd
timeout 5
set /P "= Typing password: " < NUL
%SendKeys% "MyUsername{TAB}"
%SendKeys% "MyPassword{ENTER}"
timeout 5
@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
它只是简单地输入文本,“tab”和“enter”到活动文本框。
我使用“超时”来延迟页面加载,并使用“SendKeys/CScript”作为我的输入。
但我仍在寻找最佳答案。
推荐阅读
- android - android WebView 内容滚动时如何停止触摸事件?
- reactjs - 发生意外错误:“EISDIR:对目录的非法操作,已读取”
- ios - SwiftUI 拖动以关闭 ScrollView
- java - 抑制使用 JsonFormat 注释的 LocalDate 字段的 InvalidFormatException/反序列化异常
- gitlab - gitlab k3s runner WARNING: Checking for jobs... failed x509: certificate signed by unknown authority
- javascript - VueJS i18n 路由 404 页面
- c# - MongoDB C# - 通过嵌套数组中的 contiditon 过滤 findig 对象
- sql - SQL - 修复加入问题
- mysql - 从查询到子查询的组中未选择的值
- r - 这种赔率/偶数提取如何在 R 语言中工作?