[
    {
        "role": "user",
        "content": "i%20want%20to%20set%20system%20volume%20on%20default%20device%20from%20windows%20command%20line%20cmd%20or%20powershell.%20give%20ooptions"
    },
    {
        "role": "assistant",
        "content": "Here are a few ways to set the **default audio device** and/or **adjust system (master) volume** in Windows via Command\u2010Line (CMD) or PowerShell. Some use built-in APIs via scripts; others rely on third-party tools or modules. Choose what fits your environment best.\n\n---\n\n## 1. Using the \u201cAudioDeviceCmdlets\u201d PowerShell Module\n\nThis is one of the more robust, up-to-date methods. It gives you cmdlets for setting default devices, volumes, mute state, etc. ([github.com](https://github.com/frgnca/AudioDeviceCmdlets?utm_source=openai))\n\n**Setup**  \n- Open PowerShell as Administrator  \n- Run:  \n  ```powershell\n  Install-Module -Name AudioDeviceCmdlets\n  ```\n\n**Get a list of audio devices**  \n```powershell\nGet-AudioDevice -List\n```\n\n**Set a default playback or communication device**  \nYou can refer to the device by Index, ID, or Name:  \n```powershell\n# Example: Set by name\nSet-AudioDevice -Name \"Speakers (Realtek(R) Audio)\"\n\n# Or by index\n$dev = Get-AudioDevice -List | Where-Object { $_.Name -like \"*Headphones*\" }\nSet-AudioDevice -InputObject $dev\n```\n\nYou can also specify whether to set it as the *default device*, *default communications device*, or both. ([github.com](https://github.com/frgnca/AudioDeviceCmdlets?utm_source=openai))\n\n**Set the system (master) volume of the default playback device**  \n```powershell\nSet-DefaultAudioDeviceVolume 50\n```\nThis sets the default playback device\u2019s volume level (0 to 100). ([powershellgallery.com](https://www.powershellgallery.com/packages/AudioDeviceCmdlets/1.1/Content/AudioDeviceCmdlets.dll-Help.xml?utm_source=openai))\n\n---\n\n## 2. Using NirCmd / SoundVolumeView (Third-Party Utilities via CMD / Batch Files)\n\nIf you prefer a simple .bat/.cmd approach, third-party utilities like **NirCmd** and **SoundVolumeView** are popular. They allow changing default device, adjusting volume, etc. ([reddit.com](https://www.reddit.com/r/windows/comments/kz68mg?utm_source=openai))\n\n**NirCmd (by NirSoft)**  \n- Download and ensure `nircmd.exe` is accessible (e.g. add to PATH or same folder).  \n- To set the default playback device:  \n  ```cmd\n  nircmd setdefaultsounddevice \"Device Name\" 1\n  ```\n  The last parameter (like `1`) may denote setting for default device role (multimedia or communications) depending on version. Some discussion shows usage with `0`, `1`, `2` to pick roles. ([reddit.com](https://www.reddit.com/r/PowerShell/comments/1bgdvbc?utm_source=openai))\n\n- To change master volume:  \n  ```cmd\n  nircmd setsysvolume <value>\n  ```\n  (Value is 0 to some max depending on utility; sometimes need to calculate relative levels.) ([reddit.com](https://www.reddit.com/r/usefulscripts/comments/jbl2je?utm_source=openai))\n\n**SoundVolumeView (NirSoft)**  \n- More flexible, supports commands like `/SetDefault`, `/SetAppDefault` to set default device for system or per-application. ([blog.nirsoft.net](https://blog.nirsoft.net/2020/05/29/set-default-audio-device-of-specific-application-from-command-line-on-windows-10/?utm_source=openai))  \n- Example:  \n  ```cmd\n  SoundVolumeView.exe /SetDefault \"Speakers Device\\Render\" 0\n  ```\n\n---\n\n## 3. Custom Scripts Using Windows Core Audio APIs\n\nIf you prefer something self-hosted or avoid third-party executables, you can write code or script using the **Core Audio APIs**. Microsoft provides sample code like *EndpointVolume* which demonstrates enumerating audio endpoints, changing default devices, setting master volume, mute, etc. ([learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/coreaudio/endpointvolume?utm_source=openai))\n\nYou could wrap such functionality in a PowerShell script leveraging COM interop or C# (via `Add-Type`) to call MMDevice APIs. More complex, but maximal control.\n\n---\n\n## 4. Using CMD / PowerShell Without Third-Party Tools (Built-In Only)\n\nWindows does **not** include built-in command-line tools that reliably set default audio device or master volume in all versions. Native options are limited:\n\n- The `SetAudio` command discussed in Microsoft docs is for MCI devices (older multimedia devices), not general playback endpoints. ([learn.microsoft.com](https://learn.microsoft.com/en-us/windows/win32/multimedia/setaudio?utm_source=openai))  \n- For audio device preference during driver install, there\u2019s the `SetupPreferredAudioDevices` directive in INF files\u2014but that only applies when installing drivers, **not** dynamic switching after boot. ([learn.microsoft.com](https://learn.microsoft.com/en-us/windows-hardware/drivers/audio/setuppreferredaudiodevices?utm_source=openai))  \n\nThus, for built-in only, you're mostly limited to UI (Sound control panel) or manual selection in Settings.\n\n---\n\n## Summary & Recommendations\n\n| If you want \u2026 | Use this option |\n|---------------|-----------------|\n| Scriptable PowerShell method | AudioDeviceCmdlets module |\n| Simple batch file or hotkey | NirCmd or SoundVolumeView |\n| Full control with programmatic API | Custom script via Windows Core Audio APIs |\n| Zero external tools | You'll be limited; Windows doesn\u2019t provide built-in reliable commands for switching default device or setting master volume in all cases |\n\n---\n\nIf you tell me your Windows version (10 / 11 / etc.) and whether you\u2019re okay installing modules or external tools, I can give you a ready-made script customized for your setup."
    }
]