Sign in to follow this  
Followers 0
ZenKensei

Delete a 'locked' folder

3 posts in this topic

Group,

Could use a little assistance with some logic. As an ongoing effort in my enterprise I am trying to 'clean-up' our Microsoft SMS infrastructure, specifically some clients on remote machines. I am currently having a problem deleting several SMS profile folders as noted below:

C:\Winnt\Profiles\SMSCliSvcAcct&

C:\Winnt\Profiles\SMSCCMBootAcct&

These folders are sometimes 'locked' and will not let me delete them or rename them until the machine is rebooted. And until these profiles are deleted the SMS client cannot re-install itself (the Profile has become corrupted).

What I would like is a script I can run remotely on the machine with PSExec that will try to delete the Directory(s), if it can't then write a registry entry in the RunOnce key to delete the profile at next reboot (maybe rerun the same AutoIt script again which I can copy to the machine during the initial run effort).

I am unsure though how to determine if one or more directories have been deleted if I try and use the DirRemove function (basically I'm not sure how I can use the 'return' value in my script).

Any help, especially an example of using the 'return' value for deleting a directory would be most appreciated.

thanks,

Z/K

Share this post


Link to post
Share on other sites



Any help, especially an example of using the 'return' value for deleting a directory would be most appreciated.

Here is an example that allows the user to select a directory, and then tries to remove it. On any error, it will tell the user about the error, and then exit.

;allow user to select an existing directory, with root at the desktop:
$directory = FileSelectFolder("Select a directory to attempt to delete", "", 0)
;test if the user closed the box without selecting a folder:
If $directory = 1 Then
  MsgBox(0, "No directory selected", "Now exiting...")
  Exit
EndIf
;attempt to delete the folder, and store return in $result:
$result = DirRemove($directory)
;test if the remove was successful:
If $result = 0 Then;the directory delete failed, so tell the user
 ;the 256 style is an error icon
  MsgBox(256, "Error", "Either the remove failed, or the director doesn't exist")
  Exit
EndIf

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0