Ausmith1 Posted March 18, 2004 Posted March 18, 2004 I have found Devcon to be an extremely useful tool for unattended installs. One of the latest uses I found for it is to automatically determine if the install is running in a VM (I use MS Virtual PC 2004 and Virtual Server 2004) and if so to install the VM additions package.What is Devcon? Here is the official line from MS.The DevCon utility is a command line utility that acts as an alternative to Device Manager. Using DevCon, you can enable, disable, restart, update, remove, and query individual devices or groups of devices. DevCon provides information that is relevant to the developer and is not available in Device Manager.You can use DevCon with Windows 2000 and Windows XP. You cannot use Devcon with Microsoft Windows 95, Windows 98, or Windows Millennium Edition.You can download Devcon fromDevCon - Command Line Utility Alternative to Device ManagerHere is the simple script I use to determine if the install is running on a VM.From my RunOnce.Cmd script.@ECHO Attempting to determine if the system is a VM...@ECHO Install Microsoft Virtual PC or Server 2004 Additions if this system is a VM.REM Since the VM additions install an updated video driver and it sets the desktopREM to 640 x 480 x 8 bit we will use reschange after the next reboot to set the desktop to REM 1024w x 768h x 24d x 75rREM Virtual Server and Virtual PC both have a device named "Virtual HD"C:\Temp\Scripts\devcon hwids * | xgrep -c "Virtual HD"IF %errorlevel% EQU 0 CALL C:\Temp\Apps\VM\VM_Additions.CmdREM Lets do that again to skip the HP and IBM tests in the case we are on a VMC:\Temp\Scripts\devcon hwids * | xgrep -c "Virtual HD"IF %errorlevel% EQU 0 GOTO 002-ExitAnd here is the actual VM_Additions.Cmd scriptREM Script to install Microsoft Virtual PC/Server 2004 additionsREM Updated for the new common additions (v13.120) March 12th 2004REM Virtual Server and Virtual PC both have the device named "Virtual HD"C:\Temp\Scripts\devcon hwids * | xgrep -c "Virtual HD"IF %errorlevel% EQU 0 GOTO MS_VMIF %errorlevel% EQU 1 GOTO EXITIF %errorlevel% GEQ 2 GOTO ERROR:MS_VMREM Since the additions are the same now, this is kind of unnecessary at the moment...REM All it does for now is logs to a different log file.REM Determine if we have Virtual PC or Virtual ServerREM Virtual PC (by default) has a sound card, Virtual Server does not have this option.C:\Temp\Scripts\devcon hwids * | xgrep -c "Sound Blaster 16"IF %errorlevel% EQU 0 GOTO VPCIF %errorlevel% EQU 1 GOTO VSRVIF %errorlevel% GEQ 2 GOTO ERROR:VPC@Echo Installing Virtual PC AdditionsREM Extract the archiveC:\Temp\Apps\VM\VSrv_Additions.Exe -yREM Do silent install and rebootC:\Temp\Apps\VM\Setup.Exe /S /V"/qb-! /L*v C:\Temp\VPC_Additions.Log"GOTO EXIT:VSRV@Echo Installing Virtual Server AdditionsREM Delete the VMWare SCSI drivers to avoid any conflicts during installRMDIR /S /Q C:\Temp\Drivers\SCSI\VMWareDEL /Q /F C:\WINDOWS\system32\drivers\vmscsi.sysREM Extract the archiveC:\Temp\Apps\VM\VSrv_Additions.Exe -yREM Do silent install and rebootC:\Temp\Apps\VM\Setup.Exe /S /V"/qb-! /L*v C:\Temp\VSrv_Additions.Log"GOTO EXIT:ERROR@ECHO Error occured during parsing of hardware IDs.@ECHO Cannot determine if this system is a VM or real hardware.pause:EXITAnother use I have for Devcon is determining if the system is attached to a FC SAN device which we use for clustering.REM Clustered HP systems have a FC HBA device named "KGPSA"C:\Temp\Scripts\devcon hwids * | xgrep -c "KGPSA"IF %errorlevel% EQU 0 GOTO HAS-FC-HBAREM Clustered VMs have a SCSI device named "VM Additions Accelerated SCSI Controller"C:\Temp\Scripts\devcon hwids * | xgrep -c "VM Additions Accelerated SCSI Controller"IF %errorlevel% EQU 0 GOTO HAS-FC-HBAI hope this example is helpful to someone else out there and that you can adapt these ideas and examples for your own uses.BTW xgrep is available for download @xgrep - Small and fast text finding utilityNaturally you can substitute your favoured grep utility.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now