Solved

How to login to a web page w/credentials??

Posted on 2009-05-18
19
304 Views
Last Modified: 2012-05-07
I'm trying to login to a webpage locally on my netwrok with credentials using vbscript but am unable to open the page and set the focus tothe page to send my credentials, can someone help me solve this?

see pic

My script currently... not working

Const strURL = "192.168.1.50"
Const strID = "myuser"
Const strPswd = "mypass"
 
Set objIE = CreateObject( "InternetExplorer.Application" )
objIE.Visible = True
objIE.Navigate2 strURL
 
 
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.AppActivate "Connect to 192.168.1.50"
WScript.Sleep 1000
objShell.SendKeys strID
WScript.Sleep 100
objShell.SendKeys "{TAB}"
WScript.Sleep 100
objShell.SendKeys strPswd
WScript.Sleep 100
objShell.SendKeys "{ENTER}"

Set objIE = Nothing
Set objShell = Nothing

NG,
login.jpg
0
Comment
Question by:nike_golf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
19 Comments
 
LVL 13

Author Comment

by:nike_golf
ID: 24413871
Nobody's got any suggestions that's not good...??

NG,
0
 
LVL 3

Expert Comment

by:bleech677
ID: 24414536
I've been monitoring - wasn't goiing to say anything because I don't have a definite solution

check this out -  believe you need Server.CreateObject("MSXML2.XMLHTTP") vs trying to COM+ IE
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=170

Have you thought about using integrated authentication to bypass the login?
0
 
LVL 3

Expert Comment

by:bleech677
ID: 24414551
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 3

Expert Comment

by:bleech677
ID: 24414601
Also, I just realized that by the look of your login box it seems you have windows authentication - not forms authentication. That might be a problem with your approach. This is just a guess though
0
 
LVL 13

Author Comment

by:nike_golf
ID: 24415200
The login is actually for a network storage device so I'm not sure if that plays a role or not.

Since this is being accessed through a web browser why wouldn't it use the same objects... ?

NG,


0
 
LVL 3

Expert Comment

by:bleech677
ID: 24415332
I guess you can either use IE via com+ like you're doing then see:
http://www.eggheadcafe.com/articles/20011215.asp

Otherwise you need an XMLHttp object - kind of like you would use for AJAX - You don't need to use IE
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=170

But the non-forms authentication may pose a problem _ I'm not sure

Do you just need to login? What are you trying to accomplish? What if you use a batch file to login?
0
 
LVL 3

Expert Comment

by:bleech677
ID: 24415358
Does the NAS have a gui frontend where you can login via a form?
0
 
LVL 3

Expert Comment

by:bleech677
ID: 24415369
here is some background info on what IE does
http://support.microsoft.com/?id=258063
0
 
LVL 13

Author Comment

by:nike_golf
ID: 24415440
"What if you use a batch file to login? "

That would work for me as well, actually better.


"Does the NAS have a gui frontend where you can login via a form?"

Nope just a web interface.

0
 
LVL 3

Expert Comment

by:bleech677
ID: 24416069
>>Nope just a web interface.

Yea thats what I mean but it isn't a web form is it? Its just the pop up window - thats the problem I refer to

As for the batch file: if all you need is access to the files on the name - edit this then save to a batch file and run - you can map the drives on your machine this way - in this case I'm mapping the d:\somefolder directory on the the R: drive xcxYG7U is the password and the user is the local admin on the destination machine

net use r: \\192.28.251.35\d$\somefolder xcxYG7U /User:2003Web\Administrator
0
 
LVL 13

Author Comment

by:nike_golf
ID: 24416395
Here's my problem the NAS doesn't wake up. The mapping shows a red X but isn't available - however it wakes up when I log into it from the web so my plan is to script a login when I need to access it.

"Its just the pop up window - thats the problem I refer to "

Yes, when I hit the IP 192.168.1.50 since its static the login screen appears and waits for my credentials, for some reason it doesn't have the focus. So another option would be to set the focus to the form?

I thought you meant a batch file to open a webpage and use log in credentials... the above isn't going to work.

Thanks.

NG,
0
 
LVL 3

Expert Comment

by:bleech677
ID: 24420710
What model is the NAS? Are you just trying to login to get access to files? That does not seem right that you would have to log in to wake the device up - maybe there is something that has to be configured
0
 
LVL 13

Author Comment

by:nike_golf
ID: 24421338
Argosy 363N..

Yes, I agree not waking up is a huge issue for a NAS... actually its a paper weight at that point.

From a setup perspective all is good, it just doesn't wake up sometimes - sometimes it does. If it doesn't wake up sometimes unplugging / replugging the ethernet cable will get it to boot back up...

NG,
0
 
LVL 3

Expert Comment

by:bleech677
ID: 24422557
Do you posibly have some sort of internet security application on your computer which may be blocking the connection?

Do you have the latest firmware installed?

Maybe somthing in the config to prevent it from sleeping?

You should not have to log into a web interface to access your files... that should only be to configure the unit. I have a NAS and a batch script like I posted above which maps it as a drive letter.

I googled the model number and it looks like a real PITA model - worst case you can always pull out the drives and put them in a computer
0
 
LVL 13

Author Comment

by:nike_golf
ID: 24426357
Thanks for the posts and suggestions. I've thought about all the suggestions that you've made and I think we're a little off topic. I've gone through all of those options already before I started to resort to implementing a script.

I don't understand why IE doesn't get the focus when its executed? and yet I can't find anything on the net so I'm still looking for a solution to this problem, thanks.

NG,



0
 
LVL 3

Expert Comment

by:bleech677
ID: 24435347
0
 
LVL 13

Author Comment

by:nike_golf
ID: 24437405
I had already seen that link, thanks.

I ran Spy++ on the window and came upwith the following - not sure if its helpful..


spy.jpg
0
 
LVL 3

Accepted Solution

by:
bleech677 earned 500 total points
ID: 24442037
Ok so I went ahead and actually tried this myself and got it working for an IIS site that uses windows authentication.  This is not very elegent and will probably interrupt you if you are working but it does do the login.

Please post if you tweak / improve it for your use

Code:
strUsername = "administrator"
strPass = "password"
 
Set objIExplorer = CreateObject("InternetExplorer.Application")
objIExplorer.visible = True
objIExplorer.navigate strLink
 
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Connect to http://server.dyndns.tv:8887"
wshShell.AppActivate ("Internet Explorer") 'give focus back to IE
WScript.Sleep 100
WshShell.SendKeys strUsername
WScript.Sleep 100
WshShell.SendKeys "{TAB}" 
WScript.Sleep(100)
WshShell.SendKeys strPass		
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{TAB}"
WScript.Sleep 100
WshShell.SendKeys "{ENTER}"
	
Set objIExplorer = Nothing
Set WshShell = Nothing

Open in new window

0
 
LVL 13

Author Closing Comment

by:nike_golf
ID: 31582545
That worked! thanks for that.

NG,
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question