MSFN Forum: Duplicated User Accounts - MSFN Forum

Jump to content



  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Duplicated User Accounts Rate Topic: -----

#1 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 12 January 2005 - 12:38 AM

Hi All,

I have been doing some stuff with unattended backup and installs using scripted installs and ghost. A user logs on to the system, their user account is created on partition 2 (system is on partition 1) so it is easy to restore or upgrade a system without having to do much with the user data.

This all works correctly, however the problem i have is after i restore partition 1 using ghost, and the same user logs on again, they have a new account created using the preferences in the default user profile because the system does know anything about their profile even know it is still on partition 2 - so the user profile folder is duplicated with the machine name appended. see below

before restore
d:\documents and settings\user1

after restore
d:\documents and settings\user1
d:\documents and settings\user1.machine_name

Does anyone know how to overcome this issue?

Any and all help appreciated :)


#2 User is offline   MCT 

  • MSFN Junkie
  • PipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 3,288
  • Joined: 19-May 04

Posted 12 January 2005 - 12:58 AM

put the files in $OEM$\$Docs into an SFX file & have it extract @ T-12
the problem occurs when windows sees the directory is already made

#3 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 12 January 2005 - 01:01 AM

MCT, on Jan 12 2005, 02:58 PM, said:

put the files in $OEM$\$Docs into an SFX file & have it extract @ T-12
the problem occurs when windows sees the directory is already made

Thats a good idea, however it will old work if i was doing a scripted install - i am having the problem after a restore of partition 2. That is to say i have already installed the system to partition 1 via unattended method and then taken a ghost image of partition 1. now when i restore partition 1 from the backup image i have the problem stated above.

#4 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 12 January 2005 - 09:28 AM

Has no one seen this problem?

#5 User is offline   TrAvELAr 

  • Junior
  • Pip
  • Group: Members
  • Posts: 71
  • Joined: 12-November 03

Posted 12 January 2005 - 11:55 AM

Are you running sysprep before you make your ghost image or are you just imaging the drive?

#6 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 12 January 2005 - 07:13 PM

TrAvELAr, on Jan 13 2005, 01:55 AM, said:

Are you running sysprep before you make your ghost image or are you just imaging the drive?

Yep sure am and the mini setup is running after the restore to fix duplicate SID's

#7 User is offline   TrAvELAr 

  • Junior
  • Pip
  • Group: Members
  • Posts: 71
  • Joined: 12-November 03

Posted 13 January 2005 - 07:29 AM

When you sysprep it, did you tell it to generate a new sid (only required if the restore is going to another machine)? If you are generating a new sid, that would cause this problem.

-nosidgen - Runs the Sysprep.exe file without generating new SIDs. You must use this parameter if you are not duplicating the computer where you are running the Sysprep.exe file or if you are preinstalling domain controllers.

#8 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 13 January 2005 - 07:29 PM

TrAvELAr, on Jan 13 2005, 09:29 PM, said:

When you sysprep it, did you tell it to generate a new sid (only required if the restore is going to another machine)?  If you are generating a new sid, that would cause this problem. 

-nosidgen - Runs the Sysprep.exe file without generating new SIDs. You must use this parameter if you are not duplicating the computer where you are running the Sysprep.exe file or if you are preinstalling domain controllers.

Good point and yes i have tried both. The problem arrises because the restore is from a default clean image and so it doesn't know about the users that have logged on since the build... therefore when the machine is restored the accounts as far as the USER Accounts are missing... so basically i need to be able to backup the sam and security configurations and then restore those... something you may be interested in is this information - this basically is what is happening.

HOW TO: Restore a User Profile

#9 User is offline   TrAvELAr 

  • Junior
  • Pip
  • Group: Members
  • Posts: 71
  • Joined: 12-November 03

Posted 14 January 2005 - 07:09 AM

Ahhh... I see now. I was assuming that the user base was already populated. :) Let me do some investigating for you today.

#10 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 17 January 2005 - 01:09 AM

TrAvELAr, on Jan 14 2005, 09:09 PM, said:

Ahhh... I see now.  I was assuming that the user base was already populated.  :)  Let me do some investigating for you today.

Hi TrAvELAr,

