Macrium Support Forum

This forum is for Version 5 of Macrium Reflect.
Version 6 users should join our new forum here.

Version 5 support expired on 17 February 2016.

Find out more
Macrium Support Forum
Macrium Support Forum    RSS 2.0  RSS Feed      KB
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
 All Forums
 Reflect v4
 Disk Imaging
 Disk changes from C to D to C
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

jepolch
New Member

15 Posts

Posted - November 23 2009 :  15:02:03  Show Profile
This just started happening since I upgraded to Windows 7. A little background. I'm using version 4.2.2082. I have two physical disks in my Dell Inspiron 1720. I have Reflect configured to create a mirror image of C and save it on D every day. Since I installed Windows 7 I began to notice that sometimes the image found on D was of disk D, not C. At first I thought I must have created the XML file wrong using the wizard. So I created it again and next time the backup would be OK. Then after that it would back up D again! Anyway, to get to the point, the assignment of drive letter to physical disk seems to be random each time I boot up! One day, disk 1 will be C, the next D. Is this an issue with Reflect, or a bug in Windows 7? I'm beginning to realize that Windows 7 does have some bugs in it, from reading other forums, so it wouldn't surprise me. I'm just wondering if there's anything I can do to make sure that my backup is correct each day. Here's a shot of the partition selection screen showing disk 1 assigned to drive D. Today it's C. Any ideas? Thanks!



Joe

Edited by - jepolch on November 23 2009 15:03:49

jepolch
New Member

15 Posts

Posted - November 23 2009 :  15:06:49  Show Profile
I just wanted to add that in Windows Explorer C and D do not change from day to day, as in Reflect. When I navigate to C it's always C and D is always D.

Joe
Go to Top of Page

jepolch
New Member

15 Posts

Posted - November 23 2009 :  15:36:08  Show Profile
Just for comparison, here's what the partition selection looks like today. Disk 1 is assigned C.



Thanks!

Joe
Go to Top of Page

infimum
Starting Member

8 Posts

Posted - November 23 2009 :  16:21:08  Show Profile
Never mind.

Edited by - infimum on November 23 2009 16:39:13
Go to Top of Page

Nick
Moderator

United Kingdom
6303 Posts

Posted - November 23 2009 :  16:33:28  Show Profile
Hi Joe

Macrium Reflect is mapping the disks the same as Windows. If you open the Windows Disk Management Console you will see that this is also inconsistent. This issue seems to occur only with some motherboards/disk controllers and isn't a problem for all Vista/Windows 7 installations.


http://support.macrium.com/topic.asp?TOPIC_ID=830

The problem is that Reflect uses the disk and partition numbers to reference the partition to backup. If the disk number is inconsistent then this causes the wrong partition to be backed up.

We are modifying the XML file to optionally use the unique Disk ID instead of the disk number. This should get round this inconsistency in Windows. In the meantime you can use the following VBScript to detect whether disk 1 is the 'C' drive or not and run the appropriate XML file.

Create 2 XML backup files, one for drive 'C' and one for drive 'D'. If you look at the XML text you should see that one references 'Disk 1' and 'Partition 1' and the other references 'Disk 2' and 'Partition 1'. We'll call them 'Disk1.xml' and 'Disk2.xml'.

1. Right click on 'Disk1.xml' and select 'Generate a VBScript file'.
2. Right click on 'Disk1.vbs' and select 'Edit'. This will open the source file in notepad.
3. Change the line:
ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""<PATH>Disk1.xml""")
To:
If GetFirstPartition = "C:" Then 
    ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""<PATH>Disk1.xml""")
