' Just an example of how to use the function ' wsh.echo "You entered: ", _ Join(PasswordBox("Enter UID and password", _ "Testing"), ", ") ' A function to present a Password dialog in a VBS (WSF) ' script ' Requires WScript version 5.1+ ' Tom Lavedas ' with help from and thanks to Joe Ernest and ' Michael Harris ' ' modified 1/2008 to handle IE7 ' Function PasswordBox(sPrompt, sDefault) set oIE = CreateObject("InternetExplorer.Application") With oIE ' Configure the IE window .RegisterAsDropTarget = False .statusbar = false : .toolbar = false .menubar = false : .addressbar = false .Resizable = False .Navigate "about:blank" Do Until .ReadyState = 4 : WScript.Sleep 50 : Loop ' Test for IE 7 - cannot remove 'chrome' in that version sVersion = .document.parentWindow.navigator.appVersion if instr(sVersion, "MSIE 7.0") = 0 Then .FullScreen = True .width = 400 : .height = 270 ' Create the password box document With .document oIE.left = .parentWindow.screen.width \ 2 - 200 oIE.top = .parentWindow.screen.height\ 2 - 100 .open .write "<" & "script>bboxwait=true;Password _"_ & "
" _ & "
" _ & " " & sPrompt & " 

" _ & "
" _ & " User:" _ & "" _ & "
Password:" _ & "" _ & "

" _ & "  

" .close Do Until .ReadyState = "complete" : WScript.Sleep 100 : Loop .all.user.focus .all.user.select ' Optional oIE.Visible = True CreateObject("Wscript.Shell")_ .Appactivate "Password _" PasswordBox = Array("CANCELLED") On Error Resume Next Do While .parentWindow.bBoxWait if Err Then Exit Function WScript.Sleep 100 Loop oIE.Visible = False PasswordBox = Array(.all.user.value, _ .all.pass.value) End With ' document End With ' IE End Function