Thankyou for taking the time to investigate and help me out - i would be interested in reading what you find out....

In the meantime i have managed to write a batch file to check this and correct the issue automatically - I am in the process now of looking to programing it into a single com or exe file as there are some other utils like getsid and reg that are currently used with the batch file that i believe i can do away with in a single application file.

I will post the results when i have finished :) Look forward to reading your next message. :whistle:

#11 User is offline   TrAvELAr 

  • Junior
  • Pip
  • Group: Members
  • Posts: 71
  • Joined: 12-November 03

Posted 19 January 2005 - 06:20 AM

Hey 'Felix',

Sorry for the delayed response, but things got a bit hectic around here. I was able to reproduce this, but I have not had sufficient time to come up with a working solution. It sounds like you have something in the works tho, albeit somewhat painful.

I'm interested in seeing what you've come up with.

#12 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 28 January 2005 - 01:49 AM

Hi TrAvELAr - sorry bout the delayed response.....

Ok here is my present solution (fully tested and working)
[Tested on Windows 2000, Windows XP and Windows 2003 - Windows NT users a little bit different naming process]

UserProfileChecker.cmd
@echo off
cls
::If other than WinNT (2000/XP/2003) Environment - bailout.
IF %OS%!==! GOTO _NotNT
setlocal
GOTO _CHECKS

:_CHECKS
::Get current user SID.
FOR /F "tokens=7" %%A IN ('getsid \\%computername% %username% \\%computername% %username%') DO SET USERSID=%%A
::Get current user Profile Path.
FOR /F "tokens=2* delims=\" %%A IN ('reg query "hklm\software\microsoft\windows nt\currentversion\profilelist\%USERSID%" /v ProfileImagePath') DO SET PIP=%%B
::If the current username and the current user profile path match - bailout!
IF "%USERNAME%"=="%PIP%" goto _eof
::Set Directory to be removed next logon...
FOR /F "tokens=2*" %%A IN ('reg query "hklm\software\microsoft\windows nt\currentversion\profilelist\%USERSID%" /v ProfileImagePath') DO SET ToRemove="%%B"
::Get the system profiles path - normally %systemdrive%\documents and settings\
::Or D:\documents and settings\
FOR /F "tokens=2*" %%A IN ('reg query "hklm\software\microsoft\windows nt\currentversion\profilelist" /v ProfilesDirectory') DO set USERDIR=%%B
::Check the system profiles path for a directory name that matches the username
echo %USERDIR% | DIR /AH /B "%USERDIR%\%username%\NTUSER.DAT" | find /c /i "NTUSER.DAT" >NUL
::If no match - bailout!
if errorlevel 1 goto _eof
IF NOT "%USERNAME%"=="%PIP%" GOTO _ModifyUserImagePath

:_ModifyUserImagePath
call :_splash
::Let the user know something is happening...
popup /YN /HF "userprofilechecker.hlp" /IE /M "Duplicate User Profile Detected" /T "User Profile Checker 1.0"
if errorlevel 7 goto _eof
::if use says yes - then update the users SID Profile Image path to original value...
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%USERSID%" /v ProfileImagePath /t REG_EXPAND_SZ /d "%userdir%\%username%" /f >NUL
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths" /v %USERNAME% /d "%userdir%\%username%\My Documents" /f >NUL
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v RemoveDuplicateProfile /d "%comspec% /C RMDIR /S /Q ""%ToRemove%""" /f >NUL
rem shutdown -l -f
goto _eof

:_NotNT
cls
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo This program is designed for Windows NT, Windows 2000, Windows XP, Windows 2003
echo and above.
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo.
goto _eof

:_ERROR
cls
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo  You have cancelled this update, as a result your profile will not be updated.
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo.
goto _eof

:_Splash
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo  User Profile Checker v1.0
echo  Copyright 2004-2005 Darren Blackley, Simplify I.T. All rights reserved.
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

:_EOF


Required 3rd party utilities for the batch to work.
REG.EXE - Windows Resource Kit
GETSID.EXE - Windows Resource Kit
SHUTDOWN.EXE - Windows Resource Kit
POPUP.EXE - Just a windows message popup for notifying the user. (Attached)

