Adding files to all users 'My Documents' folders in Windows - windows

I am creating an installer (using Inno Setup) for a windows application. The app has initial documents that I need to store in the users 'My Documents' folder.
Here is the issue, I install it as an Admin, but there may be one or many non admin users on that machine. How can i add that same folder to all the possible current (and future user's) My Documents folder?
Here is what i have tried so far-
1) I could try to pick up all usernames - This however, wont work for future user creations :(
2) I have tried to add it to the systems %allusersprofile%\Documents folder. It does not get reflected to individual My Documents folders.
I believe there should be a way, but have been unable to find a clean solution off the internet till now. Can anyone direct me towards the right path?
Mucho Thanks!

There isn't really a construct for this in Windows. You have a few options:
Put the document in some common place (like %allusersprofile%\Documents, or %program files%\yourCompany\yourApp\documents) and create a start menu link/icon that points to either the folder with the documents or the document itself.
Put the document into the Default User documents folder. When a new user is created, their profile is setup to mirror that of the default user. This doesn't help you with current users, but it does help you for users who haven't been created (logged on)
I'd go with option 1 because it's relatively standard and its what your average user is going to expect.

Look at Inno Setup Shell Folder Constants : {commondocs}

Related

How to Trash items that are not owned by the current user, the same way the Finder does?

I am writing a tool that offers the option to trash selected items (files, folders). Usually, I'd call -[NSFileManager trashItemAtURL:...] for each of those items, as it's also explained in this and in this SO question.
However, these do not work when trying to delete files from a directory owned by a different user, such as root. My tool shall offer the same option as the Finder in this case, i.e. ask the user to authorize the operation by providing the credentials of an Admin user, and then my app would move the items to the Trash like the Finder does.
I've tried solving this by using a privileged helper, as outline by the EvenBetterAuthorizationSample example code, using launchd, SMJobBless and XPC Services.
The problem with that is, however, that the privileged helper runs as the root user, without knowledge of the current user my app runs under. The result is that, when it trashes a file, it ends up in the root user's Trash folder and not, as the Finder would do it, in the user's Trash folder.
How do I solve this, i.e. how do I move items not owned by the user to the current user's trash instead of the root user's Trash?
Is there some trick I can use that would let me keep using one of the existing trash oder recycle functions?
Doing the move myself is not going to work properly because for Put Back to work, the Trash's .DS_Store file would need to be updated, and there's no API for that, AFAIK.
I have almost found a solution:
Analysis
When the helper is run, e.g. from launchd, or via AuthorizationExecuteWithPrivileges (under macOS 10.15), it may be running as root, with no knowledge of the logged-in user, hence it cannot determine the user's Trash folder.
Oddly, the Environment variables (see man env) may even show the current user's name and home dir, yet the real user id, which one can query with getuid(), will return 0 (root), which also results in NSUserName()and NSHomeDirectory() returning the root user's information. And it appears that trashItemAtURL and related functions rely on NSHomeDirectory() to determine the Trash folder location.
Half-working solution
Fortunately, there is a way to change the real user id, with setreuid.
Therefore, in my testing, when I call setreuid (501, 0) (501 being the uid of the currently logged-in user), then trashItemAtURL does move the file to the user's Trash folder, indeed, along with automatic renaming where necessary.
However, this does not make the Put Back work, the way it would when trashing the same file using the Finder.
Making Put Back work
Looks like the reason for Put Back not working comes from a deeper issue: It appears to be a long-standing bug in the macOS framework, see this bug report.
Which basically means: This is the best we can get out of it until Apple fixes the underlying bug.
The only working alternative to make Put Back work is to ask the Finder to trash the items using AppleEvents / AppleScript.

How do I change file/folder permissions from cpanel?

