Jump to content

Batch file to drop file into all users directories


Recommended Posts

Posted

Hi,

My first post so go easy on me!

I am trying to knock together a batch file, I am a batch file duffer, that can do the following...

Copy the normal.dot word template into the users directories.

The directory structure is as follows

c:\users\username\

Perhaps this isn't possible but I thought that maybe someone may know differently.

Thanks

Reg


Posted

well, i didnt understand EXATCLY what.....but

can it be similar at this.

copy c:\PATH\TO\DOT c:\user\%username%

so the dot file will be copied in the dir specified named AS the user DI

example

if the User is "Rtano" the script will copy the file in c:\user\Rtano

I hope it works.

Byez

Posted

You could easily do it in vbscript in several ways...

-Filesystem object (collection; objFolder.SubFolders ... best way imho)

-dir and testing if it's a directory (i like fso better)

-FindFirstFile (bleh...)

You'd also have to test not to copy to LocalService and NetworkService, and have some basic error handling and such.

You could do something similar in other languages (perhaps even with for %%a in *.* type of deal in .bat/.cmd too if you get creative) I'm sure there are other ways to this as well. Anyways, it's definately possible, it's actually quite basic scripting,

Posted

@echo off

c:

dir /b "C:\Documents and Settings\*" > users.txt

if %errorlevel%==0 FOR /F "eol=; delims=," %%i in (users.txt) do call :copydata "%%i"

call :copydata "Default User"

goto :eof

:copydata

echo %1

C:

cd "c:\Documents and Settings"

cd %1

xcopy "c:\copyfiles\*.*" "Application Data\*.*" /s/e/v

goto :eof

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...