UserProfileChecker.hlp
********** A DUPLICATE OF YOUR USER PROFILE HAS BEEN DETECTED. **********

This situation can happen when your computer has been restored from a disaster/
System crash, an operating system upgrade, a service patch/hotfix or your user
Account has been erroneously deleted from the computer.  

Your original user profile including your files should all be available under your
original profile directory.  Presently you are operating on a default (new) 
profile that Windows as created for you because it has found a duplicate directory.

To restore your original profile and regain access to all of your original user
configuration including My Documents etc. - Click on YES. 
Note: Once you click yes, your profile will be automatically corrected and you will
be automatically logged off.  Simply Login again to gain access to your original 
profile.

If you do not wish to restore profile or require more information click NO and
contact your local IT support staff member.

For more specific information visit this reference on the Microsoft website:
http://support.microsoft.com/default.aspx?scid=kb;en-us;314045


Next step is to build it all into a single exe or com so that no third party utils are required, however i am going to have to go away and learn some delphi or something to do that... any programmers like to give it a try? :)

Attached File(s)

  • Attached File  popup.zip (41.27K)
    Number of downloads: 65


#13 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

  Posted 03 March 2005 - 01:51 AM

Hi there all,

Finally after some weeks and many, many hours of work i have completed the next version of User Profile Checker. Version 2.6 YAHOO! :w00t:

It is now a compiled file and has lots of smarts built in.

USE:
Ok now to use it you simply add it to the runonce key of your user profile - i suggest adding it to your default user ntuser.dat hive (if you want to know how to do this Click here).

If you add it to your default user runonce then add the command option RESTART. eg. UPC.EXE RESTART. What this will do is if any changes are made, UPC will then restart your computer after notifying the user. This is required to completely allow the change to be implemented and to remove the duplicate directories.

If you add UPC.EXE to your RunOnceEx during installation and you have a reboot at the end of your installation there is no need to use the RESTART option.

Each time you run UPC.EXE a log file called "AllUsersProfilefix.log" will be generated in c:\.

INSTALLATION:
-Installing to existing installation.
Simply extract the contents of the archive attached to your %systemdrive%\windows\system32 directory then it will be in the path and available from anywhere.

-Installing to AIO Installation CD or Network Share.
Simply extract the contents of the archive attached to your [path to AIO install point]\$oem$\$$\System32 directory then it will be in the path after your new installation of windows and available from anywhere.

Caveats:
- User must have Administrator access. I have not done any testing with Power Users accounts, however i expect it would work if you have allowed Power Users to make changes to the registry.

- Currently UPC will address the following profiles the first time you use it:
all users.windows, default user.windows, localservice.nt authority and networkservice.nt authority - the last 3 are normally hidden. It will also address the current user logged on by using the %username% environment variable. Other user accounts will not be effected until the actual user logs on.

TODO LIST:
- Address ALL system users (not All User profile) in a single pass, thus allowing an administrator to logon and run UPC once to correct the profiles and remove the duplicate directories.

- Add addition command line options: shutdown timeout, logfile name and location & some help syntax.

- Fully document functions and features.

- Maybe redevelop using VB or something else that would allow for the functions performed by getsid, popup and reg to be done internally.
---------------

Well that is about it for now, however we am open to suggestions and comments.

PLEASE TEST first before adding this to production systems. We (esas and I) have spent many weeks testing in VMware and actual machines, however we may have missed something. :blushing:

Well i hope this address' your needs and is helpful - enjoy! :thumbup

Ok esas has been continuing to refine my orginal code and has now compiled the code and related files into a single exe file that works very well. you can now download the current version here UPC | Mirror #1

Special Thanks to esas for his continuing work! :yes:

Attached File(s)

  • Attached File  UPC.rar (114.83K)
    Number of downloads: 76

This post has been edited by `Felix`: 06 December 2005 - 08:57 PM


#14 User is offline   esas 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 07-February 05

Posted 03 March 2005 - 07:07 AM

Great work Felix!

I'll test this during the next week.. You'll hear from me then..

#15 User is offline   esas 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 07-February 05

Posted 09 March 2005 - 06:34 PM

Hey Felix!

