Page 1 of 1 1
Topic Options
#122086 - 2004-07-02 03:38 PM passing variable
Stealth Offline
Fresh Scripter

Registered: 2001-08-09
Posts: 48
Loc: Scotland
Can someone please enlighten me I cant get my head round this heres part of my script

:variables

$CITRIXCHECK = "C:\Winnt\Profiles\%username%\Application Data\ICAClient"
$HOMEDIR = "%HOMEDRIVE%%HOMEPATH%" ; Required - Path For Users Home Directory
$AUTOCORRECT = $HOMEDIR+"Autocorrect\" ; Required - Default path for locaton of Auto Correct files.
$OUTLOOKROOT = $HOMEDIR+"Exchange\" ; Required - Default Path For Outlook Files
;
$HKCUSMWCVEUSF = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"
$HKCUSMWCVIS = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$HKCUSMWCVISPS = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer"
$HKCUSMWCVPE = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
$HKCUSMO8CFNLT = "HKCU\Software\Microsoft\Office\8.0\Common\FileNew\LocalTemplates\"
$HKCUCPC = "HKCU\Control Panel\Colors"
$HKCUCPDT = "HKCU\Control Panel\Desktop"
$HKCUSMWCVIE4SS = "HKCU\Software\Microsoft\Windows\CurrentVersion\IE4 Screen Saver"
$HKCUSPMIECP = "HKCU\Software\Policies\Microsoft\Internet Explorer\Control Panel"
$HKCUSMWCVISZMD = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains"
$HKCUSMWCVISZM = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges"
$HKCUSMWCVISZMR = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range"
$HKCUSMWCVISZ1 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1"
$HKCUSMO8CAC = "HKCU\Software\Microsoft\Office\8.0\Common\AutoCorrect\"
$HKCUSMO8OOE = "HKCU\Software\Microsoft\Office\8.0\Outlook\Office Explorer"
$HKCUSMIE = "HKCU\Software\Microsoft\Internet Explorer"
$HKCUSMIEM = "HKCU\Software\Microsoft\Internet Explorer\Main"
$HKCUIACD = "HKCU\IDENTITIES\Auto Correct Done"
$HKCUSPMIER = "HKCU\Software\Policies\Microsoft\Internet Explorer\Restrictions"



: proxy_settings


If Val (ReadProfileString(C: +'\Kix\include.ini','Include',@WKSTA)) = 1
$nul=WriteValue($HKCUSMWCVIS,"ProxyEnable","1","REG_DWORD")
EndIf
;
$Proxy = ReadProfileString(c: +'\Kix\include.ini','Include','Proxy')
WriteValue($HKCUSMWCVIS,"ProxyServer",'$Proxy',"REG_SZ")







Contents of include.ini

[Include]

PCNAME=1 ; Allows certain comuputers to have proxy enabled

[Proxy]

PROXYSERVER:PORTNUMBER ; Hopefully writes the proxy listed here to the registry


I want to be able to read the value in the include.ini under the header proxy and pass it to the writevalue and write it to the registry


Any help appreciated thanks in advance

Top
#122087 - 2004-07-02 03:41 PM Re: passing variable
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
In your INI file,
PROXYSERVER:PORTNUMBER

does not conform to proper INI key/data constructs.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122088 - 2004-07-02 03:45 PM Re: passing variable
Stealth Offline
Fresh Scripter

Registered: 2001-08-09
Posts: 48
Loc: Scotland
maybe it doesn't but will it not work and if not how can i achieve what im looking for?
Top
#122089 - 2004-07-02 03:53 PM Re: passing variable
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Providing that you have control over the ini file, a better solution is:
Code:
[Include]
PCNAME=ProxyConfigX

[ProxyConfigX]
ProxyName=wwwproxy.acme.com
ProxyPort=3128
Direct=*.acme.com
Otherparameter=foo



This way you can have different sections for different proxy configurations.

However the correct way to do this is to use WPAD (or similar) to deliver the proxy configuration to all machines, then use authentication rules on the proxy to determine if access should be allowed or not.

Top
#122090 - 2004-07-02 04:04 PM Re: passing variable
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Your code:
$Proxy = ReadProfileString(c: +'\Kix\include.ini','Include','Proxy')
is looking for a "key" called "Proxy" undier the "Section" called "Include". You have a "Section" called "Proxy" but don't have a key by that name.

To make the existing code work, you need to add the key to the INI

INI FIle:
[Include]
PCNAME=1 ; Allows certain comuputers to have proxy enabled
Proxy=PROXYSERVER:PORTNUMBER ; Hopefully writes the proxy listed here to the registry

This is not how I would do it but it does answer your question. In fact I use GPOs to set proxy, not based on the computer but rather based on whether the user is in the group that has permissions applied on the proxy server. That way users without internet access do not get the proxy logon prompt.

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#122091 - 2004-07-02 04:11 PM Re: passing variable
Stealth Offline
Fresh Scripter

Registered: 2001-08-09
Posts: 48
Loc: Scotland
Ok I dont want to use wpad i want to certain users on certain domain to use 1 of 6 or more proxy servers this is what I had before



: proxy_settings
;
$nul=WriteValue($HKCUSMWCVIS,"ProxyOverride","home.*;10.*etc etc.*;<local>","REG_SZ")
$nul=AddKey($HKCUSMWCVISPS)
$nul=WriteValue($HKCUSMWCVIS,"ProxyEnable","0","REG_DWORD")

If Val (ReadProfileString(C: +'\Kix\include.ini','Include',@WKSTA)) = 1
$nul=WriteValue($HKCUSMWCVIS,"ProxyEnable","1","REG_DWORD")
EndIf
;
If Val (ReadProfileString(C: +'\Kix\include.ini','Proxy',Proxy1) = 1
$nul=WriteValue($HKCUSMWCVIS,"ProxyServer","Proxy1:80","REG_SZ")
;
Else
$nul=WriteValue($HKCUSMWCVIS,"ProxyServer","Proxy2:80","REG_SZ")
;
EndIf


As you can see this is hardcoded to the script although you could mess around with cnames you are still limited to 2 All I want to do is manually read a value as a variable? as described before and enter it into the registry surley it cant be that difficult??

Top
#122092 - 2004-07-02 04:17 PM Re: passing variable
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

surley it cant be that difficult??



Right you are. See my previous reply. All that is required is a basic understanding of INI structures and the KiX ReadProfileString() function. It is well documented on the manual.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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
0 registered and 369 anonymous users online.
Newest Members
rrosell, PatrickPinto, Raoul, Timothy, Jojo67
17877 Registered Users

Generated in 0.06 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

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