hama007
(Fresh Scripter)
2012-03-08 03:54 PM
kix with 2008r2 terminalserver + %clientname%

hi have a problem with windows 2008 terminalserver and kix

on my running windows terminalserver 2003 i can use in the kix %clientname%
on the new windows 2008 ts i run my script and have no output for %clientname%

i open cmd.exe and start my kix script manual, the variable "clientname" set and my script is running good!


LonkeroAdministrator
(KiX Master Guru)
2012-03-08 05:29 PM
Re: kix with 2008r2 terminalserver + %clientname%

%clientname% is not a kixtart variable but a environment one.

there is the fact that if you are using admin session, the %clientname% should always be empty.


LonkeroAdministrator
(KiX Master Guru)
2012-03-08 05:38 PM
Re: kix with 2008r2 terminalserver + %clientname%

nevermind the previous post. instead try setting "Run logon scripts synchronously" in the gpo
on the server: User Configuration/Administrative Templates/System/Scripts


hama007
(Fresh Scripter)
2012-03-13 11:45 AM
Re: kix with 2008r2 terminalserver + %clientname%

the problem is the same!!!

any idee?

in the kix file i do this

$client = %clientname%

in windows 2003 it runs in windows 2008 r2 not


BradV
(Seasoned Scripter)
2012-03-13 01:35 PM
Re: kix with 2008r2 terminalserver + %clientname%

Have you tried @hostname instead?

LonkeroAdministrator
(KiX Master Guru)
2012-03-13 02:43 PM
Re: kix with 2008r2 terminalserver + %clientname%

I still suggest "my" solution. cause it was the one given by MS. ;\)
just in case you should see the effective policy for logged in user.


hama007
(Fresh Scripter)
2012-03-14 08:32 AM
Re: kix with 2008r2 terminalserver + %clientname%

@hostname = name of my terminalserver, i need the name of the client from the user

BradV
(Seasoned Scripter)
2012-03-14 11:15 AM
Re: kix with 2008r2 terminalserver + %clientname%

OK, how about %computername%? If you have MS office installed, read
 Code:
HKCU\Software\Microsoft\Office\12.0\Outlook\Machine Name
I also found
 Code:
HKCU\Software\Microsoft\Windows\ShellNoRoam\(Default)
and
 Code:
 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Distinguished-Name
or
 Code:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName
There are many more. I don't have a citrix setup, so I can't really search for any specific entries relative to that.


AllenAdministrator
(KiX Supporter)
2012-03-14 12:26 PM
Re: kix with 2008r2 terminalserver + %clientname%

I have not tested this personally as I don't have a Terminal Server environment, but another member posted the code, and I converted it to a UDF... please follow up and say if this works for you. If so, I'll post this to the UDF Forum.

Clientname() -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=202786#Post202786

*Requires*
GetSessionID() -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=137632#Post137632

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1



AllenAdministrator
(KiX Supporter)
2012-03-16 04:21 AM
Re: kix with 2008r2 terminalserver + %clientname%

hmmm, guess hama missed this. Can someone check this to make sure it is working as advertised?

BradV
(Seasoned Scripter)
2012-03-16 10:57 AM
Re: kix with 2008r2 terminalserver + %clientname%

There is a citrix setup at one of our other buildings. I probably won't be able to get to it until some time next week. I can test it then.

Glenn BarnasAdministrator
(KiX Supporter)
2012-03-16 01:47 PM
Re: kix with 2008r2 terminalserver + %clientname%

We have a W2K8r2 TS farm in the office - it works as advertised. I'd create & post a complete UDF without any dependency.

Glenn


AllenAdministrator
(KiX Supporter)
2012-03-16 02:37 PM
Re: kix with 2008r2 terminalserver + %clientname%

I was going to merge them before I even posted above, but I looked at getsessionid... I believe it is recursive. The biggest problem I have if I wr-write it, I don't have any way to test it.

Glenn BarnasAdministrator
(KiX Supporter)
2012-03-16 02:55 PM
Re: kix with 2008r2 terminalserver + %clientname%

I'll take a look at it and see if I can bring them together and test. Then we can post it with references to the UDF that were blatantly plagerized. \:D

I'll post back here when complete.

Glenn


AllenAdministrator
(KiX Supporter)
2012-03-16 03:24 PM
Re: kix with 2008r2 terminalserver + %clientname%

Sometimes I wonder what my eyes are seeing \:\( I just looked again, and don't see what I thought made it recursive. WTH? Old age?

Please do the "hard work" Glenn... it has to be easier than me doing it and asking someone/you to test it. \:\)



Glenn BarnasAdministrator
(KiX Supporter)
2012-03-16 03:27 PM
Re: kix with 2008r2 terminalserver + %clientname%

Considering I probably have a decade or so on you... I just bit my tongue regarding the whole Recursive thing! (thought I missed it, actually!)

\:D

I should have time after lunch to knock it out and test.

Glenn


LonkeroAdministrator
(KiX Master Guru)
2012-03-16 07:03 PM
Re: kix with 2008r2 terminalserver + %clientname%

