Page 1 of 1 1
Topic Options
#149466 - 2005-10-07 04:13 PM problem with %USERPROFILE%
paulathhl Offline
Lurker

Registered: 2005-10-07
Posts: 3
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

Top
#149467 - 2005-10-07 04:23 PM Re: problem with %USERPROFILE%
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Does not %USERPROFILE% already include the drive letter?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149468 - 2005-10-07 04:36 PM Re: problem with %USERPROFILE%
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
yeah, it sounds like he needs @userid or %username%
Top
#149469 - 2005-10-07 04:51 PM Re: problem with %USERPROFILE%
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Better still would be to pull it from the reg.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149470 - 2005-10-07 07:04 PM Re: problem with %USERPROFILE%
StarwarsKid Offline
Seasoned Scripter
*****

Registered: 2005-06-15
Posts: 506
Loc: Oregon, USA
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
_________________________
let the wise listen and add to their learning,
and let the discerning get guidance- Proverbs 1:5

Top
#149471 - 2005-10-10 11:55 AM Re: problem with %USERPROFILE%
paulathhl Offline
Lurker

Registered: 2005-10-07
Posts: 3
The %username% did the trick for me, the %userprofile% showed the local userdirectory as mentioned.

Thanks for the advise guys

Top
#149472 - 2005-10-10 04:17 PM Re: problem with %USERPROFILE%
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#149473 - 2005-10-10 06:45 PM Re: problem with %USERPROFILE%
paulathhl Offline
Lurker

Registered: 2005-10-07
Posts: 3
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?
Top
#149474 - 2005-10-11 10:19 AM Re: problem with %USERPROFILE%
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
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.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.057 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org