Solved

Win32_Directory with gcc???

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

The headers I need are:
comdef.h
Wbemidl.h
and the library would link to is:
wbemuuid

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?
0
Comment
Question by:aewarnick
  • 5
  • 4
12 Comments
 
LVL 15

Expert Comment

by:bpmurray
Comment Utility
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.
0
 

Author Comment

by:aewarnick
Comment Utility
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.
0
 
LVL 15

Expert Comment

by:bpmurray
Comment Utility
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! :-)
0
 

Author Comment

by:aewarnick
Comment Utility
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.
0
 

Author Comment

by:aewarnick
Comment Utility
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
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:aewarnick
Comment Utility
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.
0
 
LVL 1

Accepted Solution

by:
johndarby earned 125 total points
Comment Utility
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.

Cheers,
John
0
 
LVL 15

Expert Comment

by:bpmurray
Comment Utility
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?
0
 

Author Comment

by:aewarnick
Comment Utility
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.
0
 
LVL 15

Assisted Solution

by:bpmurray
bpmurray earned 125 total points
Comment Utility
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.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maxMirror challenge 10 87
scoreUp challenge 14 47
Enhanced For loop vs ForEach Loop 4 54
base64 decode encode 12 94
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
This article will show, step by step, how to integrate R code into a R Sweave document
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now