Page 1 of 1 1
Topic Options
#127294 - 2004-10-01 02:08 PM fil in use when deleting a folder
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Hi,

When i try to RD an empty directory it says it is in use by another process. It's a share and first thing I do is to remove the share and then try to remove the folder.

Here are my code:
$objUser=GetObject("LDAP://cn=$username,$domain")
$DirToEmpty=$objuser.homedirectory
$uarray=SPLIT($DirToEmpty,"\")
$server=$uarray[2]
SHELL '%comspec% /c \\dkbirfs01\drift\NTReskit\RMTSHARE \\$server\$username /delete'
DELDIR($DirToEmpty)
SHELL '%comspec% /c RD $DirToEmpty /q'
$objOU = GetObject("LDAP://$domain")
? $objou.Delete("User", "cn=$username")
IF @ERROR <> 0
MESSAGEBOX("Couldn't delete $username from AD","ERROR",4112)
ENDIF

Instead of using SHELL '%comspec% /c RD $DirToEmpty /q' I've also tried the kix RD:
$objUser=GetObject("LDAP://cn=$username,$domain")
$DirToEmpty=$objuser.homedirectory
$uarray=SPLIT($DirToEmpty,"\")
$server=$uarray[2]
SHELL '%comspec% /c \\dkbirfs01\drift\NTReskit\RMTSHARE \\$server\$username /delete'
DELDIR($DirToEmpty)
? RD "$DirToEmpty"
IF @ERROR <> 0
MESSAGEBOX("Couldn't remove $DirToEmpty@CRLF@SERROR","ERROR",4112)
ENDIF
$objOU = GetObject("LDAP://$domain")
? $objou.Delete("User", "cn=$username")
IF @ERROR <> 0
MESSAGEBOX("Couldn't delete $username from AD","ERROR",4112)
ENDIF

Nobody is using the files and the folders are empty

Hope someone can help me

Jan

Top
#127295 - 2004-10-01 07:51 PM Re: fil in use when deleting a folder
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
This does not even sound like a scripting issue. Typically scripting is used to automate a repetitive or lengthy process. In the case here why can't you just open Windows Explorer and go to this folder location and delete it?

Top
#127296 - 2004-10-02 03:59 PM Re: fil in use when deleting a folder
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
It would be nice if I could make it work. I've found that DELTREE should do the job, but I haven't been able to download it. Do you know where I can download it?
Top
#127297 - 2004-10-02 04:10 PM Re: fil in use when deleting a folder
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why do you need DELTREE if RD /S /Q does the same thing?
_________________________
There are two types of vessels, submarines and targets.

Top
#127298 - 2004-10-02 04:15 PM Re: fil in use when deleting a folder
jan Offline
Getting the hang of it

Registered: 2004-07-07
Posts: 66
Because RD says the file is in use. But I can delete it from explorer

I've found DELTREE and it's working now

Thanks for your help

Top
#127299 - 2004-10-02 04:17 PM Re: fil in use when deleting a folder
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Also, it seems you try to delete the user's home directory while it is still specified in the user account properties? Have you tried to deleet the user account first or removign the home directory property before deleting the physical directory?
_________________________
There are two types of vessels, submarines and targets.

Top
#127300 - 2004-10-03 01:58 AM Re: fil in use when deleting a folder
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Hmmm... I'm wearing my skeptical face on this. If RD /S /Q says the file is in use the DELTREE should not be able to delete it either. They both do operate on the same principal. Perhaps by the time you got around to using DELTREE the object was no longer in use.

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

Generated in 0.184 seconds in which 0.108 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