0

So this is what i have got so far, the "%cd%" is meant to go to the current directory, then the "Test.exe" is the file i want to copy. But i need help specifying, that i want to copy it to Desktop, without knowing the drive letter or the username. But when i try this, it doesn't work. Any help is greatly appreciated. This is the code i have got -

xcopy /s "%cd%\Test.exe" "%drive%\Users\%Username%\Desktop\"

I also want to run the "Test.exe" as well after it has been copied to that location.

  • Well, if the script is not able to know about the drive or username, you'd have to help out. Do you mean the currently logged in user? – Nico Haase May 13 '18 at 10:42
  • Yes i mean to the currently logged in user –  May 13 '18 at 10:43
  • 4
    Possible duplicate of [What's the environment variable for the path to the desktop?](https://stackoverflow.com/questions/2000638/whats-the-environment-variable-for-the-path-to-the-desktop) – Nico Haase May 13 '18 at 10:44
  • ok thanks for the help –  May 13 '18 at 10:47
  • 2
    Why can you not run `Test.exe` from its original location instead of copying it first? Also the usage for the depracted command, `XCopy /?` should show you that your `/s` option looks incorrect in the context of your command. `"%UserProfile%\Desktop"` is the usual location for a users desktop, but it may not be there, and depending upon how you're accessing their PC, may not be readable in the users context. You should really provide more information, by [editing your question](https://stackoverflow.com/posts/50315099/edit), if you want anything other than your question closing as a duplicate. – Compo May 13 '18 at 11:03
  • 1
    You do realise that doing `set` from cmdline shows you a lot? have you tried `echo %userprofile%` and perhaps `dir %userprofile%\desktop` – Gerhard May 13 '18 at 15:06

0 Answers0