shell | Electron
https://www.electronjs.org/docs/latest/api/shell • 42 KB fetched Open original page
shell | Electron
Skip to main content
Electron Docs API Blog Tools
* Electron Forge
* Electron Fiddle
Community
* Governance
* Showcase
* Resources
Releases English
* English
* Deutsch
* Español
* Français
* 日本語
* Português
* Русский
* 中文
Search
* Main Process Modules
* app
* autoUpdater
* BaseWindow
* BrowserView
* Deprecated
* BrowserWindow
* clipboard
* contentTracing
* crashReporter
* desktopCapturer
* dialog
* globalShortcut
* ImageView
* inAppPurchase
* ipcMain
* Menu
* MenuItem
* MessageChannelMain
* MessagePortMain
* nativeImage
* nativeTheme
* net
* netLog
* Notification
* powerMonitor
* powerSaveBlocker
* process
* protocol
* pushNotifications
* safeStorage
* screen
* session
* sharedTexture
* ShareMenu
* shell
* systemPreferences
* TouchBar
* Tray
* utilityProcess
* webContents
* WebContentsView
* webFrameMain
* View
* Renderer Process Modules
* Utility Process Modules
* Custom DOM Elements
* Chromium and Node.js
* Classes
* API Structures
*
* Main Process Modules
* shell On this page
shell
Manage files and URLs using their default applications.
Process: Main , Renderer (non-sandboxed only)
The shell module provides functions related to desktop integration.
An example of opening a URL in the user's default browser:
const { shell } = require ( 'electron' )
shell . openExternal ( 'https://github.com' )
warning
While the shell module can be used in the renderer process, it will not function in a sandboxed renderer.
Methods
The shell module has the following methods:
shell.showItemInFolder(fullPath)
* fullPath string
Show the given file in a file manager. If possible, select the file.
shell.openPath(path)
History Version(s) Changes None
API ADDED
* path string
Returns Promise<string> - Resolves with a string containing the error message corresponding to the failure if a failure occurred, otherwise "".
Open the given file in the desktop's default manner.
shell.openExternal(url[, options])
History Version(s) Changes None
Added activate option. None
Added workingDirectory option. >=24.0.0
Added logUsage option.
* url string - Max 2081 characters on Windows.
* options Object (optional)
* activate boolean (optional) macOS - true to bring the opened application to the foreground. The default is true .
* workingDirectory string (optional) Windows - The working directory.
* logUsage boolean (optional) Windows - Indicates a user initiated launch that enables tracking of frequently used programs and other behaviors.
The default is false .
Returns Promise<void>
Open the given external protocol URL in the desktop's default manner. (For example, mailto: URLs in the user's default mail agent).
shell.trashItem(path)
History Version(s) Changes >=12.0.0
API ADDED
* path string - path to the item to be moved to the trash.
Returns Promise<void> - Resolves when the operation has been completed.
Rejects if there was an error while deleting the requested item.
This moves a path to the OS-specific trash location (Trash on macOS, Recycle
Bin on Windows, and a desktop-environment-specific location on Linux).
The path must use the default path separator for the platform (backslash on
Windows). Use path.resolve() from the node:path module to ensure correct
handling on all filesystems.
shell.beep()
Play the beep sound.
shell.writeShortcutLink(shortcutPath[, operation], options) Windows
* shortcutPath string
* operation string (optional) - Default is create , can be one of following:
* create - Creates a new shortcut, overwriting if necessary.
* update - Updates specified properties only on an existing shortcut.
* replace - Overwrites an existing shortcut, fails if the shortcut doesn't
exist.
* options ShortcutDetails
Returns boolean - Whether the shortcut was created successfully.
Creates or updates a shortcut link at shortcutPath .
shell.readShortcutLink(shortcutPath) Windows
* shortcutPath string
Returns ShortcutDetails
Resolves the shortcut link at shortcutPath .
An exception will be thrown when any error happens.
Edit this page
Previous
ShareMenu
Next
systemPreferences
* Methods
* showItemInFolder
* openPath
* openExternal
* trashItem
* beep
* writeShortcutLink
* readShortcutLink
Docs
* Getting Started
* API Reference
Checklists
* Performance
* Security
Tools
* Electron Forge
* Electron Fiddle
Community
* Governance
* Resources
* Discord
* Bluesky
* X
* Mastodon
* Stack Overflow
More
* GitHub
* Open Collective
* Infrastructure Dashboard
Copyright OpenJS Foundation and Electron contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation , please see our Trademark Policy and Trademark List . Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them. The OpenJS Foundation | Terms of Use | Privacy Policy | Bylaws | Code of Conduct | Trademark Policy | Trademark List | Cookie Policy
Hosting and infrastructure graciously provided by
Links found on this page
- Skip to main content [direct]
- Electron [direct]
- Docs [direct]
- API [direct]
- Blog [direct]
- Electron Forge [direct]
- Electron Fiddle [direct]
- Governance [direct]
- Showcase [direct]
- Resources [direct]
- Releases [direct]
- Deutsch [direct]
- Español [direct]
- Français [direct]
- 日本語 [direct]
- Português [direct]
- Русский [direct]
- 中文 [direct]
- autoUpdater [direct]
- BaseWindow [direct]
- BrowserView Deprecated [direct]
- BrowserWindow [direct]
- clipboard [direct]
- contentTracing [direct]
- crashReporter [direct]
- desktopCapturer [direct]
- dialog [direct]
- globalShortcut [direct]
- ImageView [direct]
- inAppPurchase [direct]
- ipcMain [direct]
- Menu [direct]
- MenuItem [direct]
- MessageChannelMain [direct]
- MessagePortMain [direct]
- nativeImage [direct]
- nativeTheme [direct]
- net [direct]
- netLog [direct]
- Notification [direct]
- powerMonitor [direct]
- powerSaveBlocker [direct]
- process [direct]
- protocol [direct]
- pushNotifications [direct]
- safeStorage [direct]
- screen [direct]
- session [direct]
- sharedTexture [direct]
- ShareMenu [direct]
- systemPreferences [direct]
- TouchBar [direct]
- Tray [direct]
- utilityProcess [direct]
- webContents [direct]
- WebContentsView [direct]
- webFrameMain [direct]
- View [direct]
- Custom DOM Elements [direct]
- Chromium and Node.js [direct]
- Classes [direct]
- API Structures [direct]
- Main [direct]
- API ADDED [direct]
- >=24.0.0 [direct]
- >=12.0.0 [direct]
- ShortcutDetails [direct]
- Edit this page [direct]
- Performance [direct]
- Security [direct]
- Discord [direct]
- Bluesky [direct]
- X [direct]
- Mastodon [direct]
- Stack Overflow [direct]
- GitHub [direct]
- Open Collective [direct]
- Infrastructure Dashboard [direct]
- OpenJS Foundation [direct]
- Trademark Policy [direct]
|
|