How to use different logon scripts for the same users logging on to both workstations and citrix in the same domain

Hi,

I have a citrix XP setup on w2k servers with a remote site connected to the citrix site via vpn. The computers on the remote site are members of the same domain as the citrix servers and the domain controller is placed in the citrix site. That means that the users when logging unto their computers are using the same usersname as when logging unto citrix and thus the same login script. My problem is that I do not want the same printers and network drives attached when they are logging into citrix as when logging into their computers. We are using a bat file and a vbs script for login. So here is my question: how can I make two seperate login scripts for the same username : one for citrix and one for the computer, or else how can I in the same login script seperate what lines should be executed depending on if the user is logging into citrix or the computer ?

Br Kasper
kasperprentowAsked:
Who is Participating?
 
oBdACommented:
You can use the environment variable %COMPUTERNAME% to check on which machine your users are logging on. This will be set either to the workstation name or the Citrix server name.
If there's only one Citrix server, you can simply use

@echo off
if /i not "%ComputerName%"=="YourCitrixServer" goto CitrixEnd
:: *** This part is only executed when logging on to the Citrix machine:

:: *** Citrix part ends here.
:CitrixEnd

If you have several machine, you can use a list:

@echo off
set CitrixServer=Citrix01 Citrix02 Citrix03
set Citrix=FALSE
for %%a in (%CitrixServer%) do if /i "%ComputerName%"=="%%a" set Citrix=TRUE
if /i %Citrix%==FALSE goto CitrixEnd
:: *** This part is only executed when logging on to the Citrix machine:

:: *** Citrix part ends here.
:CitrixEnd
0
 
LongbowCommented:
When logged on on the Domain this registry key will change. The value is or the DomainName or the ComputerName.
Not sure if it is the case when the logon dialog box is opened (and the logon has not begin)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName="DomainName"
0
 
talphiusCommented:
What we do is add some logic to our one master login script that everyone uses.  There's a few ways to do this - 1)  You can do it on Operating System type (assuming you don't want the drives to map on regular servers either), or 2)  On Drive letter on the Citrix Server (All of ours are set to M:\ as the default drive, as to avoid drive letter conflicts when local client drives map on login)



****  Here's the revelant pieces - you will need to customize for Option 1: ****

'Connect to WMI on local machine to pull OS Type
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
      strOSCaption = objOperatingSystem.Caption
      strOSVer = objOperatingSystem.Version
      strSPMajor = objOperatingSystem.ServicePackMajorVersion
      strSPMinor = objOperatingSystem.ServicePackMinorVersion    
      windir = objOperatingSystem.WindowsDirectory
Next

Select Case strOSCaption
      Case "Microsoft Windows 2000 Professional"
            OSType = "Workstation"
      Case "Microsoft Windows XP Professional"
            OSType = "Workstation"
      Case "Microsoft Windows XP Tablet PC Edition"
            OSType = "Workstation"
      Case "Microsoft Windows XP Home"
            OSType = "Workstation"
      Case "Microsoft Windows 2000 Server"
            OSType = "Server"
      Case Else
            OSType = "Unknown"
End Select

If OSType = "Workstation" Then
<<Action Here>>

If OSType = "Server" Then
<<Action Here>>


**** For Option 2: ****

If Windir = "M:\WINNT" Then
      TSServer = True
End If


'Map Terminal Server drive mappings
If TSServer Then
<<Action Here>>


If Not TSServer  Then
<<Action Here>>
0
 
anilskvCommented:
Another way would be to use the "%SESSIONNAME% environment variable. This variable is set to "Console" for local logons andset to "RDP-TCP#x" for logon using terminal services.

if %SESSIONNAME%==Console goto console

:TS
... terminal services related stuff goes here
...
goto end

:console
... local logon related stuff goes here
...
goto end

:end

Also, the environment variable "%CLIENT_NAME%" is set to the name of the machine from which the terminal services client is running. For a local logon, this envronment variable is not defined.

if defined %CLIENT_NAME% goto TS

:console
... local logon related stuff goes here
...
goto end

:TS
... terminal services related stuff goes here
...
goto end

:end
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.