Sign in to follow this  
Followers 0
tharris

User Migration Script Help

3 posts in this topic

#1 ·  Posted (edited)

My company is in the process of collapsing an old domain and rolling everything under one domain. During this process user ID's are changing. I am writing a script to move the data from the users old account to their new account. One issue that we have ran in to is that some computers do not have enough space to copy the data. I know I could just move the directories instead of copying but management does not like that idea because they can't go back later if a user states they are missing something. I am attempting to have the script calculate the size of the 3 folders that will be copied and if it is greater than the available disc space give me a message box stating there is not enough room to copy the data. If there is enough space it will then copy the data. For some reason when you run the script everyone gets the pop up box no matter if they have enough space or not. Any help would be greatly appreciated. This is only my 4th or 5th script to write and by far the most complex.

CODE
Do

$OldPro = InputBox("Old Profile", "Please enter the old profile name", "", " M")

$NewPro = InputBox("New Profile", "Please enter the new profile name", "", " M")

$GoNoGo = MsgBox(36,"Is it right?","Verify :" & @CRLF & "Old profile name is "&$OldPro & @CRLF & "New Profile name is "&$NewPro & @CRLF & "Press Yes to continue, or No to reenter")

Until $GoNoGo = 6

;;Verifying there is enough space to copy the data

$AvailDriveSpace = DriveSpaceFree( "c:\" )

$MyDocsSize = DirGetSize("c:\documents and settings\"&$OldPro&"\My Documents")

$DesktopSize = DirGetSize("c:\documents and settings\"&$OldPro&"\Desktop")

$FavoritesSize = DirGetSize("c:\documents and settings\"&$OldPro&"\Favorites")

$TotalFileSize = $MyDocsSize + $DesktopSize + $FavoritesSize

If $TotalFileSize > $AvailDriveSpace Then

MsgBox (0, "Disc Full", "There is not enough space to copy the data.")

Exit

Else

;;Copying data from old profile to new profile

DirCopy("c:\documents and settings\"&$OldPro&"\desktop", "C:\documents and settings\"&$NewPro&"\desktop", 1)

DirCopy("c:\documents and settings\"&$OldPro&"\favorites", "C:\documents and settings\"&$NewPro&"\favorites", 1)

DirCopy("c:\documents and settings\"&$OldPro&"\My Documents", "C:\documents and settings\"&$NewPro&"\My Documents", 1)

FileCopy("c:\documents and settings\"&$OldPro&"\Local Settings\Application Data\Microsoft\Outlook\*.pst", "C:\documents and settings\"&$NewPro&"\Local Settings\Application Data\Microsoft\Outlook", 1)

;;Remapping network drives

Run("regedit.exe /s c:\migration\drives.reg")

;;Readding Network Printers

Run("regedit.exe /s c:\migration\printers.reg")

EndIf

MsgBox (0, "Migration Complete", "Migration to West Domain complete. Please click OK to finish and restart your computer", 30)

Exit

Edited by tharris

Share this post


Link to post
Share on other sites



My company is in the process of collapsing an old domain and rolling everything under one domain. During this process user ID's are changing. I am writing a script to move the data from the users old account to their new account. One issue that we have ran in to is that some computers do not have enough space to copy the data. I know I could just move the directories instead of copying but management does not like that idea because they can't go back later if a user states they are missing something. I am attempting to have the script calculate the size of the 3 folders that will be copied and if it is greater than the available disc space give me a message box stating there is not enough room to copy the data. If there is enough space it will then copy the data. For some reason when you run the script everyone gets the pop up box no matter if they have enough space or not. Any help would be greatly appreciated. This is only my 4th or 5th script to write and by far the most complex.

CODE
Do

$OldPro = InputBox("Old Profile", "Please enter the old profile name", "", " M")

$NewPro = InputBox("New Profile", "Please enter the new profile name", "", " M")

$GoNoGo = MsgBox(36,"Is it right?","Verify :" & @CRLF & "Old profile name is "&$OldPro & @CRLF & "New Profile name is "&$NewPro & @CRLF & "Press Yes to continue, or No to reenter")

Until $GoNoGo = 6

;;Verifying there is enough space to copy the data

$AvailDriveSpace = DriveSpaceFree( "c:\" )

$MyDocsSize = DirGetSize("c:\documents and settings\"&$OldPro&"\My Documents")

$DesktopSize = DirGetSize("c:\documents and settings\"&$OldPro&"\Desktop")

$FavoritesSize = DirGetSize("c:\documents and settings\"&$OldPro&"\Favorites")

$TotalFileSize = $MyDocsSize + $DesktopSize + $FavoritesSize

If $TotalFileSize > $AvailDriveSpace Then

MsgBox (0, "Disc Full", "There is not enough space to copy the data.")

Exit

Else

;;Copying data from old profile to new profile

DirCopy("c:\documents and settings\"&$OldPro&"\desktop", "C:\documents and settings\"&$NewPro&"\desktop", 1)

DirCopy("c:\documents and settings\"&$OldPro&"\favorites", "C:\documents and settings\"&$NewPro&"\favorites", 1)

DirCopy("c:\documents and settings\"&$OldPro&"\My Documents", "C:\documents and settings\"&$NewPro&"\My Documents", 1)

FileCopy("c:\documents and settings\"&$OldPro&"\Local Settings\Application Data\Microsoft\Outlook\*.pst", "C:\documents and settings\"&$NewPro&"\Local Settings\Application Data\Microsoft\Outlook", 1)

;;Remapping network drives

Run("regedit.exe /s c:\migration\drives.reg")

;;Readding Network Printers

Run("regedit.exe /s c:\migration\printers.reg")

EndIf

MsgBox (0, "Migration Complete", "Migration to West Domain complete. Please click OK to finish and restart your computer", 30)

Exit

It's because the return values for DriveSpaceFree() returns the total in megabytes (as a float) and DirGetSize() returns the total in bytes. Just modify the "$TotalFileSize" declaration to:

$TotalFileSize = ($MyDocsSize + $DesktopSize + $FavoritesSize)/(1024*1024)

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0