old farts being polite or what is this? :P

Glenn BarnasAdministrator
(KiX Supporter)
2012-03-16 07:03 PM
Re: kix with 2008r2 terminalserver + %clientname%

OK - looking at this...

%CLIENTNAME% is populated on my server, so I'm adapting the UDF to use this if defined and only proceed with more complex methods if not.

Does anyone know why HKU\@SID is used instead of HKCU to get to the Volatile Settings? At first blush, it seems more complex than necessary.

Glenn


LonkeroAdministrator
(KiX Master Guru)
2012-03-16 07:37 PM
Re: kix with 2008r2 terminalserver + %clientname%

comes back to the fact that clientname should be always populated, unless logonscript is not ran in sync.
after logon, it is populated when in the session you go and check it out.

that said, your approach should add the foolproof aspect to it.


AllenAdministrator
(KiX Supporter)
2012-03-29 08:40 PM
Re: kix with 2008r2 terminalserver + %clientname%

Okay so if I read the comments right, I think I have included the changes...

Someone want to test this?

 Code:
function ClientName()
  select
    case len(%clientname%)
      $clientname=%clientname%
    case InStr(@PRODUCTTYPE,"Server 2008")
      Dim $s_sessionid, $iIndex, $sessionid
      $s_sessionid = SubStr(%TEMP%,1+InStrRev(%TEMP%,"\"))
      While $s_sessionid <> ""
        $iIndex = InStr("0123456789ABCDEF",Left($s_sessionid,1))
        If $iIndex
          $SessionID = $GetSessionID*16+(Cint($iIndex-1))
          $s_sessionid = SubStr($s_sessionid,2)
        Else
          $SessionID = 0
          $s_sessionid = ""
        EndIf
      Loop
      $ClientName = ReadValue("HKCU\Volatile Environment\" + $sessionid,"CLIENTNAME")
    case InStr(@PRODUCTTYPE,"Server 2003")
      $ClientName = ReadValue("HKCU\Volatile Environment","CLIENTNAME")
    case 1  
      $ClientName = @WKSTA
  endselect
endfunction


LonkeroAdministrator
(KiX Master Guru)
2012-03-30 02:44 AM
Re: kix with 2008r2 terminalserver + %clientname%

hmm. Why case 1 is @wksta?

AllenAdministrator
(KiX Supporter)
2012-03-30 04:10 AM
Re: kix with 2008r2 terminalserver + %clientname%

That's how it was in the original. No way for me to test... just trying to get this done. \:\)

Seems like if you were running this in a normal logon script you might have a mix of terminal servers clients and regular pc users. I suppose it might make sense to return the pc name for the pcs.


AllenAdministrator
(KiX Supporter)
2012-10-09 04:26 PM
Re: kix with 2008r2 terminalserver + %clientname%

Here is an updated version (but still untested) that allows you to find the clientname in the XenDesktop as well. Someone with XenDesktop or any of the other environments please try this out and post your results.

 Code:
function ClientName()
  Dim $AltRegView
  $AltRegView=setoption("WOW64AlternateRegView","On")
  select
    case len(%clientname%)
      $clientname=%clientname%
    case readvalue("HKLM\Software\Citrix\ICA\Session", "ClientName")
      $clientname=readvalue("HKLM\Software\Citrix\ICA\Session", "ClientName")
    case InStr(@PRODUCTTYPE,"Server 2008")
      Dim $s_sessionid, $iIndex, $sessionid
      $s_sessionid = SubStr(%TEMP%,1+InStrRev(%TEMP%,"\"))
      While $s_sessionid <> ""
        $iIndex = InStr("0123456789ABCDEF",Left($s_sessionid,1))
        If $iIndex
          $SessionID = $GetSessionID*16+(Cint($iIndex-1))
          $s_sessionid = SubStr($s_sessionid,2)
        Else
          $SessionID = 0
          $s_sessionid = ""
        EndIf
      Loop
      $ClientName = ReadValue("HKCU\Volatile Environment\" + $sessionid,"CLIENTNAME")
    case InStr(@PRODUCTTYPE,"Server 2003")
      $ClientName = ReadValue("HKCU\Volatile Environment","CLIENTNAME")
    case 1  
      $ClientName = @WKSTA
  endselect
  $AltRegView=setoption("WOW64AlternateRegView",$AltRegView)
endfunction


Glenn BarnasAdministrator
(KiX Supporter)
2013-07-29 07:59 PM
Re: kix with 2008r2 terminalserver + %clientname%

I checked this in my lab:

 Code:
O/S          Env Var Set       Result
Server 2K3      Yes            Success
Server 2K8r2    Yes            Success
Server 2K12     No             Success


Glenn


AllenAdministrator
(KiX Supporter)
2013-08-02 03:05 PM
Re: kix with 2008r2 terminalserver + %clientname%

And to follow up.... here is the link to the UDF posted in the UDF Forum. The most current version will be there.

http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=207561#Post207561

Special thanks to Glenn for his time and willingness to check it out. Also, thanks to everyone who contributed on this function as this truly was a community effort.