Automatic login when run the program second time - vb.net

Recently try to use a webbrowser component.
when I click button, it will navigate to facebook.com. after I login on first time and stop the program. and then when I run the program second time I don't need to fill the email and password. why I don't need to fill an email and password textbox ? thanks
Here's the code
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Navigate("m.facebook.com")
End Sub
End Class
Note: I will delete this post, because it doesn't help the community. Just my curiosity. Thanks
how do i need to re-type the email password again when 2nd starting the program

You have two options:
The first is to save the CookieContainer associated with the WebBrowser to disk and reload it when you restart your program. There is no straightforward way to serialize cookies to disk or other storage method - that is up to you.
Instruct the WebBrowser object to make use of the user's Windows profile Internet Explorer cookie collection which is shared with Internet Explorer and other programs that also opt-in to sharing state (I do not know if this also applies to the Edge browser, I suspect it does not). See here for instructions on how to do this: Use cookies from CookieContainer in WebBrowser

Related

Open TCP/IPv4 dialog with visual basic button

I have a button in visual basic. I would like, when I hit the button for it to open up the TCP/IPv4 dialog window of the active network connection on the machine so that I can quickly and easily change ip address settings.
I can't seem to find a way to google this properly. All ways I can think to ask the question return unrelated results.
How do I open this dialog window with VB code?
Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
End Sub
I'm not too sure if you can get it to open up straight at the WiFi properties of the current connection, but you can get it to open the Network Connections which should be able to save you some time.
Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
Process.Start("ncpa.cpl")
End Sub
You cant open it directly but this article has a method using #Werdna's approach of using ncpa.cpl and send keys.
It also has the command line utilities for extracting / setting the ip.
https://superuser.com/questions/735292/how-to-open-tcp-ip-properties-from-cmd-or-run-directly

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

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.

Windows Mobile SDK : how to turn a label/button into a website link?

I am programming in Windows Mobile SDK 6 using Visual Basic, i would like to know how to make a button open the smartphone browser with a specific website path (make a link)
I got to the next piece of code so far:
Public Class GuitarHelperPage
Public link As New WebBrowser
Public adress As Uri
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
adress = New Uri("https://www.google.com")
Try
link.Navigate(adress)
'link.Focus()
Catch ex As System.UriFormatException
Return
End Try
End Sub
(the commented 'link.Focus()' its just something i tryed out, but i got the same output)
I simply want to click the button and open the browser at google homepage. But when I click it, the warning "This page contains both secure and nonsecure items. Do you want to continue?" appears and when I click "yes", nothing else hapens.
I've been researching and found this on MSDN help pages:
"The WebBrowser class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute"
SO i added this my main method:
<STAThread()> _
Shared Sub Main()
But still i get this error : "Type STAThread is not defined." And can't find a away around, I tried to add this same attribute to a Windows Desktop VB project and it works, maybe there is another way to do it in Mobile?
I am using .Net Framework 3.5 and windows mobile sdk 6.0 for this project
Please help, thank you.
If you want to open the default browser, you don't need a WebBrowser control. Just use the Process class, specifically the Start overload that takes in a ProcessStartInfo. Set the UseShellExecute property of the ProcessStartInfo to true so that it will open the default browser (e.g. if the user installed Opera Mobile, it will use that, not just always force IE).

Help files open in two browsers

In our application, when you go to "Menu > Help...", it opens our help files in Internet Explorer, which is the desirable effect. However, we have the shortcut key "F1" set to open the help files as well. It still opens the help in Internet Explorer... but it also opens them up at the same time in the user's default web browser!
Here is the code in the event method that opens the web browser:
Private Sub menuHelpHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuHelpHelp.Click
Dim temp As String = String.Format("{0}\Internet Explorer\iexplore.exe", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles))
Dim temp2 As String = String.Format("{0}", Globals.HelpFilePath)
If Not System.IO.File.Exists(temp2)
MessageBox.Show(String.Format("Could not find index.html, run ""help_zip.exe"" inside the Doc folder as an Administrator to restore the help system (make sure to overwrite all files when asked!)"))
Else
System.Diagnostics.Process.Start(temp, temp2)
End If
End Sub
If I step through the code after clicking the Help menu item, IE opens as intended when I hit the "System.Diagnostics.Process.Start(temp, temp2)" line. However, when I do the same thing after pressing F1, it opens first in the user's default browser, and then in IE second. Any ideas? The code in this part of the application is written in VB.NET, and the application is a .NET 3.5 app.
Out of curiosity, have you tried binding the action to another button to see if the problem still exists? Switch it from F1 to F2, see if it still happens. Almost certainly will, unless there's some code in your program which you forgot about that's causing problems.
EDIT
You appear to be setting a global variable for your help path.. which means the default F1 Help would likely load the correct file. So I'd go with the "F1 is still bound to the default Help action." You'll need to unbind it.

Web browser that can not be closed

I am trying to create a locked down browser for the employees at my work to use at a kiosk. I need to prevent the user from getting out of the app. I have figured out how to prevent them from closing it by pressing alt-f4 or ctrl-f4 but I would like to also prevent alt-esc, ctrl-esc, alt-tab, and the windows key. Can anyone help me figure out how to do this? I am new to windows application development but have experience in web vb.net. I am using VB.NET 2010 express. Thanks.
Rather than do that, why not just Cancel the close?
Handle the Closing event on your form and set Cancel to true.
Public Class MyForm Inherits Form
//Wire the event...
Public Sub MyForm_FormClosing(sender as Object, args as FormClosingEventArgs) Handles Closing
args.Cancel = True
End Sub
End Class
That way, you can decide when it should be closed and it doesn't matter what other ways the user thinks of.
As Cody mentioned in the comments, a lot of this should be enforced (and some can only be enforced) by Group Policy. You can script Group Policy settings, to make it easily deployable.