Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Take Ownership procedure
I would appreciate some help with the following: 

I have compiled a complete setup file of my utilities program. It installs fine and works fine.
However, after install the user has to Take Ownership of the Program Folder because Windows is blocking access to some of the files and then some elements of my program won't work properly.

Instead of a right clicking on the program folder, choosing properties, clicking the security tab etc. etc. or using third-party reg files or utilities, I would prefer a faster and easier way (because some users don't understand all these extra steps and I preferably don't want to include any third party files in my setup).

I've been trying to create a second executable that takes care of this by means of performing these steps one after another by means of sending keystrokes/activating the controls. About halfway, in the "Permissions for App2" window, QM manages to activate the window but apparently cannot get access to its controls.
Apart from that I think this approach is too risky anyway, too many steps are involved with the chance of misfiring/accidental selection of the wrong folder, user may touch the mouse or keyboard etc.

It's about this program folder:
C:\Program Files (x86)\App2

I understand that the Take Ownership procedure mainly consists of (CMD) commands Takeown.exe and Icacls.exe
But that would be way too complicated for a user to do. Is there an easier way with QM?

Any suggestions are welcome.
Just a quick alternative maybe:
Have you tried running the compiled exe as admin? Does it still block the folder?
If it works you could take another route by asking users to run the exe as admin?
(And I am almost sure it's not possible to compile an exe that runs as admin due to security issues, windows does not allow that).

Sorry, I wasn't clear in my previous post. My program consists of several executables but it is offered as a setup package (install forge) which works without any problems.

It extracts the entire App2 program folder to C:\Program Files (x86).
This setup package itself can be run as administrator.

The problem is the Ownership procedure that needs to be done after the installation.
Oh, then I am afraid I can not be of much assistance.

You might try to add an executable that does the finalizing work.
This means if possible, install forge needs to copy the executable that finalizes the installation in the windows temp dir AND execute it.
The executable could look like this:
Macro Macro33
Select All      Help
;; Install forge passes install path to this .exe
str usermodified_path=_command
str folder_path

;; If install forge somehow did not pass a path to this .exe then use a default path
,folder_path="C:\Program Files (x86)\App2" ;; Default path
,folder_path=usermodified_path ;; The path that is supposed to be passed from install forge

;; Stop if install path could not be detected.
if(!FileExists(folder_path 1))
,mes-(F"Could not detect installtion path:[]{folder_path}[][]Has the application been installed correctly?" F"APPLICATION NAME" "!")

;; With this command, the logged on user will take ownership of the specified directory
run "takeown" F"/f ''{folder_path}'' /r /d y" ;; double quoted the  ''folder_path'', because of paths with spaces

I do not know if you can instruct install forge to run the the exe after installation? If possible then the final executable should be run as admin and you might pull it off?

Or maybe a bit simpler if install forge  accepts .bat, you could put the commands in a .bat file and then the .bat file needs to be run at the end of the installation?
Thanks Ron,

The InstallForge part is not a problem for me besides I can always create a second executable, or batch file like you said, that users can run after the installation.
But for some reason this script doesn't work, although it seems to find the App2 program folder all right. 
I think it is the last line of the script:

Macro Ownership
Select All      Help
run "takeown" F"/f ''{folder_path}'' /r /d y" ;; double quoted the  ''folder_path'', because of paths with spaces

I see a brief flashing (as with a batch file) but it doesn't change anything in the Users group security settings of the App2 folder. I tried adding Icacls.exe as well but that appears to make no difference.  Is QM entering these commands, silently, via the command prompt BTW?
Question. what is your exe doing that is causing the take ownership issue?
what does it do?
i am wondering if the problem may be in what the exe does or is attempting to do.

check out this function may do what you need
it is in qm system folder

Select All      Help
other possible problems 
the installer script is not configured correctly
my suggestion is to use inno setup instead. I have used it in the past many times and never had any issues with permissions
i just tested it with a qm generated exe that modifies the registry and had no issues at all.

I've used Inno Setup before but it doesn't have the nice Boot Screen option that InstallForge does, actually I had the same ownership problem with Inno Setup. My program is a bundle of several executables (restart utility, read utility, URL storage utility etc.) That last one in particular writes to a specific Notepad file in the App2 program directory which by default is being blocked by Windows 8 and 10.

Thanks for the ChangeFileSecurity tip BTW I will try that.

What might actually be even better is having the Notepad file in the Users Documents folder so I wouldn't have this issue. Is there a SpecialFolder function in QM like in C#?

I would then have to change the target path in this script that copies the current IE URL (I have another one for Chrome):

Select All      Help
int w1=act(win("Internet Explorer" "IEFrame"))
key Ad
key Cc             
key T
_s.getclip(); _s.setfile("$program files$\App2\Store.txt" -1 -1 1)
yes i bet that is the problem better to save to another directory besides program files
it has to many protections on it and really it's not designed for that

 see qm floating toolbar 
write file  for more options
also here is a better way to get the url from ie

Select All      Help
;_s.setfile("$Local AppData$\")

int w=win("Internet Explorer" "IEFrame")
Htm e=htm("BODY" "" "" w "0" 0 0x20)
str url
e.DocProp(0 url)
out url;
A faster and cleaner solution indeed. Thank you!

It will now create the text file in Documents.

I was going to ask how to call up the txt file but I see that SpecialFolder is already fully integrated in the standard "Open file" command of QM.

What a great program this is :-)

Forum Jump:

Users browsing this thread: 1 Guest(s)