How to copy files to all Users?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ssnnjr
Posts: 2
Joined: 07 Jun 2016 16:31

How to copy files to all Users?

#1 Post by ssnnjr » 07 Jun 2016 16:42

Any idea on how to create a batch file that will copy certain files to all Profiles/Users aside from putting the file in c:\users\default\desktops?

Thanks.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to copy files to all Users?

#2 Post by foxidrive » 08 Jun 2016 07:09

ssnnjr wrote:Any idea on how to create a batch file that will copy certain files to all Profiles/Users aside from putting the file in c:\users\default\desktops?

Thanks.

Where do you want to copy the files to?

ssnnjr
Posts: 2
Joined: 07 Jun 2016 16:31

Re: How to copy files to all Users?

#3 Post by ssnnjr » 08 Jun 2016 08:03

foxidrive wrote:
ssnnjr wrote:Any idea on how to create a batch file that will copy certain files to all Profiles/Users aside from putting the file in c:\users\default\desktops?

Thanks.

Where do you want to copy the files to?


to all users desktop

Monoennio
Posts: 2
Joined: 08 Jun 2016 09:16

Re: How to copy files to all Users?

#4 Post by Monoennio » 08 Jun 2016 09:22

for /d %a in (c:\users\*) do copy [myfile(s)] %a\Desktop

Substitute [myfile(s)] with your disk:\path\file(s)

Hope this help

M.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: How to copy files to all Users?

#5 Post by Compo » 08 Jun 2016 09:23

Do you mean C:\Users\Public\Desktop?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: How to copy files to all Users?

#6 Post by Squashman » 08 Jun 2016 10:12

Monoennio wrote:for /d %a in (c:\users\*) do copy [myfile(s)] %a\Desktop

Substitute [myfile(s)] with your disk:\path\file(s)

Hope this help

M.

The OP asked for a batch file. Your code will not work in a batch file.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to copy files to all Users?

#7 Post by foxidrive » 08 Jun 2016 10:24

Add a final command to delete the same files from "default\desktop"

Shows us your code if you want advice on it.

Compo wrote:Do you mean C:\Users\Public\Desktop?


I can see "default\desktop" in Windows 8.1 - it is a hidden folder.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to copy files to all Users?

#8 Post by foxidrive » 08 Jun 2016 10:28

Squashman wrote:The OP asked for a batch file. Your code will not work in a batch file.


It doesn't handle spaces in usernames either.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: How to copy files to all Users?

#9 Post by Compo » 08 Jun 2016 10:39

foxidrive wrote:
Compo wrote:Do you mean C:\Users\Public\Desktop?


I can see "default\desktop" in Windows 8.1 - it is a hidden folder.

Are you telling me that copying to a hidden folder is disabled?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to copy files to all Users?

#10 Post by foxidrive » 08 Jun 2016 10:46

Compo wrote:
foxidrive wrote:
Compo wrote:Do you mean C:\Users\Public\Desktop?


I can see "default\desktop" in Windows 8.1 - it is a hidden folder.

Are you telling me that copying to a hidden folder is disabled?


No.

Monoennio
Posts: 2
Joined: 08 Jun 2016 09:16

Re: How to copy files to all Users?

#11 Post by Monoennio » 10 Jun 2016 07:46

Squashman wrote:
Monoennio wrote:for /d %a in (c:\users\*) do copy [myfile(s)] %a\Desktop

Substitute [myfile(s)] with your disk:\path\file(s)

Hope this help

M.

The OP asked for a batch file. Your code will not work in a batch file.


True. In a batch file you must use double "%"

for /d %%a in (c:\users\*) do copy [myfile(s)] %%a\Desktop

M.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: How to copy files to all Users?

#12 Post by Compo » 10 Jun 2016 09:14

Based on a method I've posted here before:

Code: Select all

@For /F "UseBackQ Tokens=1* Delims==" %%A In (
   `WMIc Path Win32_UserProfile Where "Special!='True'" Get LocalPath /Value`
   ) Do @For %%C In (%%B) Do @Copy [myfile(s)] %%C\Desktop

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to copy files to all Users?

#13 Post by foxidrive » 14 Jun 2016 22:56

Monoennio wrote:True. In a batch file you must use double "%"

for /d %%a in (c:\users\*) do copy [myfile(s)] %%a\Desktop

M.

It's nice to see you here Monoennio, but please note this too.

foxidrive wrote:It doesn't handle spaces in usernames either.

Post Reply