I've been testing UPC for some days now, and I have a few things to report..

1. When a duplicated userfolder is detected and deleted the originally folder doesn't appear in "My Computer"

Posted Image


2. The Popup only says "Duplicated profile dected", with the buttons "Yes"and "No". This isn't even a question. I really liked your previously version with the help button, and the possibility to write my own popup. (I would also like to translate this to my norwegian XP by time)

3. The popup is being displayed no mather what. Even if there isn't a duplicated account. It also creates the logfile, even though it doesn't delete anything.

4. I can't get the RESTART option to work. I have to restart manually. Is it necessary to restart? Is is not enough to logof the user like in the first version? Just asking.

5. A SILENT option would be great. That way I won't have to answar yes during RunOnceEX. This wasn't a issue in the first version as I could edit the cmd-file myself. Can't do that now.

That's all.....

I also want to thank you for the work you have done so far. You are great!!

#16 User is offline   `Felix` 

  • MSFN Contributor
  • PipPipPip
  • Group: Members
  • Posts: 481
  • Joined: 28-July 04

Posted 10 March 2005 - 02:43 AM

esas, on Mar 10 2005, 08:34 AM, said:

Hey Felix!

I've been testing UPC for some days now, and I have a few things to report..

1. When a duplicated userfolder is detected and deleted the originally folder doesn't appear in "My Computer"

Posted Image


Ok so in the log is it reporting that it is deleting your original account too? need more information here... i need to try and duplicate the problem so i can fix it :)

Quote

2. The Popup only says "Duplicated profile dected", with the buttons "Yes"and "No". This isn't even a question. I really liked your previously version with the help button, and the possibility to write my own popup. (I would also like to translate this to my norwegian XP by time)

3. The popup is being displayed no mather what. Even if there isn't a duplicated account. It also creates the logfile, even though it doesn't delete anything.

4. I can't get the RESTART option to work. I have to restart manually. Is it necessary to restart? Is is not enough to logof the user like in the first version? Just asking.
Yes you do for all the profiles to be fully released from system control.

Quote

5. A SILENT option would be great. That way I won't have to answar yes during RunOnceEX. This wasn't a issue in the first version as I could edit the cmd-file myself. Can't do that now.

That's all.....

I also want to thank you for the work you have done so far. You are great!!
<{POST_SNAPBACK}>


Ok well the easiest thing i can do is just give you the source. here it is below :) With this you can remove the popup (for silent) or change it to include help and add anything else you like. Please let me know about clear changes you have made so i can keep updating my source. Let me know about the first issue you raise so i can address that asap. I have not been able to reproduce that issue here and did orginally test for that situation.

@ECHO OFF
:: Fix and Delete Duplicate Profiles 1.1.17
:: Copyright 2005, `felix`
:: Last updated: March 3, 2005

IF %OS%!==! GOTO:EOF
setlocal
If /I "%1"=="RESTART" SET RS=YES
set theNum=0
set KEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
set gtid=getsid \\%computername% %username% \\%computername% %username%
for /f "Tokens=7" %%i in ('%gtid%^') do (set UserSID=%%i)
set qry1=reg query "%KEY%" /v ProfilesDirectory
set qry2=reg query "%KEY%" /s
set qry3=reg query "%KEY%\%USERSID%" /v ProfileImagePath
set fnd1=FIND /I "Documents and Settings" 
set fnd2=FIND /I "ProfileImagePath"
set fnd3=FIND /I "AllUsersProfile"
set fnd4=FIND /I "DefaultUserProfile"
set fnd5=FIND /I "LocalService"
set fnd6=FIND /I "NetworkService"
set fnd7=FIND /I "%UserName%"
for /f "Tokens=1,2*" %%i in ('%qry1%^|%fnd1%') do (set DocSetDir0=%%k)

CALL:CheckCurrentLocal
CALL:CheckIfDuplicate
if %RS%==YES call:restartIt
GOTO:EOF

