#205927 - 2012-10-08 06:09 AM
Re: Pull a registry value into an environment variable
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Here is a short example...
$value = ReadValue("HKCU\Volatile Environment","HOMEDRIVE")
Set "NewEnvVarName = "+$value
|
Top
|
|
|
|
#205936 - 2012-10-08 03:42 PM
Re: Pull a registry value into an environment variable
[Re: Glenn Barnas]
|
David_Figueroa
Fresh Scripter
Registered: 2012-10-06
Posts: 7
Loc: Houston, TX
|
I'm trying to pull the CLIENTNAME information out of HKLM\Software\Citrix\ICA\Session. So, my commands I'm trying to use are:
DIM $ClientName $CLIENTNAME = READVALUE("HKLM\Software\Citrix\ICA\Session", "ClientName")
As a test, I tried to just write it to another part of the registry...
WriteValue("HKCU\Software\Test", "KixTest", $CLIENTNAME, "REG_SZ")
The value gets created properly, but the actual data in the value isn't written. If I manually set $CLIENTNAME before the WriteValue, then it works properly.
The flip side of this, is I wanted to get a "permanent" environment variable set with this data for subsequent processes. I know it will not be visible in the current environment, so my hope was to find a way to write it to the registry (to create a system level environment variable - {easy}) a fire off a wm_changenotify system message in order to force windows to revaluate the environment {hard}.
My preference is to stick with Kix, because this is going to be a pre-flight execution script for Desktop Authority.
Thanks :-)
|
Top
|
|
|
|
#205946 - 2012-10-08 06:03 PM
Re: Pull a registry value into an environment variable
[Re: Allen]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Putting this line should display what you read from the registry.
$null = messagebox($CLIENTNAME,"",0)
|
Top
|
|
|
|
#205947 - 2012-10-08 06:42 PM
Re: Pull a registry value into an environment variable
[Re: ShaneEP]
|
David_Figueroa
Fresh Scripter
Registered: 2012-10-06
Posts: 7
Loc: Houston, TX
|
That is what I thought ShaneEP.. I tried it and got nothing, and I tried it again after this morning and got nothing.
Attachments
IcaSessionData.png (276 downloads) Description:
|
Top
|
|
|
|
#205948 - 2012-10-08 06:53 PM
Re: Pull a registry value into an environment variable
[Re: David_Figueroa]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
Just a thought... is this a 64bit OS?
At the top of the script, try...
$RC=setoption("WOW64AlternateRegView","On")
|
Top
|
|
|
|
#205964 - 2012-10-09 03:07 PM
Re: Pull a registry value into an environment variable
[Re: David_Figueroa]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
I tried it on my 64 bit Win7 laptop. The following reads and writes the registry value once I added Allen's suggestion. Can you check the error code after you try the write?
$nul = setoption("WOW64AlternateRegView","On")
$CLIENTNAME = READVALUE("HKLM\Software\Citrix\ICA\Session", "ClientName")
$nul = WriteValue("HKCU\Software\Test", "KixTest", $CLIENTNAME, "REG_SZ")
$nul = MessageBox("Error Number: "+@Error+@CRLF+"Error Text: "+@SError,"status",0)
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|