Faithfulman
(Getting the hang of it)
2005-02-24 08:12 PM
@wksta

Hi all,

We have a bunch of users logging into a CITRIX session. When they login ... we want a KIX script to run a SQL query based on the remote computers workstation name. I have been using
@wksta but it seems to want return the name of the server.

Any thoughts??

Faithfulman


Les
(KiX Master)
2005-02-24 08:44 PM
Re: @wksta

It is doing just waht it is supposed to cuz the @WKSTA is the TS. There is at least one FAQ on the topic and a few hundred posts.

Faithfulman
(Getting the hang of it)
2005-02-24 09:37 PM
Re: @wksta

Can you be more helpful .... I am new on this forum.
I haven't seen anything on this dealing with citrix.


AllenAdministrator
(KiX Supporter)
2005-02-24 09:44 PM
Re: @wksta

I think Les is referring to this FAQ . See the second post in the FAQ.

Faithfulman
(Getting the hang of it)
2005-02-24 09:54 PM
Re: @wksta

Thanks I found what I needed

%CLIENTNAME%

THANKS!


Faithfulman
(Getting the hang of it)
2005-03-01 12:35 AM
Re: @wksta

Hi Guys,

The %CLIENTNAME% Doesn't appear to work when I'm loggin in.
I can run it after I am logged in and I seems to work fine but I need to use it in a login script.

I even used a bunch of sleep commands. Still a no go.

Any help would be appreciated! thanks!

Faithful


Kdyer
(KiX Supporter)
2005-03-01 12:40 AM
Re: @wksta

%CLIENTNAME% is available for NT or better systems. Maybe you will want to use @wksta for your W9x systems?

Kent


Bryce
(KiX Supporter)
2005-03-01 01:03 AM
Re: @wksta

kent he is talking about Citrix client logon's

Faithfulman
(Getting the hang of it)
2005-03-01 01:05 AM
Re: @wksta

ummm.... I need something that is backwards compatible all the way from Windows 95 ... connecting into a Citrix session.

But The fact still is .... If I am fully logged in and run the script it works ... but having this script as my login script it doesn't get the %CLIENTNAME%

HELP!!


AllenAdministrator
(KiX Supporter)
2005-03-01 01:47 AM
Re: @wksta

Can you provide a little of your script, specifically where the error is occuring?



Les
(KiX Master)
2005-03-01 02:13 AM
Re: @wksta

Is this a network GPO script, a local GPO script, a legacy logon script, or a Citrix usrlogon.cmd script? Does the script run sync or async?

**DONOTDELETE**
(Lurker)
2005-03-01 05:25 PM
Re: @wksta

This is a windows login script ... I'm not sure what the technical wording is nor do I know about the sync or async.
But you go into group policies to tell it to run this script as a login script.

Here is a snippet: look for %CLIENTNAME%


Code:

$connection = createobject("adodb.connection")

$ConnDSN = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=172.16.1.183;DATABASE=ncives;USER=webadmin;PASSWORD=webadmin;";OPTION=3;"

$= $connection.open($connDSN)

? @SERROR


$rs = $connection.execute("SELECT workst.wSid FROM workst WHERE workst.pcName = '" + %CLIENTNAME% + "'")

? @SERROR



Faithfulman
(Getting the hang of it)
2005-03-01 07:12 PM
Re: @wksta

Sorry guys .... my post was above ... I forgot to login.

Sealeopard
(KiX Master)
2005-03-02 12:11 AM
Re: @wksta

Use EXPANDENVIRONMENTVARS() to expand the environment variable before feeding it into the SQL statement and see also the DBCommand() UDF.

AllenAdministrator
(KiX Supporter)
2005-03-02 12:16 AM
Re: @wksta

You might try this to see what values you get.

Code:
 

break on
? "Test 1: %clientname%"

? "Test 2: "
$clientname=CreateObject("WScript.Shell").ExpandEnvironmentStrings("%CLIENTNAME%")
$clientname

? "Test 3: "
$clientname=EXPANDENVIRONMENTVARS("%clientname%")
$clientname

? "Test 4: "
$output=wshpipe('%comspec% /c set clientname',1)
for each $line in $output
split($line,"=")[1]
next

Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
Exit($oExec.ExitCode)
EndFunction



**DONOTDELETE**
(Lurker)
2005-03-02 12:42 AM
Re: @wksta

Allen, ... I tried your script and it was a no go ...

Is there something I need to do with this first?
EXPANDENVIRONMENTVARS()

Sealeopard do I just do something like this:

EXPANDENVIRONMENTVARS(%CLIENTNAME%)

?? Help!


AllenAdministrator
(KiX Supporter)
2005-03-02 12:44 AM
Re: @wksta

Quote:


I tried your script and it was a no go





Can you be more specific? What didn't work? What was the output? The script needs to be run on the Terminal Server in order for the CLIENTNAME var to exist.



Faithfulman
(Getting the hang of it)
2005-03-02 12:46 AM
Re: @wksta

I just didn't show anything where the %CLIENTNAME% should of been. It doesn't seem to be getting that value my my computer. Any other ideas??

