Jump to content

Recommended Posts

Posted

I've just about perfected our configuration of sysprep for use with Ghost so we can image onto different hardware however I have encountered one problem which as of yet I've not been able to solve!

 

We are currently using an Avantis OpenCD Server, the client software creates a virtual dvd drive on the computer, by default this will pickup the first available drive letter. When using Ghost on its own I simply changed the drive letter to K: using Disk Management and that was that! However on sysprep'd computers it would appear the drive letter is reset to the first available drive letter.

 

I've looked at using Diskpart and some kind of script to change the drive letter to K: combined with the RunOnce element of sysprep. However the problem is some computers in school have physical dvd drives, some do not, some computers also feature a recovery partition and some do not. Therefore the first available drive letter is different from one computer to another. So I cannot simply change it based on the ID in Diskpart or based on the current drive letter since it will always be different.

 

Can anyone see a way around this? Is there perhaps a way to script a drive letter change based on the name of the drive in device manager? Clutching at straws here so any advice would be much appreciated. :)

Posted (edited)
I'm currently using USBDLM to control drive letters mapped to Flash Drives, how can this be used for non-USB devices? Edited by jack0w
Posted

Interesting problem. I usually image machines using a Bart PE/Image for Windows boot CD. Once fully booted, I can browse C:\ (Local Disk) and D:\ DVD Drive. If I'm using an external USB hard drive it uses the next available drive letter - E:\

Alternatively, if I map a network drive to where the images are stored using a UNC path \\servername\sharename it also uses the next available drive letter E:\. Using either method I then re-image C:\ (Local Disk), then restart and Mini Setup starts.

 

It sounds to me that your image software is using the first available drive letter - which I'm guessing would be C:\ which is a little daft if you ask me; unless you can still re-image the local disk even if its setup as D:\ or E:\ ? I've never tried. As for those hidden/restore partitions you'll probably need some other software to delete and merge partitions before imaging.

You could boot off a standard Windows ISO, delete all partitions, create a single partition, then quit setup prematurely. Your imaging software should then format and restore the image.

Posted

When I used Ghost without Sysprep to image computers whatever changes I made in Windows to the drive letters for the DVD drives would still be there after I restored the image to a different computer.

 

However its only since I've started using Sysprep that the letters I've assigned to my DVD drives reset after mini setup is run. :mad:

Posted

So could you clarify exactly what the problem is, as I am confused. How are you getting to the point where a virtual drive is created? Are you booting from a CD, floppy or USB stick?

 

When you're in this 'pre-state', what letters are your local disk, disc drive and virtual drive mapped as?

Posted

Sorry, don't think I explained the problem very well. :doh:

 

The Virtual Drive is created in Windows by installing the software that came with our Avantis OpenCD Server. Once the install of the software completes the drive is the first available letter in windows, I can then change the letter using Disk Management to K: and that's fine, no problem.

 

When using ghost without sysprep in the past I would make any other necessary changes to the computer and then take an image of the computer using Ghost. I could then deploy this image to computers with the same hardware, again - no problem.

 

However, now I've started using sysprep to create an image which is not hardware dependant. I can configure the computer in the exactly same way as above without any problems, but as soon as the computer boots up after being imaged and having mini setup run the drive which I set to K: prior to taking the image changes its drive letter to the first available again.

 

Obviously I'd rather not have to go round to all the computers after they've been imaged and manually change the drive letters back to K: as that would be a nightmare!

 

Hopefully that makes more sense than my original post! :p

Posted

I'm still confused how you're actually imaging your workstations :confused: You have Windows already installed and you install some software which creates a virtual disc drive, which you then change to K:\

 

At this point how are you re-imaging the workstation!? :) I'm really curious. As for Sysprep itself re-setting drive letters, it is possible that drive information/configuration is stored within the SID (Security Identifier), which Sysprep resets. I am not 100% sure though!

 

When you configured your Sysprep answer file, you can specify a batch file to run under Run Once when you first logon. This will automatically bring up the Disk Management console for you:

 

@echo off
c:\windows\system32\diskmgmt.msc

 

