-
Notifications
You must be signed in to change notification settings - Fork 907
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
Install-StartMenu Helper #395
Comments
one of my packages installing (and uninstalling) a start menu shortcut: |
@aronovgj Wouldn't something like For my dnSpy package, it might look something like this: Install-ChocolateyStartMenu -Path "dnSpy" -File "dnSpy.exe", "dnSpy-x64.exe"
# ...
Uninstall-ChocolateyStartMenu -Path "dnSpy" Forgive me if my powershell is off, I'm rather new to it. |
for the uninstaller you would also need the don't think it can get any easier |
Of course someone might want to have a more complicated start menu setup, in which case it can be done manually, but just looking through my own start menu most of the subdirectories are very simple and only a few have child directories themselves. You say it can't get any easier but I just gave an example of it being easier (reducing 4 lines to 1), though I should have specified a "base" directory option: |
And I explained to you that those 4 lines are actually one line. untested though... |
That's rather cumbersome, and (I believe) makes the assumption that the destination's parent directory exists, which would affect it if CrystalDiskInfo.lnk was in a subdirectory. Also, that example wouldn't translate well to shortcut-ing multiple files. Although I'm proposing a start menu helper, I'm not proposing that it be the only way to manipulate the start menu. I just figured that manipulating the start menu is something a lot of packages would be interested in doing, so there might as well be an optional helper to make it as easy as possible. Isn't that the purpose of a helper anyways? Why even bother having |
valid arguments. lets see what @ferventcoder thinks |
Related to #344, but still different. I like the idea, but I was thinking less of a helper, and more of a preference on the user end. The idea for helpers is still there and making a helper that works on top of |
I'd like for the helper to allow creating (and naming) multiple shortcuts, maybe like this (I'm no PowerShell expert): Install-ChocolateyStartMenu -Path "Some application" -Items @('app1.exe', @{'File' = 'app2.exe'; 'Name' = 'Application 2'}, 'app3.exe') I assume Auto uninstaller would remove the Start Menu directory, so In my case that would save quite a lot of code (see |
How about if I role this into #519 as follows: If shortcut path comes in without a ":" in it, assume it might be a special folder value path in the form "CommonStartMenu\shortcutname.lnk" Parse the special folder value ("CommonStratMenu" in the example) and validate it against the list returned by [Environment+SpecialFolder]::GetNames([Environment+SpecialFolder]) If it does not pass, reject the path as not a valid reference and not on the list of special folders in this user and process execution context ONLY On an error - output the values from [Environment+SpecialFolder]::GetNames([Environment+SpecialFolder]) to the log so that package builders and users don't have to create special code to try to find out what folders are available in a given special context (e.g. SYSTEM account context under SCCM on a pure 32-bit OS). If it does pass, use [environment]::getfolderpath("CommonStartMenu") to retrieve and use the value throughout. In the help for the ShortcutFilePath parameter detail: |
Here is the working code: $ShortcutFilePath = "CommonDesktopdirectory\abc.lnk" If ($ShortCutFilePath -inotlike "_:_") |
@DarwinJS that's a good start. I think folks also want an easy function they can call as well. |
Sure I could put this in the Install-ChocolateyShortcut and create a set of encapsulating functions. It looks like the rule is one function per *.ps1 ? Which shortcut areas merit their own function - just the Machine Start Menu? Also by Machine Start menu I assume you all probably mean under the "Programs" folder of the start menu? Should the easy function allow the specification of a sub folder? Rob - I am thinking that maybe Install-ChocolateyShortcut should auto-create create any non-existent folder levels in the target shortcut path so that there does not have to be a separate step to create a sub-menu folder? |
It would be nice if it was smart enough to create missing folder structure. |
All of these hacks for For example, from the ConsoleZ package, something like this: Install-ChocolateyStartMenu -Path "ConsoleZ" -Name "Console" -Target "tools/Console.exe" should create a shortcut at And something like this: Install-ChocolateyStartMenu -Name "ConsoleZ" -Target "tools/Console.exe" should create a shortcut at Shortcut folders should be within And chocolatey should track and automatically remove such shortcuts when uninstalling (per #711). |
@alexchandel None of these are consumer-centric - they are package-centric. |
@ferventcoder That's what I mean. The consumer of the API. |
I'm not following - expecting a package creator to use PowerShell is normal. So the word "hideous" throws me because package consumers (those using Chocolatey) don't see any of this for the most part. |
Has this landed on choco in some form? |
FWIW, I ended up using the following at rgl/liteide-chocolatey-package: Install-ChocolateyShortcut `
-ShortcutFilePath "$([Environment]::GetFolderPath('CommonStartMenu'))\Programs\LiteIDE.lnk" `
-TargetPath "$installPath\liteide\bin\liteide.exe" |
I'd really love to see this. Especially with zip-Packages this would make life easier as it would allow getting rid of the |
I even found two coreteam packages that would profit from a helper that also automatically removes the shortcut when uninstalling:
I'm sure there are many more out there..... :) |
Some of the packages I plan on maintaining provide GUI programs but don't have installers, so there's no easy way to add (or remove) shortcuts of them to/from the CommonPrograms directory so that they appear in the start menu (on Win 7 / Win Server 2008 at least, not sure about newer versions). I ended up writing functions to add/remove shortcuts to/from the start menu for one of my packages.
It would be convenient if chocolatey had helpers for similar functionality, considering the start menu is the typical place GUI programs show up after being installed.
The text was updated successfully, but these errors were encountered: