When trying to delete files you get the error ”The filename or extension is too long.” because someone has created a filename with to many characters.
To delete this quickly:
1. Open a command prompt and cd to the folder that contains the file.
2. Do a “dir /x” to get the Dos 8.3 filename.
3. Now do “del” against this filename displayed.
Very simple to do with Powershell, Open a powershell command prompt and type:
Remove-Item c:\DirYouWantToDelete\* -recurse -force
Below is a small powershell script that will add the “Everyone” Group to Full control for a the registry key HKEY_LOCAL_MACHINE\Software\MyKey. This script will then recursively change the permission on SubKeys and future keys. Save the text to a notepad document and call it something like RegPermissions.ps1
$acl = Get-Acl HKLM:\Software\MyKey
# Everyone has Full contol may do anything:
$person = [System.Security.Principal.NTAccount]"Everyone"
$access = [System.Security.AccessControl.RegistryRights]"FullControl"
$inheritance = [System.Security.AccessControl.InheritanceFlags]"ObjectInherit,ContainerInherit"
$propagation = [System.Security.AccessControl.PropagationFlags]"None"
$type = [System.Security.AccessControl.AccessControlType]"Allow"
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($person,$access,$inheritance,$propagation,$type)
$acl.ResetAccessRule($rule)
Set-Acl HKLM:\Software\MyKey $acl
To run the program from a login script you can assign it to the computer and run using the following syntax:
powershell -executionpolicy bypass -File \\Server\Share\RegPermissions.ps1