首页 > 解决方案 > 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.

Look at this photo:
photo

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"

标签: batch-filecmd

解决方案


我找到了一个解决方案,使用此代码自动插入我的用户名和密码。

@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”作为我的输入。

但我仍在寻找最佳答案。


推荐阅读