[PR #4533] [MERGED] Use PowerShell to get windows drive paths. #4276

Closed
opened 2026-04-25 00:19:06 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf/pull/4533
Author: @sir-wilhelm
Created: 7/25/2025
Status: Merged
Merged: 8/23/2025
Merged by: @advplyr

Base: masterHead: wmic_replacement


📝 Commits (1)

  • cae1560 Use PowerShell to get windows drive paths.

📊 Changes

1 file changed (+2 additions, -3 deletions)

View changed files

📝 server/utils/fileUtils.js (+2 -3)

📄 Description

wmic has been deprecated on newer versions of Windows 11 and is not installed.

Brief summary

Allows windows 11 users to select paths for their library w/o having to manually enable wmic.

Which issue is fixed?

fixes #4531

In-depth Description

It uses PowerShell to get drive letters instead of wmic,
It works since PowerShell is also installed on all Windows boxes.
2 users have reported it (mikiher/audiobookshelf-windows/issues/40 and #4531), but it'll impact anyone on the latest version of Windows 11 that do not enable wmic as a workaround.

How have you tested this?

I just tested the changes manually in a node repl to ensure the output was the same on a windows box:

const { exec } = require('child_process');

// old command
exec('wmic logicaldisk get name', (error, stdout, stderr) => {
  if (error) {
    console.error('Error:', error);
    return;
  }

  const drives = stdout
    ?.split(/\r?\n/)
    .map((line) => line.trim())
    .filter((line) => line)
    .slice(1);

  const validDrives = drives.map((drive) => `${drive}/`);
  console.log('Valid Drives:', validDrives);
});

// new command
exec('powershell -Command "(Get-PSDrive -PSProvider FileSystem).Name"', (error, stdout, stderr) => {
  if (error) {
    console.error('Error:', error);
    return;
  }

  const drives = stdout
    ?.split(/\r?\n/)
    .map((line) => line.trim())
    .filter((line) => line);

  const validDrives = drives.map((drive) => `${drive}:/`);
  console.log('Valid Drives:', validDrives);
});

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf/pull/4533 **Author:** [@sir-wilhelm](https://github.com/sir-wilhelm) **Created:** 7/25/2025 **Status:** ✅ Merged **Merged:** 8/23/2025 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `wmic_replacement` --- ### 📝 Commits (1) - [`cae1560`](https://github.com/advplyr/audiobookshelf/commit/cae1560344fd14a5c00e02bd1f14db2394a75d8c) Use PowerShell to get windows drive paths. ### 📊 Changes **1 file changed** (+2 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `server/utils/fileUtils.js` (+2 -3) </details> ### 📄 Description wmic has been deprecated on newer versions of Windows 11 and is not installed. ## Brief summary Allows windows 11 users to select paths for their library w/o having to manually enable wmic. ## Which issue is fixed? fixes #4531 ## In-depth Description It uses PowerShell to get drive letters instead of wmic, It works since PowerShell is also installed on all Windows boxes. 2 users have reported it (mikiher/audiobookshelf-windows/issues/40 and #4531), but it'll impact anyone on the latest version of Windows 11 that do not enable wmic as a workaround. ## How have you tested this? I just tested the changes manually in a node repl to ensure the output was the same on a windows box: ```javascript const { exec } = require('child_process'); // old command exec('wmic logicaldisk get name', (error, stdout, stderr) => { if (error) { console.error('Error:', error); return; } const drives = stdout ?.split(/\r?\n/) .map((line) => line.trim()) .filter((line) => line) .slice(1); const validDrives = drives.map((drive) => `${drive}/`); console.log('Valid Drives:', validDrives); }); // new command exec('powershell -Command "(Get-PSDrive -PSProvider FileSystem).Name"', (error, stdout, stderr) => { if (error) { console.error('Error:', error); return; } const drives = stdout ?.split(/\r?\n/) .map((line) => line.trim()) .filter((line) => line); const validDrives = drives.map((drive) => `${drive}:/`); console.log('Valid Drives:', validDrives); }); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:19:06 +02:00
adam closed this issue 2026-04-25 00:19:06 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#4276