Page 1 of 2 12>
Topic Options
#156831 - 2006-02-07 07:16 PM using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
using Kixtart 3.6 - workstation is Windows XP

I am trying to use the login script to copy a word template to a particular location in every user's local profile. The variable is the user name, so I am trying to use @USERID
This does not work--
I am pretty new at this-- could someone give me a hand?

This is the syntax I am using...

copy "\\mm_cluster\mltwdata\mltw common\microsoft user\wd global\MLTWwd2k3.dot" "c:\documents and settings\@USERID\application data\microsoft\word\startup\" /c /r

(just as a test I made the destination C:\temp and that worked.)

thanks a lot!
Jack

Top
#156832 - 2006-02-07 07:47 PM Re: using copy command with @userid
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Try:

Code:
copy "\\mm_cluster\mltwdata\mltw common\microsoft user\wd global\MLTWwd2k3.dot" "c:\documents and settings\" + @USERID + "\application data\microsoft\word\startup\" /c /r 



An alternative could also be to look in the All Users profile. I'm not sure how that works with document templates but just another possible avenue maybe.

You could also try %username% also.

Top
#156833 - 2006-02-07 07:51 PM Re: using copy command with @userid
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Never hardcode @UserID in a path. 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
#156834 - 2006-02-07 07:53 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
thanks-- I tried your suggestion " + @USERID + "
it didn't work....

Yeah-- can't use All Users - Word templates are individual profile specific...

Top
#156835 - 2006-02-07 07:53 PM Re: using copy command with @userid
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Additionally, since this is a logon script, I'd recomment using environment variables like %systemdrive% unless you're absolutely sure that users don't have the the OS installed on a different drive letter other than C:
Top
#156836 - 2006-02-07 07:54 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
"Never hardcode @UserID in a path. Pull it from the reg. "

how exactly do I do that, and incorporate it into the path?

Top
#156837 - 2006-02-07 07:55 PM Re: using copy command with @userid
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Why not use @UserID Les? Are you saying to pull the logged on user from the registry instead? If so, then what's the point of that macro?
Top
#156838 - 2006-02-07 07:59 PM Re: using copy command with @userid
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No.
What I am saying is that the path does not always have @UserID in it so it can bite. The reg location:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
will hold all the pertinent paths.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156839 - 2006-02-07 08:03 PM Re: using copy command with @userid
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Ah yes. Thank you for the clarification.
Top
#156840 - 2006-02-07 08:12 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
If I am understanding you correctly-- does this look kosher?

$Path = ReadValue "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\AppData", "")

copy "\\mm_cluster\mltwdata\mltw common\microsoft user\wd global\MLTWwd2k3.dot" "$Path\microsoft\word\startup\" /c /r

Top
#156841 - 2006-02-07 08:18 PM Re: using copy command with @userid
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
no.. you'd probably write the regvalue using WriteValue() instead
Top
#156842 - 2006-02-07 08:31 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
actually I just tried both-- not working... (i did add the parenthesis I was missing in my previous post)
something not right with it....

Top
#156843 - 2006-02-07 08:36 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
but-- looking at this-- I don't want to WRITE a value to the registry.
I want to read it, assign it to a variable, and plug it into the path.

Top
#156844 - 2006-02-07 08:47 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
this is what i am trying...

$Path =ReadValue ("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "AppData")

copy "\\mm_cluster\mltwdata\mltw common\microsoft user\wd global\MLTWwd2k3.dot" "$Path\microsoft\word\startup\" /c /r

I want $PATH to be the registry value of the AppData key.
Am I improperly using the $Path string in the path?
help..

Top
#156845 - 2006-02-07 09:12 PM Re: using copy command with @userid
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Try using a conditional to troubleshoot white...

If Exist %Path_You're_Looking_For%
? $Path
Copy Your_String
Else
? Possible problem.
Endif

Error checkings always helps me in troubleshooting.

Edit: I don't know if Copy() returns an error code but if it does, check @ERROR to see what the problem is.


Edited by thepip3r (2006-02-07 09:14 PM)

Top
#156846 - 2006-02-07 09:24 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
pip - sorry-- I don't understand what you mean by the conditional you posted...
like i said-- I am new at this, and just trying to teach myself as quick as I can...

Top
#156847 - 2006-02-07 09:34 PM Re: using copy command with @userid
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Something like this.


Code:

Break On
 
Dim $Path
$Path = ReadValue ('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders','AppData')
If Exist($Path+'\microsoft\word\startup\')
'Path found: ' + $Path+'\microsoft\word\startup\' ?
Copy '\\mm_cluster\mltwdata\mltw common\microsoft user\wd global\MLTWwd2k3.dot' $Path+'\microsoft\word\startup\' /c /r
'Copy error was: ' + @ERROR + ' ' + @SERROR ?
Else
'Path not found' + @ERROR + ' ' + @SERROR ?
EndIf


 
 


Edited by NTDOC (2006-02-07 09:35 PM)

Top
#156848 - 2006-02-07 09:40 PM Re: using copy command with @userid
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
If your string above is EXACTLY what you're typing, you need to re-look at ReadValue() - Between the ReadValue($subkey,$entry) -- you're missing a comma.

Edit: Thanx for the clarification NTDOC

Top
#156849 - 2006-02-07 09:52 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
thanks-- i do actually have the comma..

I found another way- don't need to pull from registry-- XP has environmental variables %homedrive%%homepath%
this gives you--
C:\Documents and Settings\%username%

from there I should be able to append \application data\microsoft\word\startup\

copy "\\mm_cluster\mltwdata\mltw common\microsoft user\wd global\MLTWwd2k3.dot" "%homedrive%%homepath%\application data\microsoft\word\startup\" /c /r /h

this SHOULD work. but it doesn't.
so I tried this to troubleshoot...
copy "\\mm_cluster\mltwdata\mltw common\microsoft user\wd global\MLTWwd2k3.dot" "%homedrive%%homepath%" /c /r /h

This worked! So what is the problem with the rest of the path??

Top
#156850 - 2006-02-07 10:15 PM Re: using copy command with @userid
whitemtntn Offline
Fresh Scripter

Registered: 2006-02-07
Posts: 12
I may have figured out what's wrong -- maybe...
the APPLICATION DATA directory is read-only and hidden

I just read that the Kixtart Copy command switches /c and /r
were added with the release of v4.22
I am using version v3.6

possible?

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 811 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

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

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