paulathhl
(Lurker)
2005-10-07 04:13 PM
problem with %USERPROFILE%

Hi,

I'm new to KIXTART.
I'm trying to use a short kixtart script to set the users default printer in a metaframe farm with multiple servers and roaning profiles on server applic2.
The script below only works when I replace %USERPROFILE% with the actual domain username (testcitrix). log in as this user while a run the script of course...
Anybody knows the reason?

use u: \\applic2\profiles
IF NOT EXIST ("u:\%USERPROFILE%\DFPrint.ini")
copy "c:\winnt\Application Compatibility Scripts\DFPrint\DFPrint.ini" "u:\%USERPROFILE%\DFPrint.ini" /s/h
ENDIF

shell "%systemroot%\Application Compatibility Scripts\DFPrint\SetDefaultPrinter.exe"
$RegDFPrint = Readvalue("HKEY_Current_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows","Device")
$Result = writeprofilestring("u:\%USERPROFILE%\DFPrint.ini","DFPrint" ,"DFPrint", $RegDFPrint)
use u: /del


Les
(KiX Master)
2005-10-07 04:23 PM
Re: problem with %USERPROFILE%

Does not %USERPROFILE% already include the drive letter?

maciep
(Korg Regular)
2005-10-07 04:36 PM
Re: problem with %USERPROFILE%

yeah, it sounds like he needs @userid or %username%

Les
(KiX Master)
2005-10-07 04:51 PM
Re: problem with %USERPROFILE%

Better still would be to pull it from the reg.

StarwarsKid
(Seasoned Scripter)
2005-10-07 07:04 PM
Re: problem with %USERPROFILE%

Doing an ECHO %USERPROFILE% from a dos prompt returns the local path for the profile on my computer. I.E. C:\Documents and Settings\mranderson

You'll need to use another variable instead of %userprofile% (like maciep's suggested @userid) to accomplish your task.

BTW, This might be a helpful resource for you. Environment Variables - Windows 2000/XP


paulathhl
(Lurker)
2005-10-10 11:55 AM
Re: problem with %USERPROFILE%

The %username% did the trick for me, the %userprofile% showed the local userdirectory as mentioned.

Thanks for the advise guys


Les
(KiX Master)
2005-10-10 04:17 PM
Re: problem with %USERPROFILE%

You were on the right track with %USERPROFILE% only you doubled up on the drive. It is bad practice to use %username% since it will not always prove correct as when you rename a user account or duplicates exist.

paulathhl
(Lurker)
2005-10-10 06:45 PM
Re: problem with %USERPROFILE%

Les, I know about this problem with %username%, but my problem now is that the %userprofile% is pointing to the local profile and I need to copy these parameters to the roaming profiles (only for Terminal service users) located on a different server. What if we put the \profiles\%username% in the user accounts TS profile directory instead of the actual username?

Richard H.Administrator
(KiX Supporter)
2005-10-11 10:19 AM
Re: problem with %USERPROFILE%

Quote:

%userprofile% is pointing to the local profile




Correct. When you log on this is the profile you use - it is a copy of your roaming profile.

Quote:

I need to copy these parameters to the roaming profiles (only for Terminal service users) located on a different server




I doubt it. The roaming profile is overwritten/merged by the local copy of the profile when the user logs off so any changes that you make may well be lost.

You therefore need to set the values in the local profile once the user has logged on. When they log off the values will be copied back to their roaming profile location.

If for some strange reason you really do want to write to the roaming profile, you can get the path directly from the user account - much safer than trying to guess it. You may need to manually expand environment variables.