When i try to move the file I get an error message that the file cannot be found, I did notice that the shortcut file does not append .lnk in the folder view even though i have "hide known extensions" unselected.
also the cmd.exe dir command shows the file exactly as written.
if i add the .lnk to the windows explorer file, i get .lnk.lnk and i still get file not found
IF NOT EXIST "%USERPROFILE%\Desktop\Remote Service Restarter.lnk" ( echo f | xcopy /f /y "Remote Service Restarter.lnk" "%DESKTOP%\Remote Service Restarter.lnk" ) ELSE ( del "Remote Service Restarter.lnk" echo removing redundant installer file ) any ideas?
32 Answers
Can you try '%USERPROFILE%\Desktop' instead of '%DESKTOP%' on the second line?
Is there folder redirection involved here? (what does echo %DESKTOP% give you?)
You may need to access from %USERPROFILE% if there is
1There are 2 locations for the Desktop path. One is the per user desktop folder, and the other is the all users desktop folder.
It is likely that the file is located in the other folder, thus you see the file on your desktop, but your batchfile can't actually find it.
The locations are:
%USERPROFILE%\Desktop%PUBLIC%\Desktop
Also, keep in mind, %DESKTOP% is not an environmental value that exists by default and will not be present on most systems. It may actually not exist on your own system either. Using the 2 paths above is guaranteed to work on any system from Windows XP and up.
1