Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

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

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
nike_golf
Asked:
nike_golf
  • 11
  • 8
1 Solution
 
nike_golfAuthor Commented:
Nobody's got any suggestions that's not good...??

NG,
0
 
bleech677Commented:
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
 
bleech677Commented:
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
bleech677Commented:
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
 
nike_golfAuthor Commented:
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
 
bleech677Commented:
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
 
bleech677Commented:
Does the NAS have a gui frontend where you can login via a form?
0
 
bleech677Commented:
here is some background info on what IE does
http://support.microsoft.com/?id=258063
0
 
nike_golfAuthor Commented:
"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
 
bleech677Commented:
>>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
 
nike_golfAuthor Commented:
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
 
bleech677Commented:
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
 
nike_golfAuthor Commented:
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
 
bleech677Commented:
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
 
nike_golfAuthor Commented:
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
 
bleech677Commented:
0
 
nike_golfAuthor Commented:
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
 
bleech677Commented:
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
 
nike_golfAuthor Commented:
That worked! thanks for that.

NG,
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 11
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now