Question:
Help with Batch file moving?
2012-03-02 16:34:43 UTC
Hello, I am trying to get batch to copy a file from a folder to the desktop. It works but the problem I am having is when I put in the directory I have to put in the username of the computer. But I need this to work on any computer with out changing the username.

This is the code I have:
XCOPY C:\Users\Dave\AppData\Roaming\Test.txt C:\Users\Dave\Desktop
I need to eliminate Where it says Dave and have it work for any user on any computer.
Four answers:
Jake
2012-03-03 07:07:44 UTC
echo off

XCOPY "%appdata%\Test.txt" "%userprofile%\Desktop"



Also, even though you're using Windows vista or 7, it's probably a good idea to encase the paths in quotations, like so. This is so that it would still work on windows xp.



%appdata% is the same as C:\Users\%username%\AppData\Roaming

%userprofile% is the same as C:\Users\%username%\Desktop





For a full list of these "environment variables" type at the command prompt: SET and then press enter.
2014-08-15 22:28:53 UTC
You can download ccleaner for free here: http://bit.ly/1Bk5V5C



First open CCleaner

Go to the Cleaner tab and you will be confronted by a very confusing lineup of checkboxes.

To make this brief, below is my recommended setup:

Under internet explorer check temporary internet files, cookies, and last download location. Most users don't really need this stuff. keep history and bookmarks unchecked, history is a maybe, but you don't want to lose bookmarked sites. You can normally leave Windows Explorer, System, and Advanced alone.

Run CCleaner and it will start deleting files.

afterward it will present you with a list of the files deleted, you really don't need to go through it as it will be several pages long.

The registry cleaner is recommended for slightly more advanced users. Use it after uninstalling programs as they will often leave behind incorrect registry entries.

If you decide to run Registry cleaner then review the items detected and always back up the registry (I keep a folder aside for this)

The Tools tab lets you uninstall programs and set startup programs. Why do you need this if Windows has all of these features? Especially with Vista Home Ed. The windows defender software explorer( startup programs) doesn't pick up some entries (however software explorer is easier to use).

Using CCleaner to uninstall programs and then check for leftover registry entries takes less time.

Under Options you can determine how CCleaner cleans your files. I leave this alone.
brisray
2012-03-02 17:17:33 UTC
If you type SET in a comamnd prompt you'll see what is know as the envirnment variables. These are available for use in your own programs. For example, there's one on my machine that says



USERPROFILE=C:\Users\brisray



you can use it like this



xcopy %userprofile%\appdata\roaming\test.txt %userprofile%\desktop



You may want to test that the file exists before you try to copy it. If it doesn't it could crash your programs so use IF EXIST http://stackoverflow.com/questions/4340350/how-to-check-if-a-file-exists-from-inside-a-batch-file and http://www.computerhope.com/if.htm
?
2012-03-02 16:45:17 UTC
Try allusers instead of Dave


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...