Skip to content

Instantly share code, notes, and snippets.

@fastfingertips
Created March 16, 2024 04:32
Show Gist options
  • Save fastfingertips/5747c918783c3343f2c907d76f470b5a to your computer and use it in GitHub Desktop.
Save fastfingertips/5747c918783c3343f2c907d76f470b5a to your computer and use it in GitHub Desktop.
This batch script retrieves the path of the desktop folder on a Windows system using PowerShell and then echoes (displays) the path.
@echo off
SETLOCAL
FOR /F "usebackq" %%d IN (`PowerShell -NoProfile -Command "Write-Host([Environment]::GetFolderPath('Desktop'))"`) DO (
SET "DESKTOP_FOLDER_PATH=%%d"
)
@ECHO Desktop Path: %DESKTOP_FOLDER_PATH%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment