54D
54D

Reputation: 219

Location of Desktop Shell Folder

Is there any code or parameter to specify the desktop file on a user's computer, but is also compatible on other users in a batch file?

Or here's an example. Here's a code

move -y temp.bat [The parameter I'm asking for]

I'm asking if there is a parameter that can be used to specify the Desktop on both A's computer:

C:\Users\A\Desktop

And B's computer:

C:\Users\B\Desktop

Thanks.

Upvotes: 2

Views: 560

Answers (1)

mojo
mojo

Reputation: 4142

Windows has the means of accessing Shell Folders (via the registry or .NET) so that any application that wants to can find it.

Here's how it can be obtained using PowerShell.

SETLOCAL

FOR /F "usebackq" %%f IN (`PowerShell -NoProfile -Command "Write-Host([Environment]::GetFolderPath('Desktop'))"`) DO ( SET "DESKTOP_FOLDER=%%f" )

@ECHO %DESKTOP_FOLDER%

Upvotes: 2

Related Questions