.cmd file assistance
can anyone provide or show me how to write a .cmd file that will copy a file to the same folder for every profile on a Windows 7 machine? So if I have 3 profiles or 30 it will still copy the file to every folder.
0 Comments
[ + ] Show comments
Answers (2)
Please log in to answer
Posted by:
dchristian
12 years ago
What if you looped through everything in:
dir /b %userprofile%\..
dir /b %userprofile%\..
Comments:
-
I tried that and I guess I wrote in wrong. I have this: for /f %%a in ('dir /b "%userprofile%") do start copy *.txt %userprofile% %%a and it says it can't find file /b myProfile - mhsl808 12 years ago
-
There's two dot's (..) at the end of the %userprofile%.
This tells the command to go up a level, so you can get the listing. - dchristian 12 years ago
Posted by:
mhsl808
12 years ago
I tried that and it gives me this error output.
C:\Temp>for /F %a in ('dir /b "") do start copy *.txt C:\Users\MyUserProfile %a
The system cannot find the file 'dir /b "".
C:\Temp>pause
Press any key to continue . . .
C:\Temp>for /F %a in ('dir /b "") do start copy *.txt C:\Users\MyUserProfile %a
The system cannot find the file 'dir /b "".
C:\Temp>pause
Press any key to continue . . .
Comments:
-
Here's a simplified example.
@echo off
set filer=C:\myfile.txt
IF NOT EXIST %filer% (
EXIT
)
IF EXIST C:\users (
for /f %%a in ('dir /b "C:\users\"') do xcopy /Y %filer% "c:\users\%%a\"
)
IF NOT EXIST C:\users (
for /f %%b in ('dir /b "c:\Documents and Settings\"') do xcopy /Y %filer% "c:\Documents and Settings\%%b\"
) - dchristian 12 years ago