Automatic login to a website on windows 7/Chrome via batch file

后端 未结 2 1602
醉梦人生
醉梦人生 2020-12-10 05:47

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,

相关标签:
2条回答
  • 2020-12-10 06:08

    i tried above script for my website, but only able to see login page not able to put user name and password, need help

    @if (@CodeSection == @Batch) @then
    
    
    @echo off
    
    set SendKeys=CScript //nologo //C:JScript "%~F0"
    START iexplore.exe "www.gmail.com"
    timeout /t 5
    %SendKey% "USERNAME{TAB}"
    %SendKey% "PASSWORD{Continue}"
    
    goto :EOF
    
    
    @end
    // JScript section
    
    var WshShell = WScript.CreateObject("WScript.Shell");
    WshShell.SendKeys(WScript.Arguments(0))
    
    0 讨论(0)
  • 2020-12-10 06:10

    You can try the following code:

    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()
    

    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.

    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.

    0 讨论(0)
提交回复
热议问题