VB.Net button open multiple user and auto login in different window of IE - vb.net

I have a website stored 100 users ....now i want to create a VB form with 100 buttons ....while i click button1, it will open IE then log in users1 automatic and when i click button2 , it will open IE then log in as user2 automatic. user3 until user100 the same ....click from button on vb form.
Note : i am already done to set open IE and log in as different users in each windows but now i am finding how to set auto log in with different users in the same website when i click each button in form.
i have something more about form....i will use ( 100 button click = 100 users = 100 IE window ....)
it depend on user click on button that he need to log in......because we don't know that what button/users/time will he want to click .....
I really need your help urgently...
Thank in advanced.
here is some code of Button_Click
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Using p As New Process
p.StartInfo.FileName = "C:\Program Files\Internet Explorer\iexplore.exe"
p.StartInfo.Arguments = "http://test.com"
p.Start()
End Using

This is the only way I can come up with on how to solve this.
My guess is that your login is using POST variables, it's pretty much standard.
To make this work you would have to allow the username and password to be supplied with GET. That is, sending them in the url like this:
http://test.com/login.php/asp?username=username&password=password
Since you haven't specified whether you use PHP or ASP.NET I will add info on how to get the value for both:
ASP.NET
Request.Querystring("username")
PHP
$_GET["username"];

EDIT based on comment
You are correct it is not possible to isolate separate webbrowser controls.
I would suggest you look into either WaTin to control separate IE instances, or Awsomium .NET, which i believe allows separate sessions in 1.7, though i haven't tested it.
Also be aware that since IE8 session cookies are shared across instanced by default, so you would need to run them with the -nomerge flag. WaTin supports this.
Based on the fact that you have not mentioned this in your question, i am presuming you are using IE7. If that is the case, and this application is not intended to be used on other machines, it should be possible to create a separate application with an embeded webbrowser control, then launch multiple insatances of that application from the main one, so you can add your own communication mechanism, but WaTin is probably a far better idea
OLD ANSWER:
It is very hard to work out what you want to do, but im guessing you want to create a winforms app, that lets you to choose a user account, and then open a browser and login to a website with that account.
Based on that assumption, my suggestion would be to have one button, and some way of selecting the account, say a comboBox, and a webbrowser control:
http://img198.imageshack.us/img198/888/66649645.jpg
Rather than 1 button per user account and trying to manipulate an external browser.
If this is indeed what you want to do, comment and i will edit my answer as required, and provide starting code if you need, but i cant do that without really undertanding what you need to do.

Related

MS Access Form with Webbrowser Control Popup New IE Window, Access 2010/VBA

I have struck with one issue not finding any workable solution. Googled a lot without any success…HELP PLEASE.
Situation: Using MS Access 2010, there is one Form with WebBrowser Control (Unbound) for conducting some search, when I click the results of the search a Pop-up new Internet Explorer window opens for the search result.
Requirement: I need “new Internet Explorer window” needs to be opened on existing WebBrowser Control..... NOT to open separately as new pop-up Internet Explorer window.
Kindly provide me solution (MS Access 2010/VBA) or workaround….
Regards,
Sandy
Can you open the form that you are opening in the WebBrowser Control in a new browser window outside of the application in order to test something. Check to see, if when you open the url, and then invoke the search, if the results open in a new window for that browser. If so, then check the target of the form within the first screen to get the name of the window that the page is trying to open the results in. If the target is specified, then you will need to write code to remove it when the page loads.
Just assign the new web address to your webbrowser control. something like this. Note it has to include equal sign and a hyper-link surrounded by quote.
Private Sub WebBrowser34_Click()
Me.WebBrowser34.ControlSource = "='www.google.co.uk'"
End Sub

Make multiple WebBrowser's without dragging them in file

Ok, so a program I am making involves using multiple webbrowsers with different cookies. It logs into the same site on several accounts. However, to log into several sites I need multiple webbrowsers running the same function, but I want this program to be able to log into as many accounts as needed, so I need to generate a webbrowser basically. Instead of putting it in the form, I need a code that generates a webbrowser on the form. Is this even possible?
You can use the Load event of the form to create new WebBrowser() controls and Add them to the Form's Controls collection.
However, it is not necessary to add them to the form in order to use them.
WebBrowser :MSDN
You can dynamically create many WebBrowsers but it wont work the way that you want. Each WebBrowser will act like a separate tab of an Internet Explorer. For more information you can check the following.
Hosting multiple WebBrowser controls in one window causes sessions to "cross": any solutions?.
Use a tabcontrol and put each webbrowser in a separate tabpage. You can easily declare a tabpage with a webbrowser and add or remove the tabpage as needed. Since each document that the webbrowser loads has it's own cookie collection, and the website is your own, you should be able to set up your website to accept multiple users from the same machine, at least temporarily for testing.

Select Input:File programmatically in Webbrowser control VB.net 2010

I have a website where I am filling form data through VB.Net 2010 through WebBrowser control.
I am able to set value for input:text, input:password, checkbox, select and able to submit form.
But I am not able to select input:file programmatically. I am also able to open
"Choose a File" Dialog.
How can I send file name to select and press OK button from VB.Net Code?
I am pretty sure this is a browser security feature to prevent malicious web-sites from auto-uploading random files from the user's website to themselves. Consider how dangerous it would be if any website could pull arbitrary files off the user's computer without any explicit action from the user.
Your best bet is probably going to be dumping the Web Browser control since it will limit you to its security model. Instead consider directly getting the web page and posting a response within your application.
The following .NET namespaces should come in handy for that:
System.Net.HTTPWebRequest
System.Net.TTPWebResponse

