' IELOGIN3.VBS is a modified version of my IELOGIN2.VBS, which, in turn, ' was a modified version of IELOGIN.VBS. ' In this version, Denis St-Pierre added error handling code to prevent an ' error message if users close the dialog with the upper right "X" or Alt+F4. ' The output of IELOGIN3.VBS (and IELOGIN2.VBS) is meant to be used in a ' batch file, using the following batch code (note: the white space following ' delims= is a tab) or something similar: ' ' FOR /F "tokens=1,2 delims= " %%A IN ('CSCRIPT //NoLogo IELOGIN3.VBS') DO ( ' SET Name=%%~A ' SET Password=%%~B ' ) ' ECHO The password of %Name% is %Password% Option Explicit Dim arrLogin arrLogin = IELogin( ) WScript.Echo """" & arrLogin(0) & """" & vbTab & """" & arrLogin(1) & """" Function IELogin( ) ' This function uses Internet Explorer to create a login dialog. ' ' Version: 3.10 ' Last modified: 2010-09-28 ' ' Arguments: N/A ' Returns: [array] the user name (0) and password (1) ' typed in the dialog screen ' ' Written by Rob van der Woude ' http://www.robvanderwoude.com ' Error handling code written by Denis St-Pierre Dim objIE ' Create an IE object Set objIE = CreateObject( "InternetExplorer.Application" ) ' specify some of the IE window's settings objIE.Navigate "about:blank" objIE.Document.Title = "Login" & String( 80, "." ) objIE.ToolBar = False objIE.Resizable = False objIE.StatusBar = False objIE.Width = 320 objIE.Height = 180 ' Center the dialog window on the screen With objIE.Document.ParentWindow.Screen objIE.Left = (.AvailWidth - objIE.Width ) \ 2 objIE.Top = (.Availheight - objIE.Height) \ 2 End With ' Wait till IE is ready Do While objIE.Busy WScript.Sleep 200 Loop ' Insert the HTML code to prompt for user input objIE.Document.Body.InnerHTML = "
| Name: | " _ & " |
| Password: | " _ & "" & vbcrlf _ & " |
" _ & "