:CheckCurrentLocal
:: Check the registry to and make sure the profiles are correct based
:: a totally clean default installation.  If duplicate profiles are
:: found based on reinstall or lost of user account information, we
:: correct the paths to the correct directories here.
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd3%') do if /i not "%%k"=="All Users" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v AllUsersProfile /d "All Users" /f >NUL )
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd4%') do if /i not "%%k"=="Default User" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v DefaultUserProfile /d "Default User" /f >NUL )
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd5%') do if /i not "%%k"=="LocalService" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-19" /v ProfileImagePath /d "%DocSetDir0%\LocalService" /f >NUL )
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd6%') do if /i not "%%k"=="NetworkService" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20" /v ProfileImagePath /d "%DocSetDir0%\NetworkService" /f >NUL )
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd7%') do if /i not "%%k"=="%UserName%" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%UserSID%" /v ProfileImagePath /d "%DocSetDir0%\%UserName%" /f >NUL )
GOTO:EOF

:CheckIfDuplicate
::Let the user know something is happening...
popup /YN /HF "userprofilechecker.hlp" /IS /M "Duplicate User Profile Detected" /T "User Profile Checker 1.1.16"
if errorlevel 7 EXIT
:: Now we actually check againist the registry for duplicates
:: Normally they will be username.computername, all users.windows,
:: default user.windows, localservice.nt authority and networkservice.nt authority.
:: the last 3 are hidden.
CALL:Header
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd3%') do if /i "%%k"=="All Users" (CALL:DoIt "All Users" "%DocSetDir0%")
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd4%') do if /i "%%k"=="Default User" (CALL:DoIt "Default User" "%DocSetDir0%")
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd5%') do if /i "%%k"=="LocalService" (CALL:DoIt "LocalService" "%DocSetDir0%")
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd6%') do if /i "%%k"=="NetworkService" (CALL:DoIt "NetworkService" "%DocSetDir0%")
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry3%^|%fnd7%') do if /i "%%k"=="%UserName%" (CALL:DoIt "%UserName%" "%DocSetDir0%")
CALL:Footer
GOTO:EOF

:Header
:: We output the list of directories to the log so we have a record
:: of the directories deleted and to check the script loaded.
> c:\AllUsersProfilefix.log echo Fix and Remove Duplicate Profiles 1.1.17
>> c:\AllUsersProfilefix.log echo Copyright 2005, `felix`
>> c:\AllUsersProfilefix.log echo www.simplify-i-t.com
>> c:\AllUsersProfilefix.log echo Automatically Generated %DATE:~-10%.
>> c:\AllUsersProfilefix.log echo --------------------------------------------------------------------------------
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo This computer was found to have one or more duplicate system or user profiles.
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo The following registry key has been updated with restored values.
>> c:\AllUsersProfilefix.log echo  "%KEY%"
>> c:\AllUsersProfilefix.log echo.
GOTO:EOF

:Footer
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo --------------------------------------------------------------------------------
>> c:\AllUsersProfilefix.log echo This issue is possibly caused by the following reasons:
>> c:\AllUsersProfilefix.log echo * The computer operating system has been reinstalled.
>> c:\AllUsersProfilefix.log echo * The computer operating system has been restore from a back-up image.
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo For more information please see Microsoft Knowledge Base Article link below:
>> c:\AllUsersProfilefix.log echo http://support.microsoft.com/default.aspx?...kb;en-us;314045
>> c:\AllUsersProfilefix.log echo.
GOTO:EOF

:Doit
:: We check to make sure it is not a valid user directory and 
:: unhide all the directories that are hidden first so we can
:: build the list to remove them.
for /f "usebackq delims= tokens=1,2" %%i IN (`dir /a /b "%~2\%~1*"`) DO IF /i "%%i" NEQ "%~1" attrib -a -s -h "%~2\%%i"
for /f "usebackq delims= tokens=1,2" %%i IN (`dir /ad /b "%~2\%~1*"`) DO IF /i "%%i" NEQ "%~1" call:flagIt %~2\%%i
GOTO:EOF

