This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- InstallScript Folder permisions
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 02, 2008
02:26 PM
InstallScript Folder permisions
I am looking for a way to setup or edit users{localcomputer} permisions on a folder. The Folder is created by InstallScript and I need to be able to change the pemissions on it?
(10) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 02, 2008
02:53 PM
I don't think InstallScript provide any straight function to set permissions on directories. May be you can download xcalcs.vbs from Microsoft website and copy it into Support Folder and call it using LaunchAppAndWait function!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 02, 2008
02:58 PM
I found a way. If you look hard enough, you will find others.
This is how it works. The code runs the command line executable, "cacls". It puts the out put of that command into a log file. Then using My_AddToLog functions, I put it into a log file of my own creation. If you follow my posts, you will find this function. Otherwise, you can remove these lines of code. It isn't essential to the main operation of the function call, but it is nice to have the output logged somewhere.
My_CACLS(strTargetDir, strUserName)
strTargetDir -- This is the folder that is targeted to have the permissions changed.
strUserName -- This is the user that will be added to the folder with Full permissions.
Remarks -- The function Adds the user the to the folder with full permissions. It also does this recursively. So any folder under the target folder will also be changed. This function works great, but there is a down side. A DOS window will appear during the running of the CACLS function call. The CACLS needs the enviroment variables that are automatically loaded when you run a command shell.
EXTERNAL prototype My_RunCMDandLog(BYVAL string, BYVAL string);
EXTERNAL prototype My_CACLS(BYVAL string, BYVAL string);
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_CACLS(strTargetDir, strUserName)
STRING strCommand;
STRING szCmdArgs;
begin
//cmd /c cacls "C:\Program Files\AIMWorX\Data\Cas\Test" /T /E /G Users:F >"C:\Program Files\AIMWorX\Data\Cas\cacls.log"
///////////////////////////////////////////////////////////////////
// This modifies the Permissions on the directory to allow Full //
// Control for local logged in users. //
// cacls "" /T /E /G Users:F //
// cacls "" /T /E /G Users:F >" \cacls.log" //
///////////////////////////////////////////////////////////////////
//My_AddToLog(szCmd + szCmdArgs);
//LaunchAppAndWait(szCmd, szCmdArgs, WAIT);
strCommand = WINSYSDIR ^ "cmd.exe";
if strUserName != "" then
szCmdArgs = "/c cacls \"" + strTargetDir +"\" /T /E /G "+ strUserName +":F ";
else
szCmdArgs = "/c cacls \"" + strTargetDir +"\" /T /E /G Users:F ";
endif;
My_RunCMDandLog(strCommand, szCmdArgs);
end;
///////////////////////////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////
function My_RunCMDandLog(strCommand, strArguments)
LIST listTemp;
NUMBER nIndex;
NUMBER nSize;
STRING strValue;
STRING strLogFile;
STRING strTemp;
begin
strLogFile = "";
if GetEnvVar("TEMP", strLogFile) < 0 then
strLogFile = "C:\\";
endif;
strLogFile = strLogFile ^ "RunCMDandLog.log";
strArguments = strArguments +">\""+ strLogFile +"\"";
LaunchAppAndWait(strCommand, strArguments, WAIT);
My_AddToLog("");
My_AddToLog("Command := \""+ strCommand +"\"");
My_AddToLog("Arguments:= \""+ strArguments +"\"");
My_AddToLog("Output ::");
My_AddToLog("=======================================");
listTemp = ListCreate( STRINGLIST );
ListReadFromFile( listTemp, strLogFile );
nSize = ListCount( listTemp );
if nSize > 0 then
for nIndex = 0 to nSize -1
ListSetIndex(listTemp, nIndex);
ListCurrentString(listTemp, strTemp);
My_AddToLog(strTemp);
endfor;
endif;
My_AddToLog("=======================================");
ListDestroy ( listTemp );
end;
This is how it works. The code runs the command line executable, "cacls". It puts the out put of that command into a log file. Then using My_AddToLog functions, I put it into a log file of my own creation. If you follow my posts, you will find this function. Otherwise, you can remove these lines of code. It isn't essential to the main operation of the function call, but it is nice to have the output logged somewhere.
My_CACLS(strTargetDir, strUserName)
strTargetDir -- This is the folder that is targeted to have the permissions changed.
strUserName -- This is the user that will be added to the folder with Full permissions.
Remarks -- The function Adds the user the to the folder with full permissions. It also does this recursively. So any folder under the target folder will also be changed. This function works great, but there is a down side. A DOS window will appear during the running of the CACLS function call. The CACLS needs the enviroment variables that are automatically loaded when you run a command shell.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 02, 2008
04:43 PM
Thank you, I used the CALCS aproach and that worked great.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 29, 2008
06:44 PM
It works when I tried in command prompt but when I put the code in the installer I notice it just hanged at the command prompt. its not going forwar.
any help is appriciated.
Here is the function :
szCmd = WINSYSDIR ^ "cmd.exe";
szCmdArgs = " cacls + TARGETDIR + /E /G Everyone:F";
LaunchAppAndWait(szCmd, szCmdArgs, WAIT);
any help is appriciated.
Here is the function :
szCmd = WINSYSDIR ^ "cmd.exe";
szCmdArgs = " cacls + TARGETDIR + /E /G Everyone:F";
LaunchAppAndWait(szCmd, szCmdArgs, WAIT);
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 30, 2008
08:50 AM
You are missing the "/c" parameter. The parameter is for the CMD executable or Command Shell. It isn't to be used with CACLS. For full details on this parameter, do "cmd /?" in a command shell. To see how it is used, take a look in the function, My_Cacls... It basically does the same thing you are trying. Feel free to copy it into your installation.
Also, don't be afraid of the other functions I have in there. My installation creates a log file and I write entries to it by using My_AddToLog. I wanted a way to capture the out put of CACLS. So I came up with My_RunCMDandLog. It adds a parameter to the arguments that redirects the output to a file. I then proceed to open that file and add it to my log file that I control with My_AddToLog. So it is simply a wrapper around, "LaunchAppAndWait" with the ability to redirect the output to a file.
So when I run my functions together, it creates this command line.
cmd /c cacls "C:\Program Files\MyProductFolder" /T /E /G Users:F >"C:\Program Files\MyProductFolder\cacls.log"
I should also add, if you want to test this, do not run it in the command shell. Run it from, Start/Run dialog. It better simulates LaunchAppAndWait. The command shell environment is not loaded in LaunchAppAndWait. Just like the Run dialog.
Also, don't be afraid of the other functions I have in there. My installation creates a log file and I write entries to it by using My_AddToLog. I wanted a way to capture the out put of CACLS. So I came up with My_RunCMDandLog. It adds a parameter to the arguments that redirects the output to a file. I then proceed to open that file and add it to my log file that I control with My_AddToLog. So it is simply a wrapper around, "LaunchAppAndWait" with the ability to redirect the output to a file.
So when I run my functions together, it creates this command line.
cmd /c cacls "C:\Program Files\MyProductFolder" /T /E /G Users:F >"C:\Program Files\MyProductFolder\cacls.log"
I should also add, if you want to test this, do not run it in the command shell. Run it from, Start/Run dialog. It better simulates LaunchAppAndWait. The command shell environment is not loaded in LaunchAppAndWait. Just like the Run dialog.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 30, 2008
01:47 PM
Thank You it works good . what does /T stands for ?? I used without using /T it and it still gave the permissions to everyone in that folder.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 03, 2009
02:38 AM
I'm using your code snippet, along with your logging functions, but I'm having some problems!
The log file:
Command := "C:\WINDOWS\system32\cmd.exe"
Arguments:= "/c cacls "C:\Program Files\CRM Extensions\NN\" /T /E /G NETWORK SERVICE:F >"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RunCMDandLog.log""
Output ::
When I try to run the following command in a command prompt I get a "The filename, directory name, or volume label syntax is incorrect":
cacls "C:\Program Files\CRM Extensions\NN\" /T /E /G NETWORK SERVICE:F
However, I've tried messing with it and either I get the "The filename, directory name, or volume label syntax is incorrect" error or it simply shows me the cacls help . . .
If I write:
cacls "C:\Program Files\CRM Extensions\NN\"
It shows me the permissions for that folder correctly . . .
What am I messing up?
The log file:
Command := "C:\WINDOWS\system32\cmd.exe"
Arguments:= "/c cacls "C:\Program Files\CRM Extensions\NN\" /T /E /G NETWORK SERVICE:F >"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RunCMDandLog.log""
Output ::
When I try to run the following command in a command prompt I get a "The filename, directory name, or volume label syntax is incorrect":
cacls "C:\Program Files\CRM Extensions\NN\" /T /E /G NETWORK SERVICE:F
However, I've tried messing with it and either I get the "The filename, directory name, or volume label syntax is incorrect" error or it simply shows me the cacls help . . .
If I write:
cacls "C:\Program Files\CRM Extensions\NN\"
It shows me the permissions for that folder correctly . . .
What am I messing up?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 06, 2009
09:11 AM
At first glance, I see a couple of potential things you can try. The value, "C:\Program Files\CRM Extensions\NN\", try removing the last "\". So it should look something like, "C:\Program Files\CRM Extensions\NN".
The other potential problem is the space between "NETWORK SERVICE". Since you are dealing with command line logic, it may see this as two different arguments. Play with it. Try adding an "_" or removing the space. You might also want to look up the help on CACLS. There might be something there for you.
As always, try doing this in either the command shell or in "Start\Run". The "Start\Run" method would probably be best for a final test since it is like running it in LaunchAppAndWait.
Good Luck.
The other potential problem is the space between "NETWORK SERVICE". Since you are dealing with command line logic, it may see this as two different arguments. Play with it. Try adding an "_" or removing the space. You might also want to look up the help on CACLS. There might be something there for you.
As always, try doing this in either the command shell or in "Start\Run". The "Start\Run" method would probably be best for a final test since it is like running it in LaunchAppAndWait.
Good Luck.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 10, 2009
12:45 AM
You were right - it won't run with the last \ in the end of the path, so I used a substring function to remove this. Other than that I put " around user names with spaces in them and voila, it's working 🙂
I'm using your logging functions and your code (gave you the credit) and would like to say Thank You Very Much 🙂
I'm using your logging functions and your code (gave you the credit) and would like to say Thank You Very Much 🙂
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 12, 2009
06:45 PM
Your welcome and I'm glad that I was able to help... Let me know if you need anymore assistance in the future.
![](/skins/images/CC38E504FC9E1309DC48ACFEB4925670/responsive_peak/images/icon_anonymous_message.png)