Else
    ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""<PATH>Disk2.xml""")
End If 
At the end of the source file copy and paste the following:
Function GetFirstPartition

    DIM ComputerName, wmiServices, wmiDiskDrives, wmiDiskDrive 
    DIM Query, wmiDiskPartitions, wmiDiskPartition
    DIM wmiLogicalDisks, wmiLogicalDisk

    ComputerName = "."
    Set wmiServices  = GetObject ( _
    "winmgmts:{impersonationLevel=Impersonate}!//" _
    & ComputerName)
    ' Get physical disk drive
    Set wmiDiskDrives =  wmiServices.ExecQuery ( _
    "SELECT Caption, DeviceID FROM Win32_DiskDrive Where Index = 0")

    For Each wmiDiskDrive In wmiDiskDrives
        'Use the disk drive device id to
        ' find associated partition
        query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" _
        & wmiDiskDrive.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition"    
        Set wmiDiskPartitions = wmiServices.ExecQuery(query)
        For Each wmiDiskPartition In wmiDiskPartitions
            'Use partition device id to find logical disk
            Set wmiLogicalDisks = wmiServices.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" _
             & wmiDiskPartition.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition") 

            For Each wmiLogicalDisk In wmiLogicalDisks
                GetFirstPartition = wmiLogicalDisk.DeviceID
                Exit Function
            Next      
        Next
    Next
End Function 
Please test this code before implementing.

Hope this helps

Nick - Macrium Support


Edited by - Nick on November 23 2009 16:38:05
Go to Top of Page

jepolch
New Member

15 Posts

Posted - November 24 2009 :  01:42:12  Show Profile
Thanks, Nick! Sorry I didn't see that other topic. I did look around the forums before asking for help. You guys really do think of everything, don't you! I'm impressed.

Joe
Go to Top of Page

jepolch
New Member

15 Posts

Posted - November 24 2009 :  02:32:21  Show Profile
Nick,

I created the XML backup file for drive C (which today happens to be disk 1, partition 1) and then created the VBScript file per your instructions. When I tried to create the backup file for drive D I got this error message:

"Cannot write to 'D:\'. This destination is included in the backup!"

Am I supposed to create two identical XML files, one called "Disk1.xml" and one called Disk2.xml", each pointed to disk 1, partition 1, to cover the eventuality that sometimes this partition is C and sometimes it's D?

Thanks.

Joe


Edited by - jepolch on November 24 2009 02:47:23
Go to Top of Page

Nick
Moderator

United Kingdom
6303 Posts

Posted - November 24 2009 :  09:59:15  Show Profile
Hi Joe

If 'D' is the destination for the image then you can copy 'Disk1.xml' to 'Disk2.xml' and edit it in Notepad. Please make sure that 'Disk1.xml' has the following lines in the file:
	<image_entry id="1">
		<!-- disk is the 1 based index of the disk to be imaged -->
		<disk>1</disk>
		<!-- partition is the 1 based index of the partition on the disk -->
		<partition>1</partition>
	</image_entry>
And 'Disk2.xml' has the following:
	<image_entry id="1">
		<!-- disk is the 1 based index of the disk to be imaged -->
		<disk>2</disk>
		<!-- partition is the 1 based index of the partition on the disk -->
		<partition>1</partition>
	</image_entry>
You can edit the files in Notepad if necessary. Both files should have the same destination for the image, which can be any drive that isn't 'C:'
	<destination>
		<!-- Fully qualified path to destination directory  -->
		<directory>D:\</directory>
Please make sure you run the VBScript source not the XML. Right click on the VBScript source and select 'Execute. You can schedule VBScript in the same way as your XML files. If you are still having a problem then to check the function 'GetFirstPartition' is working correctly, temporarily change your VBScript source by adding the following lines after 'OPTION EXPLICIT':
WSCript.Echo "Disk 1 is:" & GetFirstPartition 
WSCript.Quit
This will display a message box with the drive letter for the first partition on disk 1. Check that this corresponds to the layout in the Reflect main Window.

Kind Regards

Nick - Macrium Support


Edited by - Nick on November 24 2009 10:08:38
Go to Top of Page

jepolch
New Member

15 Posts

Posted - November 25 2009 :  20:19:17  Show Profile
Hi Nick,

I'm sorry, but I don't know where to add the lines you want me to include. Here's what my VBScript looks like for disk 1. Thanks!

Joe

'******************************************************************************
'*
'*
'* Module Name: Disk 1.vbs
'*
'* Abstract: This is a template VB Script file generated by Reflect v4.2
'* Modify to add your own functionality if required
'*
'*
'******************************************************************************

OPTION EXPLICIT

' call the main function
Call VBMain()


'******************************************************************************
'* Sub: VBMain
'*
'* Purpose: This is main function to start execution
'*
'* Input: None
'*
'* Output: None
'*
'******************************************************************************
Sub VBMain()
Dim objShell
Dim ExitCode

' Elevate this script for Admin privileges in Vista
Elevate

Set objShell = WScript.CreateObject("WScript.Shell")

' Do the backup

If GetFirstPartition = "C:" Then
ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""<PATH>Disk1.xml""")
Else
ExitCode = Backup ("""C:\Program Files\Macrium\Reflect\reflect.exe"" -e -w ""<PATH>Disk2.xml""")
End If

' done
Set objShell = nothing
wscript.quit(ExitCode)
End Sub

'******************************************************************************
'* Function: Backup
'*
'* Purpose: Calls Reflect.exe passing an XML BDF as a parameter
'* Optionaly logs output to file
'*
'* Input: strCmdLine Command Line Arguments
'* Output: Exit Code
'*
'******************************************************************************
Function Backup(Byref strCmdLine)
Dim objShell
Dim objExecObject
Dim strLine
Dim objFS
Dim objNewFile
Dim strLogFileName


' Run the backup or image
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec(strCmdLine)

' Log to file
strLogFileName = "C:\Users\joe\Documents\Reflect\log-" & Year(Date) & "-" & Month(Date) & "-" & Day(Date) & " " & Hour(Time) & "." & Minute(Time) & "." & Second(Time) & ".txt"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objNewFile = objFS.OpenTextFile(strLogFileName , 8, 1)
Do Until objExecObject.StdOut.AtEndOfStream
strLine = objExecObject.StdOut.ReadLine()
If Instr(strLine , "%") = 0 Then
objNewFile.WriteLine strLine
end if
Loop

