Solved

Win32_Directory with gcc???

Posted on 2006-06-12
12
596 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
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.
0
 

Author Comment

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

Expert Comment

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

Author Comment

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

Author Comment

by:aewarnick
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

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

Accepted Solution

by:
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.

Cheers,
John
0
 
LVL 15

Expert Comment

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

Author Comment

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

Assisted Solution

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
count8 challlenge 13 119
changeXy challenge 13 69
topping2 challenge 13 83
Eclipse Neon start with Admin account only 6 95
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

863 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

19 Experts available now in Live!

Get 1:1 Help Now