Save as DiskManagement.bat. This should save you a lot of time. I'm not sure of any ways to automatically change a physical/virtual drive using a script. Network drives are straight forward however.

  • Thanks 1
Posted

Thanks for the suggestions guys, I think I've managed to create a vbscript which will do the trick, however one part of it doesn't seem to work - the command to run diskpart!

 

Any scripting gurus able to spot my error? :confused:

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objOutFile = objFSO.OpenTextFile("C:\diskpart.txt", 8, True)

 

On Error Resume Next

strComputer = "."

Dim strDriveLetter

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")

For Each objItem in colItems

If objItem.Name = "Avantis Open CDMVD001 SCSI CdRom Device" Then objOutFile.WriteLine "Select volume" & " " & objItem.Drive

Next

objOutFile.WriteLine "assign letter=K:"

 

Set objShell = CreateObject ("WScript.Shell")

objShell.Run "diskpart /s C:\diskpart.txt > c:\Logfile.txt", 6, True

 

'objFSO.DeleteFile "C:\diskpart.txt"

Posted

Have you made sure that the text file is written properly and not locked when you are trying to access it with diskpart. Also have you tried using

objShell.Run "diskpart /s C:\diskpart.txt > c:\Logfile.txt", 1, True

which should force the script wait while the command is running.

  • Thanks 1
Posted
Have you made sure that the text file is written properly and not locked when you are trying to access it with diskpart. Also have you tried using

objShell.Run "diskpart /s C:\diskpart.txt > c:\Logfile.txt", 1, True

which should force the script wait while the command is running.

 

I've checked the text file and that is being written as expected, how can I check to see if the file is locked when diskpart is trying to access it?

 

I've tried running the command you suggested in a seperate script with the text file already created, and that changes the drive letter to K: as it should.

 

Just doesn't seem to work when it is all in one script!

 

Thanks for your help on this!

Posted
think the files locked. try using

 

objReadFile.Close

 

I've just tried adding that line after the last WriteLine and adding a sleep in between creating the text file and starting diskpart - no joy! :(

Posted

After the close you could try setting the objects to nothing then adding a wait period before trying to access it:

 

Set objFSO = nothing
Set objOutFile = nothing 
WScript.Sleep(5000)

Set objShell = CreateObject ("WScript.Shell")
objShell.Run "diskpart /s C:\diskpart.txt > c:\Logfile.txt", 6, True

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutFile = objFSO.OpenTextFile("C:\diskpart.txt", 8, True)
If objFSO.FileExists("C:\diskpart.txt") then objFSO.DeleteFile "C:\diskpart.txt" 			 		

 

Also, is there any specific reason why you are using objFSO.OpenTextFile rather than objFSO.CreateTextFile ?

  • Thanks 1
Posted
After the close you could try setting the objects to nothing then adding a wait period before trying to access it:

 

Set objFSO = nothing
Set objOutFile = nothing 
WScript.Sleep(5000)

Set objShell = CreateObject ("WScript.Shell")
objShell.Run "diskpart /s C:\diskpart.txt > c:\Logfile.txt", 6, True

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutFile = objFSO.OpenTextFile("C:\diskpart.txt", 8, True)
If objFSO.FileExists("C:\diskpart.txt") then objFSO.DeleteFile "C:\diskpart.txt" 			 		

 

Also, is there any specific reason why you are using objFSO.OpenTextFile rather than objFSO.CreateTextFile ?

 

No particular reason for this, would it be better to use CreateTextFile? I'm still trying to teach myself when it comes to vbscript!

 

Just tried that and it seems to do the trick! Thank you very much for your help on this!

Posted
No particular reason for this, would it be better to use CreateTextFile? I'm still trying to teach myself when it comes to vbscript!

 

Just tried that and it seems to do the trick! Thank you very much for your help on this!

 

CreateTextFile is the more standard way of doing this kind of thing as it automatically creates the file without extra command options, the OpenTextFile method is generally usually used more for reading out or appending to existing test files. Because OpenTextFile was used it needed the 'true' appended to the end to tell it to create the file if it did not exist. Where as CreateTextFile would have just needed the filename passed to it.

 