I have a joomla website, which I recently moved and I'm having problems with file permissions. The easy fix would be to change all the folders and files permission to 0777, do whatever I need to do, and then change them back. I don't think that's possible anyway - to change them all at once then make everything as it was.
The other solution would be to switch permissions to user Apache from cpanel. Can I do that? How? What other options do I have?
Thanks!
Well it turns out that you can't change the owner from the cpanel. My solution was to contact my hosting and have me transferred to another server of theirs that used FastCGI, which made all my files' owner Apache (instead of null, or nobody, what it was before).
I couldn't find my answer on the internet, I had to ask them and they gave me that solution.
You can change the file/folder permission using the cpanel.
Just login to your cpanel,
there you can find a option called "File Manager".
Just click on that, it will list all your files and folders in a table at the window.
In the table, at the last column which will be named as "Perms". Just click on the column corresponding to the file/folder for which you want to change the permission.
I know this is old thread, but may useful for next user come here.
There is good tool for doing this by Jacob, here you can visit his page http://boomshadow.net/tech/fixes/fixperms-script/, but may you need root access to do it.

Unable to access my MAC keychain due to this

PLEASE FORGIVE ME IF THIS IS NOT A RELATED QUESTION. (this is of top priority)
Recently i tried to change the home folder name of my mac mini. i have gone through a website and followed some instructions to do that. finally i have ended up by creating a completely new user profile with a new home folder name.
after some time i have decide to turn back to my old user and deleted the recently created user.
This is where all my problems started. Now my deleted user folder is in my hardisk with the the follwing name - alpha(deleted). This folder is still being treated as my home folder even after logging in from a different user. I am unable to access even my keychain services through mac. Some softwares are asking me to reinstall on this user.... i ran into chaos with this.
Can some one help me to make my current user as default and renew my keychain access... Please help me as this is of high priority for me..
Thank you
This question should be migrated to apple.stackexchange.com, but you need to go into the newly created account in System Preferences Users pane and change the home folder manually, you may have skipped this step. Usually they will tell you to simply rename your old home folder and set it as the home folder for the new user or simply just rename your home folder and set it as the home folder for the current user.

WIndows file access control

I have a file on a Windows 2003 NTFS file system. It is called C:\MyFolder\MyFile.txt. First grant a user read access to the file. Then I remove the user's read access to the parent folder.
Now the user cannot use Windows Explorer to browse the folder and double click to open in Notepad. The user can go to Start (menu) Run and enter "C:\MyFolder\MyFile.txt" and the file will load in Notepad.
Can someone point me to some MSDN documentation that explains why this is? I've tried all the google and bing queries I can think of.
thanks much
See the 'Traverse Folder' permission in the table on this page:
http://technet.microsoft.com/en-us/library/cc787794(WS.10).aspx
It sounds more like a TechNet article than an MSDN one to me.
If you think about a directory/folder as not a file cabinet folder but rather a index card stuck to the front of the cabinet to say what is in the cabinet. This is effectively what a folder is on the file system (a index to where the files are.)
Because you have denied the user rights to what is in the folder you have denied them access to the index card. However, if they know the precise file they want then they can still access to the file which they have permissions for as this doesn't require a check on the index card.
Behind the scenes it is obviously a little more complicated but that is the basic view. I saw this technique used quite a bit on the *nix environments when I was at Uni to hide previous years assignments from the current batch of students. However, because they hadn't removed permissions from some files the tutors could still direct them to specific examples from previous years.

Changing the default behavior of where files are saved in windows

Kind of a Admin question - I know.
Here's the thing.
The OS has this deep, strange assumsion that a user wants all there pictures in one folder, all there doc files in another folder - etc. Saveing files based on file type - not the folder in which it was opened.
I, like many business/dev users have my drive devided into folders based on 'projects'.
All 'SmithProject' images goes in SmithProject, All JonesProject Images goes in JoneProject.
Why do I spend so much time fighting the OS when it wants to save all files into a folder based on file type? (No - windows - I don't want it in the pictures folder)
Is there not some simple way / setting to define how this works?
I figure, I loose 1-2 hours a week - just because i have to nav back to the same folder, again & again & again.
Any Pluggin?
Anything?
Thanks
Without changing special folders locations (My Documents, etc) it could be hard to achieve. Normally in app, when You call OpenFileDialog You can specify where to start (f.ex: always c:\, last opened folder, special folder) and there is no power in the universe to change this.

Resources