VB - using a variable

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Lucky5tar

Thread Starter
Joined
Aug 2, 2008
Messages
279
I think it's obvious what I'm trying to do here - use the "proxy" variable but it's chucking an error message (invalid character), how do you properly call text variables?

Code:
dim proxy
set proxy = "%Proxy2%"

dim oShell
set oShell = Wscript.CreateObject("Wscript.Shell")

if msgbox("Turn Proxy on?", vbQuestion or vbYesNo) = vbYes then
oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"
oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", ""%proxy%":8081", "REG_SZ"
else
oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"
end if

Set oShell = Nothing
 
Joined
Nov 30, 2009
Messages
277
You need to change the line to:

oShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", proxy & ":8081", "REG_SZ"
 
Joined
Nov 30, 2009
Messages
277
set proxy = "myProxyDomain.com"

Obviously put your proxy server domain name in where it says myProxyDomain or if you're using an IP address then put the IP in.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top