Gali
Gali

Reputation: 14963

How to get to desktop of any user by text file?

I have ini file that I read in my program.

The ini file need to contain the desktop of any user.

How to write this?

%user%/windows?

Upvotes: 0

Views: 68

Answers (2)

Steve B
Steve B

Reputation: 37700

Try this code to get, in all cases, the actual desktop path :

for /f "tokens=3" %i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Desktop"') do @set desktop=%i
echo %desktop%

Actually, the desktop path can be changed. The value is stored under HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Desktop.

Do not forget to double % if you run this in a batch file.

Upvotes: 0

trickwallett
trickwallett

Reputation: 2468

If I understand your question correctly, try

%userprofile%\desktop

Upvotes: 2

Related Questions