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?
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.
The location of the Desktop folder in most versions of Windows is %USERPROFILE%\Desktop , which for most users becomes C:\Users\YOURUSERNAME\Desktop .
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.
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.
I suppose you're under windows environnement, so %USERPROFILE%\Desktop
should be ok
This is the location of the current users desktop:
%userprofile%\desktop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With