Copy a File In Use on Reboot

I've found this inuse.exe program that takes advantage of the MoveFileEx() API.  It's a nice utility if you'd like to "MOVE" a file on reboot.  Notice the emphasis on MOVE.  I'd like to COPY a file on reboot.  Emphasis on COPY.  :)  I flat out don't want the the original file removed.  I've considered writing an app to high jack some registry entries to get the job done (I just need the copy done before the user logs in), but that seems so sloppy and why reinvent the wheel if someone has made such a system already.  The one file I whish to copy is impossible to do so while the user is logged in (NTUSER.DAT of the logged in user).

I will not accept an answer such as "log in as someone else with admins rights and copy ntuser.dat".  That's what I'm doing right now.  It's a hassle and it sucks.  I want to run xzy.bat or xyz.exe, reboot and have the ntuser.dat already copied.

Thanks in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ElmerFudAuthor Commented:
Now I remember why I stopped comming to Expert's Exchange....  I'm better apped to help myself rather than rely on the base of knowledge here.  I guess I could hang around EE and answer newbie questions, but why do that when I have a life and a career to maintain?

Even the lure of 500 points hasn't pulled anyone in with a solution or even a comment for that matter.  Hell, given about 10 hours of coding time, I could create and app that solves this problem.  Am I to believe that no one has done this before me?  Doubtful.

I have like 10K points just sitting here.  I should just dump them all on this one question for $hits and giggles, cause this place is worthless.
comon, you can't expect recieving answers on complicated question such as this so fast, the real genius of EE also have lives and career, you know :)

anyway, if its so important for you, instead of copying filed from the user profile before it login you can' simply create a roaming profile of that user and put it on a nework drive
lets say you have a file server called "myfileserver", just create a shared directory there called "profiles" or something like that
under active directory users and computers right-click the user you wish to make as a roaming profile and mark it and put he's directory under that specific share (\\myfileserver\profiles\user)

from now on that directory will hold the updated ntuser.dat and it'll be resyncronized every time a user logoff any computer, so thats preety updated registry file

hope this helps!
and quit crying man... your not the type to give up :)
ElmerFudAuthor Commented:
I'm fully aware of roaming profiles and how to use them.  This is unreleated.  I'm creating a template NTUSER.DAT for new users who login for the first time.  This way each new user starts with the same base settings (not the default ones).

Copy File on Reboot FROM:

C:\\WINNT\Profiles\Robert\NTUSER.DAT   (the setup template NTUSER.DAT)


C:\\WINNT\Profiles\Default User\NTUSER.DAT

because NTUSER.DAT is a part of the current registry when logged in, you cannot copy it unless you use a user other than "Robert" (must have admin rights on the system).  The current solution is to log in a UsernameX and copy said file to it's destination.
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

I did that one aswell, I just used a template user, called "kobebe" for example, did whatever I wanted to change (hide icons, change toolbars etc.) and then logged-off, logged-on as local administrator and copied the entire user folder to the default user, then every user logged on had those configurations
sice you seem to be aware of that I still dont get what is your problem
ElmerFudAuthor Commented:
It's a hassle.  When I setup these machines, there is one user, "Administrator".  Therefore, in order to copy that NTUSER.DAT, I have to create a second username on the machine.  I also have to "Shutdown", because Logging off will store "log off" as the option the user sees when he clicks shut down.  So....


1.) create user "tmp"
2.) assign admin rights to "tmp" so he can copy NTUSER.DAT from another profile
3.) shut down
4.) login as tmp
5.) copy NTUSER.DAT
6.) log off tmp
7.) log in Administrator
8.) delete tmp's profile
9.) delete tmp's username

When I saw this MoveFileEx() API and this cool inuse.exe I was excited to see that I could Move or Delete a file on reboot.  Moving NTUSER.DAT from one profile to the next, however, isn't a good idea.  You'll kill the source profile.  Anyway, if Copy File on Reboot was was possible, this would be much easier:

1.) run copyinuse app
2.) reboot

I think I might be able to do it with RunService or RunOnce registry keys (HKEY_LOCAL_MACHINE).  If memory serves me, one of them is executed prior to login.  The copyinuse app could simply stick a command line to itself in that key.  Then on reboot,it would copy the file and, of course, remove itself from the registry.

I asked this question hoping some utility already existed to do this.  I guess I'll have to code the app myself.  I was just a little frustrated because all of my rescent questions have sat here on EE and rotted away until some moderator deletes them or something.  I guess this one will do the same.
ElmerFudAuthor Commented:
Crap, I wish I could edit posts..  Anyway, above should be:


The process isn't as bad when the machine it joined to the domain, but typically it prior to joining to the domain and hence you get the problem of having only one admin account on the machine.
I see what you meen... I haven't heared about that api, or anything realted to... sorry
but I'll really appreciate if you'll send me the code (or the binary file) once you're done, it might be preety helpful in the future

I'll ask around, if I'll have any ideas I'll get back to you
ElmerFudAuthor Commented:
thanks kobebe, I appriciate the comments and the help.

If I end up making the app (not a lot of free time here), I'll send you the code and binaries.  The above method isn't pretty, but I think it will work.
by the way, I've thought of another solution, I hope it'll work for you

you can use the group policy in order to copy that specific file (c:\winnt\profiles\defualt user\ntuser.dat) to anywhere you desire when the computer is powering up before you actually login, and any script that run at that state gets administrator privilages (it uses the machine privilages, not a normal user), that way you can creat a simple batch with 1 copy command to do that

if the computer is a member of a domain it'll be even easier

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ElmerFudAuthor Commented:
That works great!!  good job and thanks.
ElmerFudAuthor Commented:
For those reading/searching...

This is the batch file that I ended up making.  xcopy and the /Y /H is needed bacause these are hidden system files and you need to replace the existing files:

@echo off
xcopy "C:\Documents and Settings\Administrator\NTUSER.DAT" "C:\Documents and Settings\Default User\NTUSER.DAT" /Y /H
xcopy "C:\Documents and Settings\Administrator\NTUSER.INI" "C:\Documents and Settings\Default User\NTUSER.INI" /Y /H

here's another tip, at the command prompt, type:

start gpedit.msc

that will bring up the group policy editor.  Just add the startup script (for the machine).  The batch file seemed best placed in:


This is a good tip and brings a lot of new ideas how to make this process easier for me.  Thanks.  This was done on a Windows 2000 Pro machine.  Should work good on XP and probably similarly on Windows NT.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.