:flagIt
:: The list of duplicate/unrequired directories is built
:: and added to the Local Machine RunOnce key to be removed
:: at next boot.
:: The directories can not be removed before a reboot because the
:: system still has them loaded even know we have changed the paths
:: in the registry.
set /a theNum=%theNum%+1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v RemoveDuplicateProfile%theNum% /d "%comspec% /C RMDIR /S /Q """%*"""" /f >NUL
>> c:\AllUsersProfilefix.log echo  %theNum%. %* has been deleted!
GOTO:EOF

:restartIt
shutdown -r -f -t 90 -c "%computername%" needs to restart to finish the update to the user profiles."
GOTO:EOF
endlocal


#17 User is offline   esas 

  • Newbie
  • Group: Members
  • Posts: 20
  • Joined: 07-February 05

Posted 10 March 2005 - 08:47 AM

Hi!

I've been looking at the source and made some changes.

Quote

@ECHO OFF
:: Fix and Delete Duplicate Profiles 1.1.17
:: Copyright 2005, `felix`
:: SILENT option added by esas
:: Last updated: March 10, 2005


IF %OS%!==! GOTO:EOF
setlocal

::Check for options (RESTART or SILENT)
If /I "%1"=="RESTART" SET RS=YES
If /I NOT "%1"=="RESTART" SET RS=NO
if %RS%==NO goto CheckmoreRS
if %RS%==YES goto SkipCheckmoreRS

:CheckmoreRS
If /I "%2"=="RESTART" SET RS=YES
If /I NOT "%2"=="RESTART" SET RS=NO

:SkipCheckmoreRS
If /I "%1"=="SILENT" SET SL=YES
If /I NOT "%1"=="SILENT" SET SL=NO
if %SL%==NO goto CheckmoreSL
if %SL%==YES goto SkipCheckmoreSL

:CheckmoreSL
If /I "%2"=="SILENT" SET SL=YES
If /I NOT "%2"=="SILENT" SET SL=NO

:SkipCheckmoreSL

set theNum=0
set KEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
set gtid=getsid \\%computername% %username% \\%computername% %username%
for /f "Tokens=7" %%i in ('%gtid%^') do (set UserSID=%%i)
set qry1=reg query "%KEY%" /v ProfilesDirectory
set qry2=reg query "%KEY%" /s
set qry3=reg query "%KEY%\%USERSID%" /v ProfileImagePath
set fnd1=FIND /I "Documents and Settings"
set fnd2=FIND /I "ProfileImagePath"
set fnd3=FIND /I "AllUsersProfile"
set fnd4=FIND /I "DefaultUserProfile"
set fnd5=FIND /I "LocalService"
set fnd6=FIND /I "NetworkService"
set fnd7=FIND /I "%UserName%"
for /f "Tokens=1,2*" %%i in ('%qry1%^|%fnd1%') do (set DocSetDir0=%%k)

CALL:CheckCurrentLocal
CALL:CheckIfDuplicate
if %RS%==YES call:restartIt
GOTO:EOF

:CheckCurrentLocal
:: Check the registry to and make sure the profiles are correct based
:: a totally clean default installation.  If duplicate profiles are
:: found based on reinstall or lost of user account information, we
:: correct the paths to the correct directories here.
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd3%') do if /i not "%%k"=="All Users" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v AllUsersProfile /d "All Users" /f >NUL )
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd4%') do if /i not "%%k"=="Default User" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /v DefaultUserProfile /d "Default User" /f >NUL )
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd5%') do if /i not "%%k"=="LocalService" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-19" /v ProfileImagePath /d "%DocSetDir0%\LocalService" /f >NUL )
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd6%') do if /i not "%%k"=="NetworkService" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20" /v ProfileImagePath /d "%DocSetDir0%\NetworkService" /f >NUL )
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd7%') do if /i not "%%k"=="%UserName%" (
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%UserSID%" /v ProfileImagePath /d "%DocSetDir0%\%UserName%" /f >NUL )
GOTO:EOF

:CheckIfDuplicate
::Let the user know something is happening unless SILENT option in used...
if %SL%==YES goto Skippopup
popup /YN /HF "userprofilechecker.hlp" /IS /M "Duplicate User Profile Detected" /T "User Profile Checker 1.1.16"
if errorlevel 7 EXIT
:Skippopup
:: Now we actually check againist the registry for duplicates
:: Normally they will be username.computername, all users.windows,
:: default user.windows, localservice.nt authority and networkservice.nt authority.
:: the last 3 are hidden.
CALL:Header
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd3%') do if /i "%%k"=="All Users" (CALL:DoIt "All Users" "%DocSetDir0%")
FOR /f "Tokens=1,2*" %%i in ('%qry2%^|%fnd4%') do if /i "%%k"=="Default User" (CALL:DoIt "Default User" "%DocSetDir0%")
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd5%') do if /i "%%k"=="LocalService" (CALL:DoIt "LocalService" "%DocSetDir0%")
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry2%^|%fnd6%') do if /i "%%k"=="NetworkService" (CALL:DoIt "NetworkService" "%DocSetDir0%")
FOR /f "delims=\ Tokens=1,2*" %%i in ('%qry3%^|%fnd7%') do if /i "%%k"=="%UserName%" (CALL:DoIt "%UserName%" "%DocSetDir0%")
CALL:Footer
GOTO:EOF

:Header
:: We output the list of directories to the log so we have a record
:: of the directories deleted and to check the script loaded.
> c:\AllUsersProfilefix.log echo Fix and Remove Duplicate Profiles 1.1.17
>> c:\AllUsersProfilefix.log echo Copyright 2005, `felix`
>> c:\AllUsersProfilefix.log echo www.simplify-i-t.com
>> c:\AllUsersProfilefix.log echo Automatically Generated %DATE:~-10%.
>> c:\AllUsersProfilefix.log echo --------------------------------------------------------------------------------
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo This computer was found to have one or more duplicate system or user profiles.
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo The following registry key has been updated with restored values.
>> c:\AllUsersProfilefix.log echo  "%KEY%"
>> c:\AllUsersProfilefix.log echo.
GOTO:EOF

:Footer
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo --------------------------------------------------------------------------------
>> c:\AllUsersProfilefix.log echo This issue is possibly caused by the following reasons:
>> c:\AllUsersProfilefix.log echo * The computer operating system has been reinstalled.
>> c:\AllUsersProfilefix.log echo * The computer operating system has been restore from a back-up image.
>> c:\AllUsersProfilefix.log echo.
>> c:\AllUsersProfilefix.log echo For more information please see Microsoft Knowledge Base Article link below:
>> c:\AllUsersProfilefix.log echo http://support.micro...kb;en-us;314045
>> c:\AllUsersProfilefix.log echo.
GOTO:EOF

:Doit
:: We check to make sure it is not a valid user directory and
:: unhide all the directories that are hidden first so we can
:: build the list to remove them.
for /f "usebackq delims= tokens=1,2" %%i IN (`dir /a /b "%~2\%~1*"`) DO IF /i "%%i" NEQ "%~1" attrib -a -s -h "%~2\%%i"
for /f "usebackq delims= tokens=1,2" %%i IN (`dir /ad /b "%~2\%~1*"`) DO IF /i "%%i" NEQ "%~1" call:flagIt %~2\%%i
GOTO:EOF

:flagIt
:: The list of duplicate/unrequired directories is built
:: and added to the Local Machine RunOnce key to be removed
:: at next boot.
:: The directories can not be removed before a reboot because the
:: system still has them loaded even know we have changed the paths
:: in the registry.
set /a theNum=%theNum%+1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v RemoveDuplicateProfile%theNum% /d "%comspec% /C RMDIR /S /Q """%*"""" /f >NUL
>> c:\AllUsersProfilefix.log echo  %theNum%. %* has been deleted!
GOTO:EOF

:restartIt
shutdown -r -f -t 90 -c "%computername% needs to restart to finish the update to the user profiles."
GOTO:EOF
endlocal


As you can see I've added a SILENT option. It can be used with or without the RESTART option, and it doesn't mather in whitch order you put the options.

The reson the RESTART option didn't work before was a error in the shutdown line.
I removed the " after the %computername% and it worked.

You might want to put the UserprofileChecker.hlp in the UPC.rar. I wasn't using it untill I saw I had to in the source. Figured it build in with the UPC.exe or something.


It still creates the logfile and launches the popup (If the SILENT option isn't used) even though there isn't duplicated user account. A little irritating.

Quote

Ok so in the log is it reporting that it is deleting your original account too? need more information here... i need to try and duplicate the problem so i can fix it

No the log only report that it has deleted the new account. Except for this the original account seems find.

#18 User is offline   Bebbetufs 

  • Newbie
  • Group: Members
  • Posts: 36
  • Joined: 12-September 04

Posted 10 April 2005 - 03:25 PM

Is there an updated package available for download somewhere?

#19 User is offline   Acheron 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 915
  • Joined: 28-June 04

Posted 27 September 2005 - 01:11 PM

This method is new to me but it sounds cool.

I would like to see an option to do all this stuff before a user actually logons.

AFAIK all changes upto T13 are copied to the Default User Account. However this account is created directly after the commands from cmdlines.txt have passed (T12) :)

More interesting is that this account is not in use during install but the generic System Account is used.

The Administrator account is created at first logon after the reboot.

Is it possible to run this script at T9 [SetupParams] to move the newly created Default User.001 Account to Default User, overwriting existing files and change the appropiate registry entries, since it's not yet in use.

This would be cool in use when you have specific software settings not stored in the registry, custom shortcuts etc, documents folder, history, favorites etc. from a previous installation. All you would have to do is a unique username for each system.

If anyone has experience with this please reply :yes:

#20 User is offline   Acheron 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 915
  • Joined: 28-June 04

Posted 02 October 2005 - 11:50 AM

I have worked this out. For me it's not necessary to keep the existing user profiles. So I use this:

WinNT.sif
[SetupParams]
    UserExecute="cmd.exe /C adminchange.cmd"


cmdlines.txt
[COMMANDS]
"runonceex.cmd"
"rundll32.exe iernonce.dll,RunOnceExProcess"


RunOnceEx.cmd
@echo off
FOR %%a IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO ((( set drv=%%a:) & (call :setupdocs))
)
goto :ending

:setupdocs
FOR /F "tokens=7 delims=:= " %%a IN ( 'vol %drv%' ) DO (
IF /I %%a==Documenten (
set docsdrive=%drv%
)
IF /I %%a==nLite (
set CDDRIVE=%drv%
goto :endloop
)
)
:endloop
GOTO :EOF
:ending
IF not defined docsdrive set docsdrive=%systemdrive%
IF NOT Defined CDDRIVE set CDDRIVE=%CD%^\^.^.
cacls "%docsdrive%\Profieldata\" /E /T /P Administrators:F
rmdir /S /Q "%docsdrive%\Profieldata"
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Profilelist" /v "ProfilesDirectory" /t REG_EXPAND_SZ /d "%docsdrive%\Profieldata" /f


AdminChange.cmd
@echo off
FOR %%a IN (C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO ((( set drv=%%a:) & (call :setupdocs))
)
goto :ending

:setupdocs
FOR /F "tokens=7 delims=:= " %%a IN ( 'vol %drv%' ) DO (
IF /I %%a==Documenten (
set docsdrive=%drv%
)
IF /I %%a==nLite (
set CDDRIVE=%drv%
goto :endloop
)
)
:endloop
GOTO :EOF
:ending
IF not defined docsdrive set docsdrive=%systemdrive%
IF NOT Defined CDDRIVE set CDDRIVE=%CD%^\^.^.
::get systemsid
for /f "skip=1" %%a in ('psgetsid') do set sid=%%a
::set adminsid
set adminsid=%sid%-500
for /f "tokens=2* delims=\" %%a in ('reg query "hklm\software\microsoft\windows nt\currentversion\profilelist\%adminsid%" /v "ProfileImagePath"') do set pid=%%b
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Profilelist" /v "ProfilesDirectory" /t REG_EXPAND_SZ /d "%docsdrive%\Profieldata" /f
reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Profilelist\%adminsid%" /v "ProfileImagePath" /t REG_EXPAND_SZ /d "%docsdrive%\Profieldata\Administrator" /f
XCOPY /C /H /E /O /I /Y "%systemdrive%\Documents and Settings" "%docsdrive%\Profieldata"
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" /v "CleanProfile" /d "cmd.exe /C \"RMDIR /S /Q \"%systemdrive%\Documents and Settings\"\"" /f
EXIT


You need psgetsid btw.

This post has been edited by hp38guser: 02 October 2005 - 11:51 AM


Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy