Changing file permissions via PowerShell

Hi all,

I have a user who needs a very specific Wireshark plugin. Wireshark plugins are just DLLs (on Windows) that need permissions to execute. It’s easy enough to copy the file in, and I thought I’d use PowerShell with get-acl and set-acl to copy the permissions from one of the default plugins. The added fun is Wireshark’s plugin directory is named by version; as a result I needed some gnarly relevance to cough out the right path.

This is the command:

waithidden powershell -ExecutionPolicy Bypass -command "{{$theacl = get-acl '{value of variable "programw6432" of environment}\Wireshark\plugins\{(value "DisplayVersion" of key whose ( value "DisplayName" of it as string contains "Wireshark" ) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of registry) as string}\ethercat.dll' ; set-acl '{value of variable "programw6432" of environment}\Wireshark\plugins\{(value "DisplayVersion" of key whose ( value "DisplayName" of it as string contains "Wireshark" ) of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of registry) as string}\f5ethtrailer.dll' $theacl}"

And then in the log, it runs and exits with error code 0:

Command started - waithidden powershell -ExecutionPolicy Bypass -command "{$theacl = get-acl "C:\Program Files\Wireshark\plugins\1.12.6\ethercat.dll" ; set-acl "C:\Program Files\Wireshark\plugins\1.12.6\f5ethtrailer.dll" $theacl}" (action:55391)
Command succeeded (Exit Code=0) waithidden powershell -ExecutionPolicy Bypass -command "{$theacl = get-acl "C:\Program Files\Wireshark\plugins\1.12.6\ethercat.dll" ; set-acl "C:\Program Files\Wireshark\plugins\1.12.6\f5ethtrailer.dll" $theacl}" (action:55391)

But when I use get-acl to verify it, the ACLs haven’t changed. Naturally, the same powershell command line works fine in the normal PowerShell.

Ideas or suggestions welcome. Thanks!

I don’t know powershell very well, but here is an example of changing permissions using cacls.exe :

https://bigfix.me/fixlet/details/771

It includes relevance to detect the current permissions are wrong and then fixes them. This example is no longer needed for spotify, but it is a valid example otherwise.

Also, does wireshark have an “InstallLocation” in the uninstall key of the registry? that might be easier to use than both trying to get the programfiles location as well as the displayversion. Usually at least one entry in the uninstall key has the full path to the program.

They do, but it doesn’t include the version\plugin path. I’ll probably use parameters to make the logic more readable, but that doesn’t address the PowerShell issue.

cacls is gone in Windows 7, but I’ll look at the new icacls.

I was using cacls in Windows 7 in the above example, so I don’t think that is the case.

Does it include the path with the version? if so, you could add “plugin” to it.