AllenAdministrator
(KiX Supporter)
2005-03-02 12:50 AM
Re: @wksta

Try running this on the Citrix/Terminal Server... I don't think you will get a value if you run it locally on your pc.

Faithfulman
(Getting the hang of it)
2005-03-02 12:59 AM
Re: @wksta

I am running it on the Citrix Terminal Server ... I login and the login.bat runs ... which is running login.kix script. Maps some network drives and tries to query the database.

No values for %CLIENTNAME% though.

Help!


AllenAdministrator
(KiX Supporter)
2005-03-02 01:21 AM
Re: @wksta

At this point, I doubt the variable is defined at all, which may be where Les was headed with Sync/Asych issue...

One last test just to see:

Code:
 

? "Test 5: "
$output=wshpipe('%comspec% /c set',1)
for each $line in $output
if left($line,10 )="clientname"
$found=1
endif
next
if $found=1
"Var Exists"
else
"Var does not exist"
endif

Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
Exit($oExec.ExitCode)
EndFunction




Faithfulman
(Getting the hang of it)
2005-03-02 01:40 AM
Re: @wksta

I think you may be right .... with that last snippet of code
it returns:

Var does not exist

So, now what do I do.

?

Thanks for your help


Sealeopard
(KiX Master)
2005-03-02 04:28 AM
Re: @wksta

EXPANDENVIRONMENTVARS is explained in the KiXtart Manual. I suggest reading it as it also explains how to debug a script.

**DONOTDELETE**
(Lurker)
2005-03-02 05:24 PM
Re: @wksta

So are we saying that the previous posts of code ... use of EXPANDENVIRONMENTVARS ... were done incorrectly??

Because all of the above examples didn't return any value for %CLIENTNAME%.


Faithfulman
(Getting the hang of it)
2005-03-02 05:33 PM
Re: @wksta

The above message was mine. Forgot to login. Sorry.

Faithfulman
(Getting the hang of it)
2005-03-02 10:13 PM
Re: @wksta

Does anyone have a moment to help out?

Howard Bullock
(KiX Supporter)
2005-03-02 10:17 PM
Re: @wksta

Have you opened a DOS window on your Terminal server/Citrix desktop and typed "set" <enter> to see if that environment variable is there to use?

Les
(KiX Master)
2005-03-02 10:42 PM
Re: @wksta

I have tested this with a network GPO and the enviro var is not present at the moment the script runs. It is however there after logon if the same script is manually run from the desktop. I think you have no recourse but to put it into a different script run at a later time in the logon sequence. You could try putting it in the 'C:\WINNT\system32\usrlogon.cmd' script or push a link to the RunOnce reg key.

Faithfulman
(Getting the hang of it)
2005-03-02 11:28 PM
Re: @wksta

Thank you Les for all your hard work. I really could use this in the Login script.

Does anyone know how to push this variable into the initial login script??

Thanks,

Faithful


Faithfulman
(Getting the hang of it)
2005-03-03 01:16 AM
Re: @wksta

I've been thinking .....

Maybe that would work.

How could I tell the first Kix script to run a second script?

Thanks,

Faithful


Kdyer
(KiX Supporter)
2005-03-03 01:25 AM
Re: @wksta

Check out CALL..

For example -

CALL @SCRIPTDIR+'\yourscript.kix'

HTH,

Kent


AllenAdministrator
(KiX Supporter)
2005-03-03 01:36 AM
Re: @wksta

just Googleing... not sure if this will help or not, but do you have a system variable called WINSTATIONNAME?

Les
(KiX Master)
2005-03-03 01:50 AM
Re: @wksta

I take it you are still in denial. I doubt that there is anything that you can do to have that env var populated that early in the logon. Have you given thought to my two suggestions?

Les
(KiX Master)
2005-03-03 01:58 AM
Re: @wksta

Jeepers... leave my laptop for a minute and three other posts sneak in there.

CALLing another script is no good cuz the var just isn't there. YOu could push a link to the RunOnce key cuz that is the last thing processed in the logon sequence.

I just had another thought... give one of the helper apps I mention in the FAQ a go. Warren Simondson's ClientInfo should be able to pull what you need since it does not rely on the env var.


NTDOCAdministrator
(KiX Master)
2005-03-03 02:27 AM
Re: @wksta

Well you may be able to just sleep the script for a while if needed. Since Les has experience in this area perhaps he can answer that question. If so, just place a sleep command in your script to wait for this to become available and then it will continue after the sleep.


Les
(KiX Master)
2005-03-03 02:46 AM
Re: @wksta

DOC,
Think about it for a second. KiX inherits whatever is in the env at the time it is invoked. SLEEPing for a million years won't change was isn't there.


Richard H.Administrator
(KiX Supporter)
2005-03-03 09:36 AM
Re: @wksta

Another solution is to use the CTXCINFO.EXE program I cobbled together some time ago to return client information, or Howard Bullocks helper DLLs.

The former definately returns the client name, and I suspect the latter does too.

