2

I'm writing a VB Script code, as part of cimplicity object. The code basically need to open IE with a specific URL and autologin to the webpage. The login is a "windows security" popup window. Can i log in to it pragmatically? enter image description here

Here is a part of my code:

On Error GoTo ERR_TRP
Dim IE
Dim UID As CimObjectVariable
Dim PWD As CimObjectVariable
Dim URL As CimObjectVariable

Dim sUID As String
Dim sPWD As String
Dim sURL As String

Set UID = CimGetScriptOwner().GetVariable("USER")
Set PWD = CimGetScriptOwner().GetVariable("PWD")
Set URL = CimGetScriptOwner().GetVariable("IP")
sUID = UID.Value
sPWD = PWD.Value
sURL = URL.Value
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1 
IE.navigate sURL
Sleep(1000)

Err_Trp:
    x = MSGBOX ("Cannot open the camera Please check User-Password-IP", 0 , "Eror")
2
  • Dim ... As won't work in VBS, all variables in VBS has Variant type. Just use Dim without As. Could you share the URL which gives you such popup window (or any similar)? Commented Mar 16, 2015 at 23:59
  • Sorry, i can't share it. This is company's internal URL Commented Mar 18, 2015 at 6:17

1 Answer 1

1

as omegastripes wrote, you can't declare variable data-types in VBS, however to send the username/password to the popup login window after navigating to the page use this code:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Windows Security"
WshShell.SendKeys "YourUserID"
WScript.Sleep 100
WshShell.SendKeys "{TAB}" 
WScript.Sleep(100)
WshShell.SendKeys "YourPassword"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{ENTER}"
Sign up to request clarification or add additional context in comments.

3 Comments

Just one question, how can i bring the IE page on top of my application?
WshShell.AppActivate IE.Name
Thanks a lot. Another question: can i ask "if the windows security is activated then perform the login"? Because not for all of the URLs there is a log in

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.