Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch File to Copy File
Name: JohnRChick Date: April 30, 2005 at 18:24:00 Pacific OS: 2003 CPU/Ram: 2.5/1/25
Comment:
Hello. I'm trying to create a batch file that will copy one file from one place to another. I need to use the %username% function since this will be used on a several different computers. Heres what I have, but its not working!
copy C:\Performance.txt to C:\Docume~1\%username%
- I can copy the file to the \Docume~1 folder, but I can never get the %username% thing to work! I tried shortening it, with ~1, etc but it still wont work! Sometimes it makes a new file instead. I tried this:
Name: Curt R Date: May 2, 2005 at 05:12:37 Pacific
Reply:
Try using double quotes around the string containing the long names:
Ex:
copy c:\performance.txt "C:\documents and settings\%username%"
0
Response Number 2
Name: Curt R Date: May 2, 2005 at 05:15:55 Pacific
Reply:
Oh shoot...I just realized. in order to use the %username% variable, it needs to pull that info from somewhere. Without an actual username to associate the variable to the file copy will go nowhere. So the question is: where/how are you getting the username?
My above example should work on as a batch file on a local PC and the variable would use the username of the person presently logged onto the the local PC.
Summary: Hello, I am new to windows scripting. Pardon me and forward me to right URL if this has been posted before. I tried but was not ale to find the required one. Here it goes. i have iis logs gen...
Summary: hi all, i need to write a batch file in win 2003 server machine which checks whether a file exist in a unix machine. For example: Honda is my windows machine. I need to right a batch file filecheck.ba...
Summary: Change the file extension to .cmd and give it a try. This is the first thing I would do. I had only a slightly similar situation. Although my batch file ran, the exit code was never sent back to the ...