I have made a standalone exe using py-installer. It's easy to add my exe to the start menu. Simply add a shortcut to my program in the following directory.
os.getenv("PROGRAMDATA") + "\\Microsoft\\Windows\\Start Menu\\Programs"
However, my exe does not show up under Control Panel -> Programs -> Programs and Features. These applications let you right click to uninstall. How can I add my application to this list? I have made a standalone uninstall exe using py-installer that I want to run when the user clicks uninstall. How I can do this in a clean way? I think I have to add some registry keys. I always sign my exes.
1.Use Registry Editor (Regedit.exe) to view the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
2.Double-click the UninstallString registry value, copy the contents of the Value Data box by selecting the contents and pressing CTRL+C, and then quit Registry Editor.
3.Click Start, click Run, press CTRL+V to paste the uninstall command, and then click OK.
Some programs create a folder under the Winnt folder that contains a "$" character at the start and end of the folder name. This folder may contain an uninstall program that you can run to remove the program you previously installed on your computer. Note that these folders are usually hidden, and that you may need to configure Windows Explorer to view hidden files and folders. To do so, right-click Start, click Explore, click Options on the View menu, and then click Show all files.
On my windows pc, I would just double click a folder and click "Open in VS Code" to a open a folder, which saved time for me when looking through lots of code online. With Mac, however, I do not have this option. I have to directly open vscode and click "Open" to open a new folder. How do I directly open a file in vscode through finder in macOS?
2023 Update - Use Native Method
Open the Command Palette (Cmd+Shift+P) and type shell command to find the Shell Command: Install 'code' command in PATH command.
Restart all terminal sessions for the new $PATH value to take effect.
You'll be able to type code . in any folder to start editing files in that folder.
If you want to do it in Finder, you can write an Automator script to do it (it's easier than it sounds, AND shows you the power of the OS).
Launch Automator
Create New Document
Create a new Quick Action
Add the Action... (New Method - 10.13+)
Workflow receives current files or folders from Finder.
Add a new "Open Finder Items" action to the workflow. (drag the "Open Finder Items" object, highlighted in the screenshot, to the empty window on the right)
Select "Visual Studio Code" from the list.
Add the Action... (Old Method)
Workflow receives current files or folders from Finder.
Add a new Run Shell Script action to the workflow. (drag the "Run Shell Script" object, highlighted in the screenshot, to the empty window on the right)
Configure the Workflow (Old Method)
Set the Pass Input to be as arguments
Paste the following in the input box:
open -n -b "com.microsoft.VSCode" --args "$*"
Save the action using a name like Open in Visual Studio Code.
You may now right-click on the folder and find your newly created task under Quick Actions.
The simplest solution is to create a Quick Action with Open Finder Items:
This way you don't need a shell script that might break with an OS update or VS Code update
Launch Automator and select Quick Action or File > New > Quick Action If Automator is already open.
Set Quick Action receives selected to files or folders and in to Finder.
Choose an Image (icon) select Choose.. and double click Visual Studio Code in the window that pops up, this will set your quick action icon to the same as VS Code
Add Open Finder Items, Choose open with as Other.. select Visual Studio Code and save your Quick Action as Open in VSCode optionally choose an Image for your Quick Action job done.
Finally just hit Cmd+S to save and name it Open with VSCode
Well you need to understand. macOS has different ways to do things than windows and initially it might be a challenge. For starters you start to make use of Terminal. its beautiful.
Now answering your question.
Open your VS code and then, press CMD + SHIFT + P, type shell command and select Install code command in path. Afterwards, navigate to any project from the terminal and type code . from the directory to launch the project using VS Code.
Using the new shortcuts app.
Download:https://github.com/gluedpixel/shortcuts
Or create it by yourself
Open Shortcuts app > Quick Actions
Change from receive any to Files and Folders
Add run shell script action
Paste the code open -n -b "com.microsoft.VSCode" --args "$*"
Change input to Shortcut input
Click on Shortcut input and set type to "Folder" & Get to File Path
There are some ways suggested here in the VS Code GitHub Issues tracker, but I would go with the first option of dragging the folder onto the app icon if you have VS Code icon in your dock!
If you really want to be able to do so from a right click, then this repository has a workflow solution. https://github.com/Sankra/OpenFolderInVSCode
Drag and drop the folder from Finder onto an empty VSCode window.
Found a way to achieve a 'Quick Action' that met my needs using the following steps using MacOS' Shortcuts app (No Automator needed):
if you are looking for screenshots as well, I wrote a small Notion page
Open the ‘Shortcuts’ app on your Mac
On the Left Pane, navigate to ‘Quick Actions’
On the top bar, press the ➕ button to add New Shortcut.
Click on ‘Any’ and change to ‘Files and Folders’ by selecting only those from the dropdown that appears on clicking the ‘Any’ field.
Click on ‘Action Library’ on the right pane and search for ‘shell’. Drag and drop the ‘Run Shell Script’ onto the main pane. This will add the action to the Shortcut’s flow.
In the shortcut details (on the right pane), make sure Use as Quick Action is ticked and so are ‘Finder’ and ‘Service Menu’.
In the newly added action called ‘Run Shell Script’ write “code “ and right-click to get the below pop-up, go ahead ‘Insert variable’ and then ‘Shortcut Input’.
Click on the ‘Shortcut Input’ tag that appears. A pop must appear, choose ‘File Path’ and just click anywhere else. This will change the tag to ‘File Path’.
Set ‘Pass Input:’ option to ‘as arguments’.
Be sure to set a cool name for your new Shortcut! I named mine a boring “Open in VSCode”.
Open a new ‘Finder’ Instance, right-click on a folder, go to ‘Quick Actions’ > ‘Customize...’
Make sure your Shortcut’s Name is selected. Exit the dialogue and Test!
There is a Terminal command named code, I would stick with it and you should get used to it as well if you are regularly using VS.
Follow the one-time setup with-in VS Code
Open your VS code and press ⌘ CMD + SHIFT + P
Type shell, and select Shell Command: Install 'code' command in PATH from the list
Open Terminal and hit any of the commands below:
code <path-to-folder>
OR
cd <path-to-folder>
code .
OR
cd <path-to-folder> && code .
I've actually managed to have it as an icon you can just add to the Finder window as such:
The script will allow you to open the current folder path in VSCode.
The steps to do so are:
Create a new Application with Automator
Select the "Run shell script" from the menu and drag it to the editor
Paste the following small script to the text area:
finderPath=`osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)'`
open -n -b "com.microsoft.VSCode" --args "$finderPath"
Save the Application to the Applications folder
Right click the app and drag and drop your desired VSCode icon to the blank area to the left of the name and close the Get Info window
Press and hold the Command key and drag the Application to an empty space in the Finder title row like in the picture
Test that it works by pressing on the icon. VSCode should now open with the content of the current folder in the navigation bar
Here is an alternative derived from the accepted answer.
Indeed the accepted solution by #jnovack just opens VS Code for me, but not the desired folder. If VS Code is already running it just switches the focus to a running instance of VS Code.
Solution
Provided that you have the code CLI command installed (if not, go to VS Code and do CMD+SHIT+P>"Shell Command: install 'code' in PATH")
Then open a terminal and run which code. You should get the code executable path looking somethin like /usr/local/bin/code
Then, as per #jnovack 's answer,
Open Automator
Create a new Document (CMD+N)
Create a new Quick Action
Workflow receives current files and folders from Finder.
Add a new Run Shell Script action to the workflow. (drag and drop the "Run Shell Script" object)
Pass input as arguments
Paste this code in the shell command field /usr/local/bin/code -n "$*" or replace with your path to the code executable if it differs from this one.
Save the action
Tbh. I would have expected to be able to use just code -n "$*", but for some reason, the PATH used by the automator's shell seems to be different from that used in the terminal. I'd welcome some input on that matter.
I find this to be the best solution out there:
https://github.com/RoadToDream/SzContext
I'm working on a Windows Setup Project in Visual Studio. In the "File System" editor, below the "User's Programs Menu" node, I have a folder for my application that contains several shortcuts. One shortcut serves to launch the application; a different one restores the application's factory settings (so it also calls the application, but with an argument).
After running the installer, the folder - and shortcuts it contains - are created correctly in the Start Menu. Additionally, without any action on my behalf, the installer creates an additional shortcut at the "top level" of the Start Menu (i.e. it's visible when one opens the Start Menu by clicking the Start button).
This additional shortcut used to be the one for launching the application. That was fine. But since I added the "Factory reset" shortcut, this is the one that appears at the "top level" of the Start Menu. This is pointless, and will just confuse users. Is there any way to change this?
EDIT (clarification): Since I added the "Factory reset" shortcut, only this shortcut appears at the top level of the Start Menu (which I don't want), and the shortcut to launch the application no longer appears (but I want it to). Note that all shortcuts in the Start Menu's subfolder are correct. What I'm referring to here is the single shortcut that appears automatically at the top level of the Start Menu (immediately visible when the Start button is clicked).
You'll have to explicitly mark your "factory reset" shortcut with the System.AppUserModel.ExcludeFromShowInNewInstall property. Raymond Chen shows how to do this in this blog post.
Note that this question was asked before.
It is very simple to add a custom command to the shell context menu like so:
[HKEY_CLASSES_ROOT\Directory\Background\shell\TestCommand]
#="My Test Command"
[HKEY_CLASSES_ROOT\Directory\Background\shell\TestCommand\command]
#="notepad.exe"
This adds a custom command to the right-click menu that launches notepad. Since I added it in Directory\Background\, my understanding is that the command should only show up when I right-click in the background of a directory (for example, right clicking an empty area in the right pane of Windows Explorer).
My issue is that the command is also showing up when I right click on an item in the left pane of Explorer (i.e. right clicking on a drive or folder in the treeview). Is there any way to prevent this from happening? I am launching a custom application with arguments and the result is unpredictable if the user is able to launch it from the left pane.
Add;
[HKEY_CLASSES_ROOT\Directory\Background\shell\TestCommand]
#="My Test Command"
"NoWorkingDirectory"=""
When I right click a file (in any folder) I see an option "Send to" and inside
Desktop
Documents
...
and a bunch of other locations.
How can I add my own location, ie "C:\stuff" to this context menu?
Open file explorer and navigate to: %APPDATA%\Microsoft\Windows\SendTo
Once in the SendTo folder, right click -> New -> Shortcut
In addition to the default shortcuts in the SendTo menu, there are hidden options that are exposed if you hold down shift while right clicking the targeted icon.
(This is Windows 7 only)
The easiest way to add your own is to type "shell:sendto" in a file explorer, ( or start -> run -> sendto ) and place whatever shortcut you deem useful. As mentioned before you can add shortcuts to programs as well as directories.
(This is more universal)
HERE is a nice article with a picture instructions.
in addition to shortcuts to folders, you can add shortcuts to apps. for example, add a shortcut to "send to notepad" to open a file in the notepad app. a useful function for a developer.