Disclaimer

Wednesday 14 November 2012

File & registry permissions with subinacl

Sample script that makes use of subinacl to modfiy permissions for files and/or registry, in this case I have done a function for alter file permissions, when I have to do somehthing for the registry I will add a new function or modify this one (you will need to obtain a copy of subinacl.exe from Microsoft which I believe is free):

Sub SetPermissions(strTarget, strUser, strAccess)
  'On Error Resume Next
  Dim wshShell
  Set WshShell = WScript.CreateObject("WScript.Shell")
  wshShell.Run "subinacl.exe /subdirectories=directoriesonly " & """" & strTarget & """" & " /grant=" & """" & strUser & """" & "=" & strAccess, 0, True
  wshShell.Run "subinacl.exe /subdirectories=directoriesonly " & """" & strTarget & "\*.*" & """" & " /grant=" & """" & strUser & """" & "=" & strAccess, 0, True
  wshShell.Run "subinacl.exe /subdirectories=filesonly " & """" & strTarget & "\*.*" & """" & " /grant=" & """" & StrUser & """" & "=" & strAccess, 0, True
End Sub

'Ignore the following lines more as reference to myself for when I get around to doing it for registry keys
  wshShell.Run "subinacl.exe /keyreg " & """" & "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Bloomberg L.P." & """" & " /grant=" & """" & "Authenticated Users" & """" & "=" & "F", 0, True
  wshShell.Run "subinacl.exe /keyreg " & """" & "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Bloomberg L.P." & """" & " /grant=" & """" & "Authenticated Users" & """" & "=" & "F", 0, True

Clear IE Cache FYI

Was looking for a way of clearing out IE cache as a prerequisite to the installation to a piece of software, ended up not needing to do this, but I am sure I will need this again at some stage, should be easy enough to just execute this through a script.

Found here:
Appears to work on IE9.
Temporary Internet Files
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
Cookies
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2
History
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1
Form Data
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16
Passwords
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32
Delete All
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
Delete All – “Also delete files and settings stored by add-ons”
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351
 These commands should work in Internet Explorer 7 on XP or on Windows Vista.