I am new to Visual Basic and am looking for a little help.
I have 2 .vbs files (which I got off edugeek) that I can double click one to turn on proxy settings and one to turn them off, I have managed to get my hands on visual basic studio 2005 and wanted to make a simple app but I am finding it difficult,
here is the script
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\In ternet Settings\ProxyEnable","1","REG_DWORD"
WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\In ternet Settings\ProxyServer","PROXY:PORT","REG_SZ"
Wscript.Echo " Proxy Settings Added "
I have designed the app and wanted to add funtionality to one of the buttons... thought I could double click the button and paste the code in? Obv not...
Is it because wshshell cannot run inside visual basic studio?
Any help welcomed...

VBS is different to Visual Basic .net - one is a scripting language, the other is a programming language.
To make an application which would switch reg settings on the press of a button, you'd need to make use of the Microsoft.Win32 library, and the 'Registry' and 'RegistryKey' objects.
I'd suggest grabbing a VB.Net book and picking up the basics of the language before trying that though.
Personally, I'd also say to use C# instead of VB.net - the syntax makes more sense I find.
Thank you, thought that they were the same but visual basic let you create a a GUI... Back to the books...
Not sure if it helps but here is the VB6 code to perform this task.
dim key as string
dim create
dim regsetting
key = "HKEY_CURRENT_USER\software\microsoft\windows\curr entversion\internet settings\proxyenable"
Set create = CreateObject("wscript.shell")
regsetting = 1
create.regwrite key, regsetting, "REG_DWORD"
'create.regwrite ("hkcu\software\microsoft\windows\currentversion\i nternet settings\proxyenable", "1", "reg_dword")
msgbox = "Proxy Now: Enabled"
I am working with visual basic 2005 express edition I got it for free and I am have very little knowledge, I have copied it in and seems to work ok, do you have one for disable proxy?
yes just change the regsetting var to 1 instead of 0.

Another issue there, you are using Visual Studio 2005 Express - Visual Basic edition. This is a cut down version of Visual Studio, which only allows the use of Visual Basic.net. The code that jmcdermott posted is VB6 - an older, and now defunct, language.
Information on VB.net registry interaction is available here: Accessing the Registry with Visual Basic .NET
Maybe older and defunct, but it is what was around when I started IT and still serves a use.
I find coding in .NET takes a lot longer to perform the simple tasks.
The code went in with no errors however doesnt work, maybe I should stop being a cheap skate and buy the latest version rather than messing about with this?
Which Browser are you using?
Also it may require the browser to exit and open again before it takes effect.
What browser am I using? should it make a difference? IE8... but I can run the application and nothing happens...
ublic Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim key As String
Dim create
Dim regsetting
key = "HKEY_CURRENT_USER\software\microsoft\windows\curr entversion\internet settings\proxyenable"
create = CreateObject("wscript.shell")
regsetting = 1
create.regwrite(key, regsetting, "REG_DWORD")
'create.regwrite ("hkcu\software\microsoft\windows\currentversion\i nternet settings\proxyenable", "1", "reg_dword")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim key As String
Dim create
Dim regsetting
key = "HKEY_CURRENT_USER\software\microsoft\windows\curr entversion\internet settings\proxyenable"
create = CreateObject("wscript.shell")
regsetting = 0
create.regwrite(key, regsetting, "REG_DWORD")
'create.regwrite ("hkcu\software\microsoft\windows\currentversion\i nternet settings\proxyenable", "0", "reg_dword")
End Sub
End Class
This is code I have in place I only want 2 buttons one to turn on one to turn off...
Last edited by neon; 14th December 2009 at 10:56 AM.
Firefox and chrome do not user the reg setting.
have you checked the reg key using regedit after running the program?
why use VB?
there's an autoit script on this forum somewhere, very easy to change to

I think you're getting a bit mixed up here.
VB6 code simply will not work in Visual Studio.net without special addons etc... It isn't supported any more, so unless you have the VB6 program installed, it will be no use.
The code you need will be possible if you use the link I provided.
Thank you, I am in the process of reading through and trying out your link...![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)