|
|
|||||||
I'm trying to read a registry value, and place it into an environment variable. (I have had absolutely zero luck even reading the value). Once I get that, I'd like to try and find a way to fire a wm_changenotify message (probably through .net?). I'm a decent vbscripter, and a pretty good winbatch scripter.. I'm picking kix32 back up now.. Any help would be appreciate it.. |
||||||||
|
|
|||||||
Which registry key? You would want to use the ReadValue() function to read the value, you can then use one of the Set commands to set the environment variable. |
||||||||
|
|
|||||||
Here is a short example... Code: $value = ReadValue("HKCU\Volatile Environment","HOMEDRIVE") Set "NewEnvVarName = "+$value |
||||||||
|
|
|||||||
Just be aware that you can't pass an environment var back to the program that called the Kix script.. You can set a variable in:
Glenn |
||||||||
|
|
|||||||
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 :-) |
||||||||
|
|
|||||||
Have you verified that $ClientName contains data after the registry read? (Display to screen) Display the @SERROR value after the WriteValue - what do you get? The SetM() command will create a machine (System) for all users. Glenn |
||||||||
|
|
|||||||
Are you sure that reg value exists? It does not on the version of Citrix I use. Also, teh enviro var %CLIENTNAME% is set by the client on my system. |
||||||||
|
|
|||||||
This is for XenDesktop. By default, it does not set ClientName.. you have to use the SessionStateMonitor for that, and I need that information *before* SSM runs. I *know* the key/value contains data - I have triple checked it with regedt32.exe. I'm not really sure how to display it to the screen.. I have tried calling it directly, using MessageBox (the box comes up with my text, but not the variable information for $CLIENTNAME). I've tried using the debug mode.. I'm hoping that setm will work as I hope.. but until I get some good data to put into it I can't be sure that I'm doing any of this correctly. (again, thanks for the help.. :-) |
||||||||
|
|
|||||||
Here is a function that never fully got tested. If it works for you and or your situation, might you follow up in the other thread. Clientname() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=204608#Post204608 |
||||||||
|
|
|||||||
I looked at the function, and it won't work for XD. For XA it works (at least in Win2k8 or Win2k8R2) because the sessionID is part of %temp% (i.e. if my session ID is 23, then my temp variable really points to %userprofile%\appdata\local\temp\23). In XD, this is not valid. :-\ The CLIENTNAME is absolutely in the registry for XD (It is for XA also, but it is also predicated on sessionID (hklm\software\citrix\ica\session\ I'll login from another machine, and I can post some screenshots. Again, I really appreciate the help.. I have been racking my brains for 3 days on this. |
||||||||
|
|
|||||||
Putting this line should display what you read from the registry. Code: $null = messagebox($CLIENTNAME,"",0) |
||||||||
|
|
|||||||
That is what I thought ShaneEP.. I tried it and got nothing, and I tried it again after this morning and got nothing. |
||||||||
|
|
|||||||
Just a thought... is this a 64bit OS? At the top of the script, try... Code: $RC=setoption("WOW64AlternateRegView","On") |
||||||||
|
|
|||||||
It is a 64bit that I'm developing and testing on. I'll try it and post the results.. if it is it, then I will feel like an idiot :-D Thanks! |
||||||||
|
|
|||||||
That was definitely part of it. I am now getting a registry value when I read.. It never even occurred to me to look for an option to do that. :-) My issue during testing now is I can't seem to write that value to HKCU (this is just a test.. ) I can't thank everyone enough :-) |
||||||||
|
|
|||||||
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? Code: $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) |
||||||||
|
|
|||||||
David, would you mind trying the clientname() udf again? I added your reg setting to it, and it would be good to know if it at least works for your environment. http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=205965#Post205965 |