?
Solved

Download file from a secured link

Posted on 2011-10-05
3
Medium Priority
?
200 Views
Last Modified: 2012-05-12
Hi
I am just looking for a script from which i can download the file from a secured website by putting user name password and then select the link.

Thanks

0
Comment
Question by:surah79
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
sungenwang earned 2000 total points
ID: 36924675
Here's a sample code.
sew

strURL = "www.gmail.com"
strUserID = "user_id"
strUserPassword = "user_password"


Set objIE = Createobject("InternetExplorer.Application")

objIE.Visible = True
objIE.Navigate2(strURL)

Call WaitWhileBusy(objIE, 3000, 100)
Call WaitForDocState(objIE, 4, 3000, 100)

objIE.document.getElementsByName("Email")(0).Value = strUserID
objIE.document.getElementsByName("Passwd")(0).Value = strUserPassword

' click on submit button
objIE.document.getElementsByName("signIn")(0).Click




Function WaitWhileBusy(objIE, intTimeout, intWaitInterval) 
	Dim boolResult : boolResult = True
	Dim intSecElapsed : intSecElapsed = 0

	Do
		If intWaitInterval > 0 Then
			WScript.Sleep intWaitInterval

			If intTimeout > 0 Then
				If intSecElapsed > intTimeout Then
					boolResult = False
					Exit Do
				Else
					intSecElapsed = intSecElapsed + intWaitInterval
				End If
			End If
		End If
	Loop While objIE.busy

	WaitWhileBusy = boolResult
End Function

Function WaitForDocState(obj, intState, uSecTimeOut, intWaitInterval)
	Dim boolResult : boolResult = True
	Dim intSecElapsed : intSecElapsed = 0

	Do
		If intWaitInterval > 0 Then
			WScript.Sleep intWaitInterval

			If uSecTimeOut > 0 Then
				If intSecElapsed > uSecTimeOut Then
					boolResult = False
					Exit Do
				Else
					intSecElapsed = intSecElapsed + intWaitInterval
				End If
			End If
		End If
	Loop Until intState <= GetDocState(obj)

	WaitForDocState = boolResult
End Function

Function GetDocState(obj)
	On Error Resume Next

	Select Case obj.Document.readyState
		Case "uninitialized"	GetDocState = 0
		Case "loading"		GetDocState = 1
		Case "loaded"		GetDocState = 2
		Case "interactive"	GetDocState = 3
		Case "complete"		GetDocState = 4
		Case Else		GetDocState = -1
	End Select

	On Error Goto 0
End Function

Open in new window

0
 

Author Closing Comment

by:surah79
ID: 36946495
thanks a lot for your help
0
 
LVL 14

Expert Comment

by:sungenwang
ID: 36946569
you're welcome!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

840 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