VB.NET - Log into website with out website open

I want to create a program to fetch information from a website (that's fine). However, you need to be logged in to get this information.
I just want two simple textbox controls that I would type my username and password into and hit submit and the information would be returned to me so I can use it. (I don't want to use a webbrowser control)
Sorry if I wasn't clear
And also
(this really isn't important, but its up to you if you want to answer, it's probably hard)
How would I go about checking if I am still logged into a website or not (as in TRUE or FALSE)
you can pass credentials into a HttpWebRequest object.
You could use a webbrowser control since it is easy, and just set its display to not visible - the user would never see anything. You could still interact with the page just like normal. You could use the same control to log yourself out by clicking on the logout button. You would set everything up and test it with visible=true, and when it all works, set visible to false.

Running VBA before any forms open

So I have an Access database with a front and a back end. I will be distributing it to users soon, but I have no control over where exactly they will put the files on their computers. However, I think I can count on them putting front and back ends in the same folder.
As such, when the front end opens, I want it to check that the linked tables are correctly connected to the back-end database. I have working code for this; however I don't know where to put it. When the front end opens, a menu form is automatically opened (configured through the start-up dialogue box). I have put the code in the OnOpen event, which I thought occurred before any data is loaded, but when I test this out, I get a message telling me that the back-end cannot be found (it's looking in its old location).
Basically, is there an event I can use that runs before any forms have opened?
Create a Macro and name it "autoexec".
For the macro action, select "RunCode" and then set the function name to the name of the function you use to check your linked tables.
As Matt said, create a macro, call it "autoexec", and select "RunCode" as the macro action. The Function Name argument should be the name of the function you wish to run (and not a sub), and if the function has no arguments, you should still put () at the end, or it won't work.
I generally prefer to create a small form that runs a number of checks, such as finding the back-end and so forth, and set various options. The code for the open event of this form might be:
Me.Visible = False
'Determines if the database window is displayed
SetProp "StartupShowDBWindow", False, dbBoolean
'Hide hidden and system objects
SetOption "Show Hidden Objects", False
SetOption "Show System Objects", False
'Find back end
CheckLinkPath
I keep a table of tables to be linked in the front-end and if any are missing, this form can be used to report the error, or any other error for that matter.
Set RS = CurrentDb.OpenRecordset("Select TableName From sysTables " _
& "WHERE TableType = 'LINK'")
RS.MoveFirst
strConnect = db.TableDefs(RS!TableName).Connect
If Not FileExists(Mid(strConnect, InStr(strConnect, "DATABASE=") + 9)) Then
'All is not well
blnConnectError = True
Else
Do Until RS.EOF()
If db.TableDefs(RS!TableName).Connect <> strConnect Then
blnConnectError = True
Exit Do
End If
RS.MoveNext
Loop
End If
If everything is ok, the small form calls the main menu or form and the user never sees the checking form. I would also use this form to open a password prompt, if required.
Before putting your front end and back end in the same folder, think about it. Isn't it worth having 2 folders? What about multiple users on the same computer accessing the same back-end database? What about multiple users accessing the same databse through a network? What is the necessity of having a front end-back end typology if your app is basically a single-user app?
Why don't you add a dialog box to your app, in case your connectivity is lost? You could create a fileDialog object in your code, allowing the user to browse for a *mdb file anywhere on his computer/network. It is then possible to control that the selected mdb file contains all requested tables and open the corresponding links (I guess you are using the transferDatabase command).
And what about additional tools/references you'll need for your app to run when you'll distribute it to your final users? By default, MS Access records the 3 basic ones:
Visual Basic For Application
Microsoft Access Library
Microsoft DAO Library
If your app needs anything else, such as ADO or Office objects (ADODB.recordset or Office commandbars for example), you will have to add the references manually for each installation, as the final user won't be able to open the VBA window and access the tools/references menu.
So, if you need to deploy your app on multiple computers, I strongly advise you to use a deployment tool such as this free one. You'll need a few hours to be able to use it properly, but the result is worth it. You'll be able to give your clients a real installer module. It will create folders, add requested shortcuts, and manage references in the computer's registry. This will make your deployment definitely painless!
EDIT: the autoexec macro is definitely the right solution for calling code before any event.
EDIT: don't forget that your final users can make profit of the runtime version of Access, which is free!
As others have suggested, I'd use the AutoExec macro in this case. If your code that checks the linked tables is currently a sub, change it to a function that returns TRUE if it succeeds. You can then use the "conditions" column in the AutoExec macro to exit the application with a user-friendly error dialog if the link table code fails. Your AutoExec macro could be something like:
Call your LinkTables() function, set condition to terminate startup if it fails.
Call your "Main" startup menu form.
You could send them a *.BAT file that copies the databases to c:\temp (or whatever folder you choose. Setup the linked to this folder before creating the BAT file. Zip it up and email it to them. then you won't have to worry with the extra needed code.