#124783 - 2004-08-12 10:57 AM
How to specify "User Name" parameter in a Delete command ?
|
westham
Fresh Scripter
Registered: 2003-05-28
Posts: 16
|
I need to delete the normal.dot file from C:\Documents and Settings\username.domain\Application Data\Microsoft\Templates folder where username is my Windows 2000 AD user account and domain is my Windows 2000 domain. Anyone has any idea how this can be done via kix logon script ?
I know I can use $user=@userid to get the Windows 2000 AD user account. But it seems that I can't incorporate this into the delete command to delete the normal.dot file.
Cheers
|
|
Top
|
|
|
|
#124785 - 2004-08-12 12:03 PM
Re: How to specify "User Name" parameter in a Delete command ?
|
westham
Fresh Scripter
Registered: 2003-05-28
Posts: 16
|
$user=@userid
del C:\Documents and Settings\"$user".DOMAIN\Application Data\Microsoft\Templates\normal.dot where DOMAIN is the domain name
OR
del C:\Documents and Settings\$user.DOMAIN\Application Data\Microsoft\Templates\normal.dot where DOMAIN is the domain name
This may looks silly... was just trying my luck...
|
|
Top
|
|
|
|
#124787 - 2004-08-12 12:20 PM
Re: How to specify "User Name" parameter in a Delete command ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
...but you really shouldn't be hard coding it.
What is your environment variable %USERPROFILE% set to? Code:
"Profile path is: "+%USERPROFILE% ?
|
|
Top
|
|
|
|
#124788 - 2004-08-12 12:33 PM
Re: How to specify "User Name" parameter in a Delete command ?
|
westham
Fresh Scripter
Registered: 2003-05-28
Posts: 16
|
this is getting nearer as i did not encountered any error while executing the stm... however, the file was not deleted at all...
tried all the followings but somehow the file just don't get deleted:-
del "C:\Documents and Settings\" + @userid + ".DOMAIN\Application Data\Microsoft\Templates\normal.dot"
del "C:\Documents and Settings\" + "@userid" + ".DOMAIN\Application Data\Microsoft\Templates\normal.dot"
del "C:\Documents and Settings\" + $user + ".DOMAIN\Application Data\Microsoft\Templates\normal.dot"
del "C:\Documents and Settings\" + "$user" + ".DOMAIN\Application Data\Microsoft\Templates\normal.dot"
|
|
Top
|
|
|
|
#124789 - 2004-08-12 12:36 PM
Re: How to specify "User Name" parameter in a Delete command ?
|
westham
Fresh Scripter
Registered: 2003-05-28
Posts: 16
|
i can't locate this environment variable %USERPROFILE%... do we have that by default ? not too familiar with environment variable thingy... appreciate if u cld elaborate... thanks
|
|
Top
|
|
|
|
#124790 - 2004-08-12 12:54 PM
Re: How to specify "User Name" parameter in a Delete command ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Open a DOS console and type "set" - you should see all your environment variables.
It's present in Win XP, I don't have a 2K box to hand to check.
If the delete fails it will do so silently. To check the status, use the @ERROR macro.
After you delete command, add the following line: Code:
"Delete status was "+@ERROR+": "+@SERROR+@CRLF
This should give you a "0" status (which is success), or a value which indicates what the error was.
|
|
Top
|
|
|
|
#124793 - 2004-08-13 04:39 AM
Re: How to specify "User Name" parameter in a Delete command ?
|
westham
Fresh Scripter
Registered: 2003-05-28
Posts: 16
|
del "%USERPROFILE%" + "\Application Data\Microsoft\Templates\normal.dot"
The above works Mine is a Windows XP machine too.
Thanks alot, Richard ! Thanks to all who ve contributed too !
|
|
Top
|
|
|
|
#124794 - 2004-08-13 10:30 AM
Re: How to specify "User Name" parameter in a Delete command ?
|
Anonymous
Anonymous
Unregistered
|
Then you could also use:
del "%AppData%\Microsoft\Templates\normal.dot"
gr, DS
|
|
Top
|
|
|
|
#124795 - 2004-08-13 02:18 PM
Re: How to specify "User Name" parameter in a Delete command ?
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Or you could do it this way.. Code:
$RegKey='HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders' $Templates=READVALUE($RegKey,'Templates') DEL $Templates+'\Normal.Dot'
HTH,
Kent
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 633 anonymous users online.
|
|
|