The site that used to host ctxcinfo.exe is no longer available, so if you want it let me know and I will post it to you.

It was originally documented here

Information on Howards DLL can be found in the Citrix/Terminal Server FAQ.


Les
(KiX Master)
2005-03-03 02:50 PM
Re: @wksta

or http://www.kixhelp.com/downloads.htm

Faithfulman
(Getting the hang of it)
2005-03-03 05:41 PM
Re: @wksta

Hi All,

Thanks for all your input, I do appreciate it.

I tried calling the second script from the first and Les you were right I got the same result.

Anyway, I need help than ... how would I do this:

Quote:


I think you have no recourse but to put it into a different script run at a later time in the logon sequence.




If I did the RegOnce thingy ... how is this accomplished.

Let me know.

Thanks,

Faithful


Howard Bullock
(KiX Supporter)
2005-03-03 05:50 PM
Re: @wksta

You could try http://home.comcast.net/~habullock/Perlutilities.htm ClientData.exe and WshPipe UDF to get your information from the user's logon script if were to be execute in a Citrix/terminal server session.



Faithfulman
(Getting the hang of it)
2005-03-03 06:24 PM
Re: @wksta

Les when you get a chance could you explain your example. I prefer not to use an executable. I would just like to be able to run a simple kix script.

Thanks


Les
(KiX Master)
2005-03-03 08:42 PM
Re: @wksta

Maybe saomething like this untested Code:
$RC = WriteValue("HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce","KiXScript","\\server\share\wkix32.exe \\server\share\script.kix","REG_SZ")



ShawnAdministrator
(KiX Supporter)
2005-03-03 09:23 PM
Re: @wksta

My buddy here (named Steve) just tried querying %CLIENTNAME% in an async login script, logging into terminal services, and was able to see %CLIENTNAME% resolve ok - fyi !

Faithfulman
(Getting the hang of it)
2005-03-03 09:32 PM
Re: @wksta

Can we change the script from SYNC to ASYNC??

Les, I tried your example ... and it works but you have to login once and then log off ... then log on again.

Can I just make it so it works the first time and then from there on??
Thanks,

Faithful


ShawnAdministrator
(KiX Supporter)
2005-03-03 09:45 PM
Re: @wksta

My buddy here just tried it using SYNC, and it still worked great - he's running Windows 2003 Terminal Services btw - fwiw idk.

ShawnAdministrator
(KiX Supporter)
2005-03-03 10:09 PM
Re: @wksta

Steve's script was just simply:

echo %CLIENTNAME%
pause


Faithfulman
(Getting the hang of it)
2005-03-03 11:37 PM
Re: @wksta

Well that isn't working for whatever reason Shawn.

Anyway, I just found out I have another Delima ....
We are Using NFUSE ... does anyone here use this program?
So, this kix script instead of showing the clientname...
(which it does cause we are telling it to run as a seperate script in the Registry RunOnce)
But In NFUSE the CLIENTNAME variable is changed to

DOMAIN\username

OY!!!

Anyone worked around NFUSE before?

(BTW - ours our running Win2K ... and logging in through Citrix)


NTDOCAdministrator
(KiX Master)
2005-03-04 12:21 AM
Re: @wksta

Are they only being offered the application, or are they offered the full desktop.


AllenAdministrator
(KiX Supporter)
2005-03-04 12:33 AM
Re: @wksta

To answer your lastest question... this may help... Source
Quote:


For NFUSE remove the open C:\Program Files\Citrix\NFuse\template.ica in notepad.

Find the line
[WFClient]
Version=2
ClientName="Userlogin (something like that)"

and change to

[WFClient]
Version=2
ClientName=

Then computer name will be used instead.






And here is something that may apply to you as well: Source
Quote:


Issue

After entering a value for the client name parameter inside an ICA file that is created manually, generated by NFuse, or with the Citrix Management Console, the value is not read when the session is subsequently launched in an embedded HTML or NFuse Web page.

The value, however, is read when a session is launched as a separate window.

Example:

[WFClient]
Version=2
TcpBrowserAddress=x.x.x.x
ClientName=yourclientname

Resolution

This behavior is by design.








Les
(KiX Master)
2005-03-04 01:01 AM
Re: @wksta

Quote:

Les, I tried your example ... and it works but you have to login once and then log off ... then log on again.

Can I just make it so it works the first time and then from there on??



You could hand-job it into HKLM\...\Run instead of scripting it into HKCU\...\RunOnce.


Faithfulman
(Getting the hang of it)
2005-08-31 12:24 AM
Re: @wksta

Hi all,

I have taken this login script out of the login policy but apparently
the script still shows up in the registry and hasn't left. Any idea as
to why it doesn't go away?


StarwarsKid
(Seasoned Scripter)
2005-08-31 05:30 PM
Re: @wksta

Is the computer name stored in the registry somewhere in Win9x? I know in XP you have a few references, one of which being the distinguished name, which could be stripped down to the simple computer name.

Here's another example...
Quote:

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName]
"ComputerName"="PROMETHEUS"




????