Page 1 of 1 1
Topic Options
#173488 - 2007-02-01 04:07 AM Script to change Proxy address and remove connection tab
sgraham978 Offline
Fresh Scripter

Registered: 2007-02-01
Posts: 11
Not sure if this is possible or not, but what I would like to do is write a script that would check the ip address of a computer, then if it determines that it's on our network it would set the proxy address to a particular address and then disable the connection tab. If it doesn't find an address on our network then it changes the proxy to blank and leaves the tab.

Is it possibel to write a kix script to do the above or am I asking too much???

Top
#173489 - 2007-02-01 04:26 AM Re: Script to change Proxy address and remove connection tab [Re: sgraham978]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
So, how would this script be deployed? Obviously if they are not on your network, it cannot be a logon script.

Why not just deploy proxy through WPAD?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#173492 - 2007-02-01 05:12 AM Re: Script to change Proxy address and remove connection tab [Re: Les]
sgraham978 Offline
Fresh Scripter

Registered: 2007-02-01
Posts: 11
The login script starts up automatically when people log in. When the laptop users are not connected to the network then they obviously won't get the login script, although what I was thinking of doing was putting it on their machines locally so that when the start the computers up off the network then they still get the script. That was the plan anyway, of course if there's a better way of doing it then I'm happy to do it another way.

The reason I wanted to automate it all in the script was because when the laptop users go offsite they generally need to turn the proxy off, but when they come back into the office they need to turn it on again. A lot of them either forget or don't want to have the hassle and then some just don't turn it back on at all when in the office and they end up using our dedicated internet link for emails etc instead of the account for browsing the internet. So, I wanted to automate it so that when they're out of the office it automatically switches over then when they're in the office it switches back without them having to do anything.

Top
#173494 - 2007-02-01 06:28 AM Re: Script to change Proxy address and remove connection tab [Re: sgraham978]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If you set the browser to auto detect proxy and then setup WPAD, it all takes care of itself.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#173495 - 2007-02-01 06:36 AM Re: Script to change Proxy address and remove connection tab [Re: sgraham978]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
http://en.wikipedia.org/wiki/Web_Proxy_Autodiscovery_Protocol
Top
#173498 - 2007-02-01 07:10 AM Re: Script to change Proxy address and remove connection tab [Re: NTDOC]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
wpad indeed.
If your web browser cannot locate a wpad server, it connects direct.
Else, it works like scripted in wpad.dat.

Top
#173499 - 2007-02-01 08:01 AM Re: Script to change Proxy address and remove connection tab [Re: Witto]
sgraham978 Offline
Fresh Scripter

Registered: 2007-02-01
Posts: 11
Cool, thanks everyone. I'll have a look at that.
Top
#173500 - 2007-02-01 08:59 AM Re: Script to change Proxy address and remove connection tab [Re: sgraham978]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Autoconfigure Scripts for Proxy Settings - Apr. 22, 2004
http://nscsysop.hypermart.net/proxypac.html

Navigator Proxy Auto-Config File Format
http://wp.netscape.com/eng/mozilla/2.0/relnotes/demo/proxy-live.html

JavaScript or JScript Auto-Proxy Example Files
http://www.microsoft.com/windows/ieak/techinfo/deploy/60/en/corpexjs.mspx

Top
#173502 - 2007-02-01 11:55 AM Re: Script to change Proxy address and remove connection tab [Re: Witto]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
In my environment can't do that. We have VPN users and ALL HTTP traffic MUST go through proxy... so they they can report on staff activity.

In this case a network detection client (detect new connection), determine subnet, if subnet=work then set proxy else no proxy, loop) would do it.

He could even add in a "run logon script" to it


Most of the code is in a " Network (and wireless) disconnector " post I made a month or so ago
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#173509 - 2007-02-01 04:34 PM Re: Script to change Proxy address and remove connection tab [Re: Radimus]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
The script like in wpad.dat stays the same, but you deploy is as an "Automatic Configuration Script".
The script file extension should be PAC file (not DAT like for the wpad server).
Maybe you can work with a logon script and a logoff script.
Maybe this can help:
http://www.adminscripteditor.com/scriptlibrary/view.asp?id=377

Top
#174906 - 2007-03-23 03:08 AM Re: Script to change Proxy address and remove connection tab [Re: Witto]
sgraham978 Offline
Fresh Scripter

Registered: 2007-02-01
Posts: 11
Just letting you all know that I've finally written a script that does what I want it to do with regards to proxies...in case anyone would like to know I've pasted the code below..

Code
-------------------------------------------
DIM $SUBNET
$SUBNET = SUBSTR(@IPADDRESS0,1,8)
If $SUBNET = "Your IP Address"
$key = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
WRITEVALUE($key,"ProxyEnable","1","REG_DWORD")
WRITEVALUE($key,"ProxyServer","proxy:8080","REG_SZ")
WRITEVALUE($key,"ProxyOverride", "<local>", "REG_SZ")
Else
$key = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
WRITEVALUE($key,"ProxyEnable","0","REG_DWORD")
EndIf
------------------------------------------------

