Page 1 of 1 1
Topic Options
#169395 - 2006-10-13 07:00 PM Deleting folder contents in users "Documents and Settings "
5paack Offline
Lurker

Registered: 2006-10-13
Posts: 3
I am trying to delete the contents of "c:\Documents and Settings\username\Oracle Jar Cache" when the user logs out.
I can create a script that will delete these files if I use the current username in the code but if I want to use this across the board how do I change the username? Is there a wildcard that I can use? I have tried %username% but that didn’t work.

Help

Top
#169396 - 2006-10-13 07:45 PM Re: Deleting folder contents in users "Documents and Settings "
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
@UserID - Current users Windows NT user ID
Top
#169397 - 2006-10-13 07:52 PM Re: Deleting folder contents in users "Documents and Settings "
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
if you want to do it when user logs off, as the user, you have no choice.
if you do remote scripting, then you can do some reg check of dir scanning.

but keeping it simple, %username% or @userid and doing logoff script is the simpliest way.

Top
#169398 - 2006-10-14 01:17 AM Re: Deleting folder contents in users "Documents and Settings "
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You should never use a username or @UserID macro as part of the profile path.
Top
#169399 - 2006-10-14 01:47 AM Re: Deleting folder contents in users "Documents and Settings "
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Code:

If NOT @LOGONMODE
Break On
Else
Break Off
EndIf
Dim $SO
$SO = SetOption("Explicit","On")
$SO = SetOption("NoMacrosInStrings","On")
$SO = SetOption("NoVarsInStrings","On")
$SO = SetOption("WrapAtEOL","On")

CreateSpecialFolderVars()

? $AllUsersStartMenu

Function CreateSpecialFolderVars()
Dim $OldExplicitOption
$OldExplicitOption = SetOption("Explicit","Off")
$AllUsersStartMenu = GetSpecialFolders(22)[1] ;2K/XP
$OldExplicitOption = SetOption("Explicit",$OldExplicitOption)
EndFunction

Function GetSpecialFolders($Folder)
Dim $objFolderItem
$objFolderItem=CreateObject('Shell.Application').Namespace($Folder).Self
$GetSpecialFolders=$objFolderItem.Name,$objFolderItem.Path
EndFunction


Top
#169400 - 2006-10-14 01:58 AM Re: Deleting folder contents in users "Documents and Settings "
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Or use %USERPROFILE% assuming current user... or read the profile path from the registry.
Top
#169401 - 2006-10-19 10:12 PM Re: Deleting folder contents in users "Documents and Settings "
5paack Offline
Lurker

Registered: 2006-10-13
Posts: 3
Thank you all for your replys,
The %username% worked to delete the directory contents, just had to get the syntax right.

;Clean out Oracle Jar Cache
? "Cleaning out Oracle Jar Cache files..."
Del "C:\Documents and Settings\%username%\Oracle Jar Cache\*.*"

Thanks

Top
#169402 - 2006-10-19 10:31 PM Re: Deleting folder contents in users "Documents and Settings "
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
which is poor mans version of:
Code:

Del "%userprofile%\Oracle Jar Cache\*.*"


Top
#169403 - 2006-10-23 12:33 PM Re: Deleting folder contents in users "Documents and Settings "
craigs9 Offline
Fresh Scripter

Registered: 2006-07-05
Posts: 22
Loc: London, UK
Quote:

You should never use a username or @UserID macro as part of the profile path.



Why is that? How should you go about it then?

Top
#169404 - 2006-10-23 12:48 PM Re: Deleting folder contents in users "Documents and Settings "
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Why is that?




Because while it will work most of the time, it will not work all of the time.

For various reasons Windows may decide to append ".001" or the domain name to the local profile. One common cause is permissions problems.

Top
#169405 - 2006-10-23 12:56 PM Re: Deleting folder contents in users "Documents and Settings "
craigs9 Offline
Fresh Scripter

Registered: 2006-07-05
Posts: 22
Loc: London, UK
Hadn't thought of that happening but have seen it happen a few tiems I supose.
So %userprofile% will still work even if the local profile path changes? (i.e. it adds the doamin on to the end?)

Top
#169406 - 2006-10-23 01:43 PM Re: Deleting folder contents in users "Documents and Settings "
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Yes, %USERPROFILE% is always the "default" current local profile path for the logged in user.

You can also pull the values for user folders from the registry, which is useful in cases where (for example) "My Documents" has been redirected to a location outside of the users profile.

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 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.068 seconds in which 0.03 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