-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add script to set the shortcut working directory to the user's home folder. #6043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use WorkingDirectory property in Shortcut
in the line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That WIX property translates to this Windows Installer property, which resolves the environment variable at install time. If we put
%HOMEDRIVE%%HOMEPATH%into the WIX configuration it creates the shortcut hardcoded to the value for the user who is doing the install.As far as I can tell there is no way to override this Windows Installer behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this works https://community.flexerasoftware.com/showthread.php?155257-Using-environment-variable-in-a-shortcut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it as a WIX property set to
%HOMEDRIVE%%HOMEPATH%and Windows Installer still resolves it at install time to a hardcoded path. I also tried various methods of escaping and they all got passed through as literal text that resulted in an invalid working directory (ex[\%]HOMEDRIVE[\%]).The one other method that did show promise was:
%HOMEDRIVE%%HOMEPATH%(this was set on the target machine outside of the install process)This resulted in
%TempWkDir%being resolved to%HOMEDRIVE%%HOMEPATH%at install time and the desired shortcut being created. The problem is I could not find a way to temporarily set that environment variable on the install process's environment. Using WIX's environment settings doesn't update the install process's environment, so the value was not resolved properly during the install.Also setting up several layers of environment variables and WIX properties that get substituted for each other seems more complicated for future maintenance than just a simple script that explicitly updates the shortcut.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link above suggests
[HOMEDRIVE][HOMEPATH].There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those get passed through without being modified, I don't think they're valid properties in MSI: https://msdn.microsoft.com/en-us/library/windows/desktop/aa370905(v=vs.85).aspx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I see we have to use a script.
I think an user profile root folder is not appropriate work directory - user should create nothing in the directory. What about the user
Documentsfolder?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? Then why doesn't PowerShell define
$Hometo be the Documents dir? I put files in the root of my home dir all the time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to other folders but I'll leave these notes as well:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 In my enterprise, we warn users of this practice, and even manage to block it as virus suspicious.
I'd reword this arguments: