Jump to content

Recommended Posts

Posted

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\Internet Settings\ProxyEnable","1","REG_DWORD"

WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet 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...

Posted

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.

Posted

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\currentversion\internet settings\proxyenable"

Set create = CreateObject("wscript.shell")

regsetting = 1

create.regwrite key, regsetting, "REG_DWORD"

'create.regwrite ("hkcu\software\microsoft\windows\currentversion\internet settings\proxyenable", "1", "reg_dword")

msgbox = "Proxy Now: Enabled"

Posted
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?
Posted
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?
Posted (edited)

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\currentversion\internet settings\proxyenable"

create = CreateObject("wscript.shell")

regsetting = 1

create.regwrite(key, regsetting, "REG_DWORD")

'create.regwrite ("hkcu\software\microsoft\windows\currentversion\internet 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\currentversion\internet settings\proxyenable"

create = CreateObject("wscript.shell")

regsetting = 0

create.regwrite(key, regsetting, "REG_DWORD")

'create.regwrite ("hkcu\software\microsoft\windows\currentversion\internet 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...

Edited by neon
Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...