Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

path of user desktop in batch files

I am doing a simple batch file to copy folders and files located under the same path of the batch files to the desktop. I can easily get the path where the batch file is located using

%~dp0

but I want to know how to get the path of the user's desktop (I am using Widows 7 Ultimate)

Any suggestions?

like image 235
Jack_111 Avatar asked Sep 05 '13 07:09

Jack_111


People also ask

How do I find the Desktop location in CMD?

Often when opening the command prompt window, you automatically be placed in the (username) directory. Therefore, you only need to type cd desktop to get into the desktop. If you're in any other directory, you would need to type cd \docu~1\(username)\desktop to get into the desktop.

What is the file path for Desktop?

The location of the Desktop folder in most versions of Windows is %USERPROFILE%\Desktop , which for most users becomes C:\Users\YOURUSERNAME\Desktop .

How do I set my Desktop path?

Right click on your desktop folder in the current location. Click on properties and then click on location tab. Type in the new location you want your desktop to be in. Then click apply and ok.

What is %1 in a batch file?

When used in a command line, script, or batch file, %1 is used to represent a variable or matched string. For example, in a Microsoft batch file, %1 can print what is entered after the batch file name.


2 Answers

I suppose you're under windows environnement, so %USERPROFILE%\Desktop should be ok

like image 165
Mali Avatar answered Oct 24 '22 17:10

Mali


This is the location of the current users desktop:

%userprofile%\desktop
like image 36
foxidrive Avatar answered Oct 24 '22 18:10

foxidrive