Your code is a perfectly valid way of doing it I had just not come accross another example where OpenTextFile was used to create the file and so suspected it may have been causing trouble. Good to hear that you got it working. :)

  • Thanks 1
Posted

Still a bit stumped on this, the script works perfectly - I've tested on several computers myself. However when it runs after sysprep (either through the GuiRunOnce or Cmdlines.txt tried both ways!) if you read the log file it says the drive letter was successfully changed, however when you actually go and take a look at the virtual cd drive it has still reverted to the first available drive letter!

 

Tearing my hair out with this, so any suggestions would be much appreciated.

 

Cheers

Posted
Still a bit stumped on this, the script works perfectly - I've tested on several computers myself. However when it runs after sysprep (either through the GuiRunOnce or Cmdlines.txt tried both ways!) if you read the log file it says the drive letter was successfully changed, however when you actually go and take a look at the virtual cd drive it has still reverted to the first available drive letter!

 

Tearing my hair out with this, so any suggestions would be much appreciated.

 

Cheers

 

It sounds like whatever process is resetting the drive letters to the first available is running after the GuiRunOnce and Cmdlines.txt sections have executed. The only thing that I can think of to deal with this is somehow running the script later in the imaging process on the first logon afterwards by scheduling the script to run with appropriate credentials using the schtasks.exe app in the GuiRunOnce or just set it up to run on every startup.

Posted
I would second USBDLM. See the 'Letters by Device ID' section in the help file. You can find the device ID in Device Manager.

 

I'm currently using USBDLM for flash drives, however I can't seem to get it to work for the virtual cdrom drive. I've tried it with the friendly name and the device id in the ini file but to no avail. Have you managed to get USBDLM to work with non-usb devices?

  • 3 weeks later...
Posted

It's also possible that when you run the command, sysprep (or a process within) is resetting the drive letters.

 

Perhaps an easier way would be to stick it in RunOnce for All Users, means sysprep shouldn't run it and it should run AFTER sysprep completes.

 

However it's also possible that diskpart may not have permission to do what you are asking, which it may well not do with my suggestion above.

 

It's tricky - had a similar situation where a cloning disaster caused drive C: to appear as D: and A: to appear as C: - oh yes, that was fun.

 

Alot of digging for certain registry keys solved it.

Let me see if I still have it...

 

Okay... on a PC that works as expected.

 

Under HKLM\System\MountedDevices is a bunch of keys with volume GUIDs in them.

 

There are also ones called DosDevices.

 

Export that registry key and use a text editor to compare - much easier.

 

Open up the registry file in notepad.

 

The values for DosDevices should match the Volume{GUID} - so in your case, look for the following:

 

\DosDevices\K:

 

Look at the value data for this and find the same one in the \??\Volume{GUID} bit.

 

Using notepad search, you can quickly find the one you want - now you want to copy the bits of the keys you want (the single Volume{GUID} and DosDevices entries that match) into a seperate .REG file (make sure you keep the first 2 lines of the original export file).

 

Import this on a PC that didn't have the right letter and reboot.

 

Hopefully - albeit a long-winded way, but it should help.

 

Az

  • Thanks 1
Posted

Cheers for the replies people!

 

I've managed to get this one working now, using the original vbscript I've created a new OU in AD called Imaged Computers, set Ghost to create the Computer Account in this OU, that way on first boot after joining the computer to the domain the script is run under the System account as a Startup Script.

 

This seems to do the trick, not sure why it wasn't running to start with but hey, at least its working!! :D

 

Thanks for everyones help and suggestions with this.

  • 3 weeks later...
Posted
Cheers for the replies people!

 

I've managed to get this one working now, using the original vbscript I've created a new OU in AD called Imaged Computers, set Ghost to create the Computer Account in this OU, that way on first boot after joining the computer to the domain the script is run under the System account as a Startup Script.

 

This seems to do the trick, not sure why it wasn't running to start with but hey, at least its working!! :D

 

Thanks for everyones help and suggestions with this.

 

Did you use the exact same script as the first page? Please can you post your full script. I am having the same problem as you.

 

Thanks

 

Z

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



×
×
  • Create New...