objNewFile.Close
set objFS = nothing

' Wait for the process to finish
Do While objExecObject.Status = 0
WScript.Sleep 100
Loop

if objExecObject.exitcode = 2 then
' Handle XML validation error

elseif objExecObject.exitcode = 1 then
' Handle backup error
elseif objExecObject.exitcode = 0 then
' Everything OK
end if
Backup = objExecObject.exitcode
Set objExecObject = nothing
Set objShell = nothing
End Function

'******************************************************************************
'* Sub: Elevate
'*
'* Purpose: Elevates this script for Vista UAC.
'* This means that only one UAC Elevation prompt is displayed and
'* functions/programs will not fail if they require admin privileges
'*
'* Input: None
'* Output: None
'*
'******************************************************************************
Sub Elevate
Dim ShellApp
Dim objShell
Dim objWshProcessEnv

Set objShell = WScript.CreateObject("WScript.Shell")
Set objWshProcessEnv = objShell.Environment("PROCESS")

If objWshProcessEnv("ELEVATED_APP") <> "True" Then
objWshProcessEnv("ELEVATED_APP") = "True"
Set ShellApp = CreateObject("Shell.Application")
Call ShellApp.ShellExecute("""" & WScript.FullName & """", """" & WScript.ScriptFullName & """" , , "runas")
set ShellApp = nothing
Set objWshProcessEnv = nothing
wscript.quit
End If
Set objWshProcessEnv = nothing
Set objShell = nothing
End Sub

Function GetFirstPartition

DIM ComputerName, wmiServices, wmiDiskDrives, wmiDiskDrive
DIM Query, wmiDiskPartitions, wmiDiskPartition
DIM wmiLogicalDisks, wmiLogicalDisk

ComputerName = "."
Set wmiServices = GetObject ( _
"winmgmts:{impersonationLevel=Impersonate}!//" _
& ComputerName)
' Get physical disk drive
Set wmiDiskDrives = wmiServices.ExecQuery ( _
"SELECT Caption, DeviceID FROM Win32_DiskDrive Where Index = 0")

For Each wmiDiskDrive In wmiDiskDrives
'Use the disk drive device id to
' find associated partition
query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" _
& wmiDiskDrive.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition"
Set wmiDiskPartitions = wmiServices.ExecQuery(query)
For Each wmiDiskPartition In wmiDiskPartitions
'Use partition device id to find logical disk
Set wmiLogicalDisks = wmiServices.ExecQuery _
("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" _
& wmiDiskPartition.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition")

For Each wmiLogicalDisk In wmiLogicalDisks
GetFirstPartition = wmiLogicalDisk.DeviceID
Exit Function
Next
Next
Next
End Function
Go to Top of Page

Nick
Moderator

United Kingdom
6303 Posts

Posted - November 25 2009 :  20:26:00  Show Profile
Hi Joe

You don't need to change the VBScript, it's correct.

EDIT: You need to change "<PATH>Disk1.xml" to be the correct path name for your xml file!

The previous post was referencing to the XML files not the VBScript. You can edit the XML files in notepad.

If you want to test the function 'GetFirstPartition' then temporarily add the lines:
WSCript.Echo "Disk 1 is:" & GetFirstPartition 
WSCript.Quit
In the VBScript source, after:
OPTION EXPLICIT
This will display a message box with the drive letter for the first partition on disk 1. Check that this corresponds to the layout in the Reflect main Window.

Kind Regards

Nick - Macrium Support


Edited by - Nick on November 25 2009 21:20:11
Go to Top of Page

jepolch
New Member

15 Posts

Posted - November 30 2009 :  15:17:45  Show Profile
Nick, just wanted to let you know that it's working great for me now. Whether disk 1 is C or D, Reflect always backs up C. Thanks for your help and patience.

Joe

Edited by - jepolch on November 30 2009 15:18:19
Go to Top of Page

SOS_DK
Starting Member

7 Posts

Posted - January 19 2010 :  13:22:39  Show Profile
Any news on updating the XML to using unique names for disks?

I have the same issue, that some of my XML files dump to eSata disks which when added to the system comes in "before" the primary disk, ergo replacing the Disk IDs.

I would prefer it if I could avoid using VBscripts on top of all this.
Go to Top of Page

Nick
Moderator

United Kingdom
6303 Posts

Posted - January 22 2010 :  16:09:51  Show Profile
Hi
quote:
Any news on updating the XML to using unique names for disks?

Please take the 'Help' > 'Check for updates' menu option to update Reflect to v4.2.2376. This update includes the Disk ID in the XML file.

Please edit your existing image definitions or create new ones to add the Disk ID.

Hope this helps

Nick - Macrium Support

Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
Macrium Support Forum © Paramount Software UK Ltd Go To Top Of Page
This page was generated in 0.56 seconds. Snitz Forums 2000