NI Package Manager (NIPM)

cancel
Showing results for 
Search instead for 
Did you mean: 

File Permission Changed by Package Process

Solved!
Go to solution

I have a package that installs an UDL file under %ProgramData%. The original UDL file has user permissions set to Full Control. When the UDL file is installed as part of the package it ends up with user permissions of Read & execute/Read. My program (running as User) gets a file I/O error when trying to update this file. With the old school (not the future) installer file permissions could be set. Is it possible to do the same with Package Builder?

0 Kudos
Message 1 of 3
(1,581 Views)
Solution
Accepted by topic author al_g
NI Package Builder does not carry any file permission or file attributes from the source file to the destination when installed. You must use a Custom Execute to operate on the file post install.
I believe that the following should work for you to create a custom execute which sets file permissions using the cacls.exe command on the target computer.
  1. In the Root property, select [System (32-bit)].
  2. Set the Executable Path to the name of the command prompt executable:
    cmd.exe
  3. In the Arguments property, provide the arguments needed to pass in a string to the command prompt and then run cacls.exe:
    /c cacls.exe ""%ProgramData%\<RestOfPathToFile>" /E /G "<UserName>":F"
  4. Click OK.

You should be able to use any of the Installation Target Roots for File Packages values with surrounding "%" characters as documented in the NI Package Manager help.

Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 3
(1,554 Views)

Thank you. Your suggestions works, but after reading that Microsoft is deprecating cacls I modified the Custom Executes to use icacls. With icacls I was able to set permissions for my entire directory with a single command.

 

/c icacls.exe "%ProgramData%\...\Configuration Files" /grant:r Users:F /t /c

 

:r Replace attributes
:F Full Access
/t Changes ACLs of specified files in the current directory and all subdirectories.
/c Continues the operation despite any file errors

 

Message 3 of 3
(1,518 Views)