Thanks to everyone who responded...much appreciated.

Top
#176341 - 2007-05-18 10:28 AM Re: Script to change Proxy address and remove connection tab [Re: sgraham978]
PeckMan Offline
Fresh Scripter

Registered: 2007-05-18
Posts: 8
Loc: Austria
 Originally Posted By: sgraham978
Just letting you all know that I've finally written a script that does what I want it to do with regards to proxies...in case anyone would like to know I've pasted the code below..

Code
-------------------------------------------
DIM $SUBNET
$SUBNET = SUBSTR(@IPADDRESS0,1,8)
If $SUBNET = "Your IP Address"
$key = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
WRITEVALUE($key,"ProxyEnable","1","REG_DWORD")
WRITEVALUE($key,"ProxyServer","proxy:8080","REG_SZ")
WRITEVALUE($key,"ProxyOverride", "<local>", "REG_SZ")
Else
$key = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
WRITEVALUE($key,"ProxyEnable","0","REG_DWORD")
EndIf
------------------------------------------------

Thanks to everyone who responded...much appreciated.


Hello @ all

I'm new at this forum and need your help because I don't come along with this code.
I was searching exactly for an IE proxy solution like this because we need different 'proxy override' options for our inner office user and our field force user.

My problem, it seams the ip address can not be checked because only the 'Else' function works.
The script should check if the ip address is a 10.43.1.* address and then should write the 'proxy override' value in the registry.
All our other ip addresses like 10.43.2.*, 10.43.3.*, 10.43.4.* and so on should get the 'Else' values.

What's going wrong here?

Thanks in advance for your help.


Edited by PeckMan (2007-05-18 10:32 AM)

Top
#176342 - 2007-05-18 10:50 AM Re: Script to change Proxy address and remove connection tab [Re: PeckMan]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Actually you should start your own thread, explain your wishes/problem and include a link to this but it's too late for that now.

This should work.
 Code:
Dim $SUBNET

$SUBNET = Left(@IPADDRESS0, 12)

If $SUBNET = " 10. 43.  1."
	$key = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
	WriteValue($key,"ProxyEnable","1","REG_DWORD")
	WriteValue($key,"ProxyServer","proxy:8080","REG_SZ")
	WriteValue($key,"ProxyOverride", "<local>", "REG_SZ")
Else
	$key = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
	WriteValue($key,"ProxyEnable","0","REG_DWORD")
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#176343 - 2007-05-18 11:19 AM Re: Script to change Proxy address and remove connection tab [Re: Mart]
PeckMan Offline
Fresh Scripter

Registered: 2007-05-18
Posts: 8
Loc: Austria
Thank you very much for the quick answers.

I'll check your solution and sorry, I thought continuing this thread will be easier than creating a new one.
I'll remind this for the future.


Edited by PeckMan (2007-05-18 11:19 AM)

Top
#176344 - 2007-05-18 11:42 AM Re: Script to change Proxy address and remove connection tab [Re: PeckMan]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: PeckMan

....

sorry, I thought continuing this thread will be easier than creating a new one.
I'll remind this for the future.


Don't worry. We all make mistakes sometimes. \:\)

Tweaked it a bit.

 Code:
Dim $SUBNET, $key

$SUBNET = Left(@IPADDRESS0, 12)
$key = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

If $SUBNET = " 10. 43.  1."
	$rc = WriteValue($key,"ProxyEnable","1","REG_DWORD")
	$rc = WriteValue($key,"ProxyServer","proxy:8080","REG_SZ")
	$rc = WriteValue($key,"ProxyOverride", "<local>", "REG_SZ")
Else
	$rc = WriteValue($key,"ProxyEnable","0","REG_DWORD")
EndIf


Edited by Mart (2007-05-18 11:45 AM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#176345 - 2007-05-18 12:06 PM Re: Script to change Proxy address and remove connection tab [Re: Mart]
PeckMan Offline
Fresh Scripter

Registered: 2007-05-18
Posts: 8
Loc: Austria
Thank you very much, Mart.

Your first solution already works perfectly.
So only the 'Substr' function was the mistake.

The tweaked code looks nice.
I think, I'll use this code \:\)

Top
#176346 - 2007-05-18 12:20 PM Re: Script to change Proxy address and remove connection tab [Re: PeckMan]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You should also be aware of the fact that spaces are added to the IP address fields until the field is three character log so 192.168.1.1 will become 129.168. 1. 1 in kix. Also it could be @IPADDRESS1, @IPADDRESS2 or @IPADDRESS3 it all depends on your setup and how many IP addresses are added to the nic or how many nic’s are in the computer.

Edited by Mart (2007-05-18 12:20 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#176424 - 2007-05-23 05:34 PM Re: Script to change Proxy address and remove connection tab [Re: Mart]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
You forgot his ProxyOverride value's ;\)
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (AndreLuiz) and 509 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.076 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org