/build/static/layout/Breadcrumb_cap_w.png

.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)

Posted by: dchristian 12 years ago
Red Belt
0
What if you looped through everything in:
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
Fifth Degree Brown Belt
0
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 . . .

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

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Link

Related Links

Post

Related Posts

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