Win32_Directory with gcc???

Posted on 2006-06-12
Last Modified: 2012-06-27
How do I compile Win32_Directory with gcc?

The headers I need are:
and the library would link to is:

Here is the real delema.  Win32_Directory may not even be the answer I need.

At my place of business, we copy the user profile that we are currently working with to the Default User so that any regular user who logs on has a consistant profile to work with. Then we use DeepFreeze to preserve the current state.

I am making a program to do this because we work on hundreds of computers doing this over and over again. The trouble is, when I try to open the file, NTUSER.DAT and others in the active profile directory, I cannot, because the files are in use by windows.

I know there is a way to copy the active directory and all it's contents because Windows does it. The OS is Win 2000 and if you right click on My Computer - Properties - Users - From there you have the option to copy any profile, even if it is the active profile.

Is there an api call I can call to copy the active profile or some other way to do this?
Question by:aewarnick
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 15

Expert Comment

ID: 16888044
I think it's probably easier than that. NTUSER.DAT is, in fact, the HKEY_CURRENT_USER part of the registry, so you can use regedit32.exe to save the standard version (the "hive"?) and then use File/Import or File/Load Hive to sync the machine to the standard stuff.

Author Comment

ID: 16888418
That's is the kind of thing I'm trying to avoid though.  I need to do everything in my program to make this process fast and easy and efficient.
LVL 15

Expert Comment

ID: 16888615
I suspect you also want it to be reliable, which is why regedt32.exe is a good solution. You only have to copy the data from the "correct" setting once, using File/Export. This will create a file called foo.reg. Then all you have to do for the other machines is call "regedt32 foo.reg" from a batch file. Sounds pretty simple, reproducible, efficient and reliable to me! :-)
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16889230
That would mean putting a disk or some other media in each computer to call it.  Not a valid solution for me.  It's not near as efficient as having a program start when logging in and pressing a button to copy one profile over the Default User profile.

Author Comment

ID: 16896115
This seems to be a really hard or highly unknown issue.  Noone could answer it with any certainty on CodeGuru either.

Registry editors have to implement this some way.  They can even write to the registry file that is in use!  There must be a way to simply COPY the files in the active user directory
i.e. C:\Documents and Settings\TheUser

Author Comment

ID: 16896920
I guess registry editors would use registry functions to get registry keys and that is not what I need.  What I need SHOULD be very simple.  I simply want to copy the NTUSER.DAT file.

Accepted Solution

johndarby earned 125 total points
ID: 16898829
I have setup all my CAD users to have a similar effect. However, I went about it a bit differently.

1. Created a new OU for specific users and assign a specific user profile (CAD user, Office Admin user, AD Admin user, etc)
2. Upon login, the specific user draws his/her user profile from the group policy
3. Admin users can then alter their own profile as they wish and other users have various grades of control depending on group membership

Leveraging using GPOs also prepared us for automated software deployment using Softgrid and SMS. This help with licensing and resource tracking.

If you absolutely must use your current method of manual copy to localhost\Default User, I would suggest attaching this procedure to a group policy and join whichever systems need this particular policy to receive the update. Of cousre, it will be a case of reboot the system and actively push the GPO.

I am unsure if this helped, but I am more than willing to help you write the GPO which suits your need.

LVL 15

Expert Comment

ID: 16900765
How do you want to execute this? I presume you want minimal intervention on the user machine, but can deploy a program. If this is the case, you can deploy a batch file and a registry hive and use the reg command:

    REG LOAD HKU myuser.dat

Would that work?

Author Comment

ID: 16913777
I simply want to do this the way Windows does it.  When I am logged in as the administrator account that I want to copy over, I can right click on My Computer and from there Copy the profile I'm using to the Default User profile.  My method will be much much more simple though: One push of a button from a program that will be installed on all the machines, and it's done.

Here is what I assume: Windows does not give itself special access to the NTUSER.DAT file.  It uses the RegGetKey (whatever the function is called) and other registry functions to parse the registry data into a registry file in the same format as the NTUSER.DAT file and then copies that file over the Default User NTUSER.DAT file.

Does that sound right?  If so, that's the way I'll have to do it.
LVL 15

Assisted Solution

bpmurray earned 125 total points
ID: 16913875
I completely understand: that's why I keep pointing to the way Windows does it! You can load two files onto each machine: standard.dat and update-registry.bat. The batch file has a single line that says "REG LOAD HKU standard.dat". Place a shorcut to the batch file on the desktop. Double-click and Bob's your uncle.

All this with NO programming, i.e. a system guaranteed to be bug free (or at least as bug-free as the OS since it's part of the OS), and simpliciity and reliability built in.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question