Solved

Setting internet proxy setting

Posted on 2002-03-05
2
153 Views
Last Modified: 2010-05-02
Hi,
I want to a code that will enable me to change the proxy setting of my IE from a vb code. Since I use my laptop at home and at school, I am getting tired of changing the proxy setting and releasing and renewing my IP (through winipcfg) all the time I change places
What I need is:
-A vb code that accepts a command line parameter (that is the name of the proxy server) and sets it as a proxy server (I think this can be done using wininet.dll functions)

-Release and renew the ip address (I think this can be done by using winipcfg /release_all and winipcfg /renew )

So that I can put this program (after making it an exe) as a startup program and I don't have to change anything.

I would really appreciate it if someone gives me a fully working code.(IF it is complete and I don't have to change anything,  I promise to add additional 50 points, cross my heart)


Thanks
0
Comment
Question by:oumer
2 Comments
 
LVL 27

Accepted Solution

by:
Ark earned 250 total points
ID: 6842924
Hi

Sub Main()
  Dim WshShell As Object
  Dim sCmd As String
  sCmd = Command$
  Set WshShell = CreateObject("WScript.Shell")
  WshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", sCmd
'No need to use release_all, renew_all should be enough
  WshShell.Run "%windir%\winipcfg /renew_all", 0
  t = Timer
  While t + 1 > Timer
  Wend
  SendKeys "{Enter}", True
  Set WshShell = Nothing
End Sub

'Compile this and call:
Project1.exe ProxyName:Port
'For example:
Project1.exe 192.168.0.5:8080
'or
Project1.exe seagate:80
0
 
LVL 4

Author Comment

by:oumer
ID: 6844013
As I promised, I have increased the points to 250. I have modified it a little an now I have a program that I can run like
ProxySet ip1 proxy1 ip2 proxy2 .....
so that when I change your laptop from place to place I have to set nothing (currently I use my laptop at home and school)

Thank you
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now