I'm trying to enable the File History functionality in my organization. I used an application written by Ben N and his script. However, I would like to add exclusions for specific folders to it. Is there an option to do that with this app?
-
APK? Android package?– Señor CMasMasMay 12, 2021 at 19:00
-
You will need to be able to debug and author vb.net to figure this out. His code is 100% vb.net.– Señor CMasMasMay 12, 2021 at 19:08
-
I've added a comment with your question to the original.– Charles KenyonMay 12, 2021 at 19:09
1 Answer
Adding an exclusion requires a call to the IFhConfigMgr::AddRemoveExcludeRule
function. To exclude a specific folder, add this code to your script after the paragraph mentioning ProvisionAndSetNewTarget
:
newslot native addRemoveExcludeRule
copyslot addRemoveExcludeRule = vtbl field 6
// fh->AddRemoveExcludeRule(TRUE, FH_FOLDER, "C:\Users\User\Documents\Excluded")
call funcat addRemoveExcludeRule /return uint (slotdata fhPtr, int 1, int 0, bstr "C:\\Users\\User\\Documents\\Excluded")
Change the path in the last line there (not just the //
one, which is just an explanatory comment) to the one you want to exclude. Backslashes must be doubled due to escaping. To exclude multiple folders, add additional call funcat addRemoveExcludeRule
statements with different paths. Do not duplicate the newslot
or copyslot
statements.
To exclude a standard folder/library rather than specifying a specific user profile path, the code is a little different. You'll need the GUID of the standard folder, which you can obtain from this page. Put it (without curly braces) inside the quotes after an asterisk. For example, this excludes the Downloads folder:
// fh->AddRemoveExcludeRule(TRUE, FH_LIBRARY, "*374DE290-123F-4565-9164-39C4925E467B")
call funcat addRemoveExcludeRule /return uint (slotdata fhPtr, int 1, int 1, bstr "*374DE290-123F-4565-9164-39C4925E467B")
To exclude a user-specific path that isn't a standard folder or library, use environment variable expansion (after the statements that set up the addRemoveExcludeRule
slot):
allocslot lpwstr userPath: 260 chars
newslot bstr userPathBstr
// userPath = ExpandEnvironmentStringsW("%USERPROFILE%\Documents\Excluded", userPath, MAX_PATH - 1)
call kernel32.dll!ExpandEnvironmentStringsW /return uint (lpwstr "%USERPROFILE%\\Documents\\Excluded", slotdata userPath, int 259)
// userPathBstr = SysAllocString(userPath)
call oleaut32.dll!SysAllocString /into userPathBstr (slotdata userPath)
// fh->AddRemoveExcludeRule(TRUE, FH_FOLDER, userPathBstr)
call funcat addRemoveExcludeRule /return uint (slotdata fhPtr, int 1, int 0, slotdata userPathBstr)
To set the path, change the text inside the quotes in the ExpandEnvironmentStringsW
call statement. Unlike the other functions called here, that one returns a nonzero value when successful. To exclude multiple folders, duplicate the three call statements, but not the allocslot
and newslot
statements.
-
Thank you very much, I have one more question, is it possible to put the name of the user logged in to the path into the path, I would like to run the script using GPO so that the user does not have to perform any actions. May 13, 2021 at 9:47
-
Yes, I added some code that adds a user-specific exclusion by incorporating the
USERPROFILE
environment variable.– Ben NMay 13, 2021 at 15:05 -
-
1@JanuszTestowy You're welcome, glad I could help! If this solved the problem, you can click the check mark next to the post to let other users know it's the answer.– Ben NMay 14, 2021 at 14:19