Video Screencast Help

Earn more Connect points - share your DS 7.x jobs with others!

Created: 09 Jun 2011 • Updated: 05 Dec 2011 | 14 comments
jon_sharp's picture

In an effort to foster sharing, I'd like to "encourage" you to share any useful DS 7.x jobs/tasks that you've created that may assist others in this forum. It will be worth your time and effort...

Also, if you're not a member of the Deployment Solution Private Group (Under All Communities->Endpoint Management->Groups->Product Groups->Deployment Solution), you should register and join today! The next notice of something along these lines may only be posted there and not publically.

Comments 14 CommentsJump to latest comment

JimChud's picture

Definately a good idea to help others save time.

I'll be uploading useful jobs as i migrate from DS 6.9 to DS 7.1

Map a network drive to a site based repository depending on IP address
https://www-secure.symantec.com/connect/downloads/map-drive-depending-ip-address-site-based-software-repositories

Install SNMP on Windows Servers
https://www-secure.symantec.com/connect/downloads/install-snmp-windows-servers

Regards Jim.
Connect Etiquette: "Mark as Solution" those posts which resolve your problem and give a thumbs up to useful comments, articles and downloads.

jason.f's picture

Here's a vbscript I wrote to determine the OS version using WMI and exit with a return code I can use as conditions for other tasks.  It's still a work in progress but should be clear enough for others to add on what they need. I only have Server OS's and a check to see if citrix is installed.

 

'EXIT CODES RETURNED
'
'(1) 'Server 2003 x86 No Citrix
'(2) 'Server 2003 x64 No Citrix
'(3) 'Server 2008 Std x86 No Citrix
'(4) 'Server 2008 Std x64 No Citrix
'(5) 'Server 2008 R2 x86 No Citrix
'(6) 'Server 2008 R2 x64 No Citrix
'(10) 'Server 2003 x86 with Citrix
'(11) 'Server 2003 x64 with Citrix
'(12) 'Server 2008 Std x86 with Citrix
'(13) 'Server 2008 Std x64 with Citrix
'(14) 'Server 2008 R2 x86 with Citrix
'(15) 'Server 2008 R2 x64 with Citrix
'(20) 'XP 32 bit

ON ERROR RESUME NEXT
strComputer = "."

dim osname, osver, procbit, build, ProdType, majorversion, minorversion, citrix

Set Wmi = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItemsOS = Wmi.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
Set colItemsProc = Wmi.ExecQuery("SELECT * FROM Win32_Processor", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem in colItemsOS
    osname = objItem.Caption
    osver = objItem.Version
    build = objItem.BuildNumber
    ProdType = objItem.ProductType
Next

For Each objItem in colItemsProc
    procbit = objItem.AddressWidth
Next

dim lngpos1, lngPos2
lngPos1 = instr(osver, ".")
lngPos2 = instr(lngPos1 + 1,osver, ".")
majorVersion = left(osver, lngpos1 - 1)
if lngPos2 = 0 then
minorVersion = mid(osver, lngpos1 + 1)
else
minorVersion = mid(osver, lngpos1 + 1, len(osver) - lngpos2 - (lngpos1 + 1))
end if

Set tstWMInamespace = GetObject("winmgmts:\\" & strComputer & "\Root\Citrix")
if ERR <> 0 then
    citrix = 0
elseif ERR = 0 then
    citrix = 1
end if

wscript.echo "Os Name: " & CStr(osname)
wscript.echo "OS Ver: " & osver
wscript.echo "Poc Bit: " & procbit
wscript.echo "Build #: " & build
wscript.echo "Major: " & majorversion
wscript.echo "Minor: " & minorversion
wscript.echo "Product Type: " & ProdType
wscript.echo "Citrix: " & citrix

if majorversion="5" and minorversion="2" and procbit = "32" and ProdType = "3" and citrix = "0" then wscript.quit(1) 'Server 2003 x86 No Citrix
if majorversion="5" and minorversion="2" and procbit = "64" and ProdType = "3" and citrix = "0" then wscript.quit(2) 'Server 2003 x64 No Citrix
if majorversion="6" and minorversion="0" and procbit = "32" and ProdType = "3" and citrix = "0" then wscript.quit(3) 'Server 2008 Std x86 No Citrix
if majorversion="6" and minorversion="0" and procbit = "64" and ProdType = "3" and citrix = "0" then wscript.quit(4) 'Server 2008 Std x64 No Citrix
if majorversion="6" and minorversion="1" and procbit = "32" and ProdType = "3" and citrix = "0" then wscript.quit(5) 'Server 2008 R2 x86 No Citrix
if majorversion="6" and minorversion="1" and procbit = "64" and ProdType = "3" and citrix = "0" then wscript.quit(6) 'Server 2008 R2 x64 No Citrix

if majorversion="5" and minorversion="2" and procbit = "32" and ProdType = "3" and citrix = "1" then wscript.quit(10) 'Server 2003 x86 with Citrix
if majorversion="5" and minorversion="2" and procbit = "64" and ProdType = "3" and citrix = "1" then wscript.quit(11) 'Server 2003 x64 with Citrix
if majorversion="6" and minorversion="0" and procbit = "32" and ProdType = "3" and citrix = "1" then wscript.quit(12) 'Server 2008 Std x86 with Citrix
if majorversion="6" and minorversion="0" and procbit = "64" and ProdType = "3" and citrix = "1" then wscript.quit(13) 'Server 2008 Std x64 with Citrix
if majorversion="6" and minorversion="1" and procbit = "32" and ProdType = "3" and citrix = "1" then wscript.quit(14) 'Server 2008 R2 x86 with Citrix
if majorversion="6" and minorversion="1" and procbit = "64" and ProdType = "3" and citrix = "1" then wscript.quit(15) 'Server 2008 R2 x64 with Citrix

if majorversion="5" and minorversion="1" and procbit="32" then wscript.quit(20) 'XP 32 bit

wscript.quit(999)

AttachmentSize
OS_Ver.txt 3.67 KB
sfaucher's picture

Here's a pair of jobs I find handy to get around the fact that currently the Reboot to Automation/Production tasks reboot even if you are already in the corresponding environment.  Here it is in pseudocode, since I can't embed images and xml exports don't really seem useful being a load of install-specific GUIDs (Edit - attached an appitory pdf with screen captures):

IF "%ALTIRIS_PREBOOT%"=="WINPE" EXIT 100 (this is a run script)

If (above task) Return Value = 100 (this is a condition on the above script)

    (nothing here)

else

    Run 'Reboot to Automation' (this is a task)

The reverse logic reboots to production from automation:

 

IF "%ALTIRIS_PREBOOT%"=="WINPE" EXIT 100 (this is a run script)

If (above task) Return Value = 100 (this is a condition on the above script)

    Run 'Reboot to Production' (this is a task)

else

    (nothing here)

These allow you to use jobs that call them from both automation and production, re-routing you to the correct environment if necessary.
AttachmentSize
Go To Automation or Production.pdf 645.63 KB

Shawn Faucher | Senior Technology Analyst

Armstrong Teasdale LLP
 

JMRoberts's picture

Thanks for that script, we'd been looking for something that prevents double PXE boots and that did the trick.

JMRoberts's picture

This is a simple script to detect a PC or Laptop's model through WMI in a vbs file, then pass this back to the command prompt and delete the temporary VBS file, the second part of the script then checks the model name, and copies the required drivers to C:\drivers, for this to work you need to have pointed your sysprep file to C:\drivers, you also need a map drive script to run before this in order to map a drive to the deployment server, in order to run firm.exe, and another drive if required to your driver share (mapped as k: and j: in this example).

This is for Windows XP but the same applies for Windows 7.

REM WinPE Copying Required Drivers
REM Windows XP 32bit Systems
@echo off

setlocal
set tmpfile=K:\%random%.vbs
echo Set CSset = GetObject("winmgmts:")._ >%tmpfile%
echo InstancesOf("Win32_ComputerSystem") >>%tmpfile%
echo For Each CS In CSset >>%tmpfile%
echo WScript.Echo CS.Model >>%tmpfile%
echo Next >>%tmpfile%

for /f "tokens=*" %%a in (
'cscript.exe //Nologo %tmpfile%') do set model=%%a

del %tmpfile%

echo Model Number is %model%

if "%model%"=="satellite pro a120" goto A120

:A120
echo Satellite Pro A120
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\A120 prod:\
goto Exit

::HAL
echo HALS required
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\HALS\acpi prod:\Windows\System32
goto Exit

:Exit

I hope this helps you out if you were stuck on driver injection as we were, it's a far quicker solution than DA at this point in time and allows you to include all drivers.

Zac H's picture

Instead of echoing and running a vbscript, I'd assume that you could also use WMIC, no?

'wmic computersystem get model' should get you the same result in the batch file.

DustinW's picture

This is absolutely fantastic. Thank you, this is exactly what I needed. We'll probably be using a variation of this soon. I'd like to try to get it to work in conjunction with DeployAnywhere, to fill in the holes where DA doesn't work. Thank you very much!

Gibson99's picture

if this script plugs in 100% of your drivers, why bother complicating things with DA?  we don't.  i wrote a vbs a couple years ago for use in ds 6.9 that does something similar to what someone else posted below - name the directories whatever WMI says the computer model is - OptiPlex 790, Latitude E6320, etc.  then your script doesn't need to get touched ever again.  just don't forget the chr(34) for your quote marks in case a model has a space in its name (most do).  this very same script still works perfectly in 7.1, or at least it did during our testing of 7.1.

If a Connect post helped you out, be sure to click "Mark As Solution" or the "Thumbs Up" button to let other users know about it.

JMRoberts's picture

I would imagine that would work just as well and cut out a large portion of that code, how would you reference the model name in the second part of the script then?

I imagine it would involve changing this line:

for /f "tokens=*" %%a in (
'cscript.exe //Nologo %tmpfile%') do set model=%%a 

Zac H's picture

I'd think this should work:

 

 

REM WinPE Copying Required Drivers
REM Windows XP 32bit Systems
FOR /F "tokens=2 delims==" %%G IN ('WMIC computersystem get model /format:VALUE') DO SET Model=%%G
 
:A120
echo Satellite Pro A120
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\A120 prod:\
goto Exit
 
::HAL
echo HALS required
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\HALS\acpi prod:\Windows\System32
goto Exit
 
:Exit
mclemson's picture

You can remove the need to update model entirely from your script if you have your folder names match your model names.

You have, essentially:

echo Model Number is %model%

if "%model%"=="Latitude E6400" goto E6400
if "%model%"=="Latitude E6410" goto E6410
if "%model%"=="Latitude E6420" goto E6420
if "%model%"=="Satellite Pro a120" goto A120

:E6400
echo Latitude E6400
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\E6400 prod:\
goto Exit

:E6410
echo Latitude E6410
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\E6410 prod:\
goto Exit

:E6420
echo Latitude E6420
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\E6420 prod:\
goto Exit

:A120
echo Satellite Pro A120
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\A120 prod:\
goto Exit

 

When you could easily use a variable:

fso.CopyFolder "W:\<driver root path>\" & strName & "", "M:\Drivers"

Now all you need to do is name your folders after the model name pulled from the WMI query (Satellite Pro A120, Latitude E6420) rather than something arbitrary that gets entered by a highly-paid technician into a text file (A120, E6420), which is time-consuming and prone to error.

 

Mike Clemson, Senior Systems Engineer, ASC
Intuitive Technology Group -- Symantec Platinum Partner
intuitivetech.com

Zac H's picture

Good point!  Assuming a batch file is still needed, this could be the result:

 

 

REM WinPE Copying Required Drivers
REM Windows XP 32bit Systems
FOR /F "tokens=2 delims==" %%G IN ('WMIC computersystem get model /format:VALUE') DO SET Model=%%G
 
ECHO %Model%
"J:\Task Handler\rdeploy\firm.exe" -recurse copy K:\WindowsXP\%Model% prod:\
goto Exit
 
:Exit
 
I did see something in there for HAL stuff.  Not sure what logic you're using for that, but this would indeed copy down the correct drivers with no editing of the batch file for new models.
JMRoberts's picture

Perfect, works a treat..

Sorry, you can ignore the hal stuff, for the laptops / base units which need an older HAL we put a call under the driver copy command to the HAL copy command, thats about it.

That's saved me a few lines of code anyway.

Thanks for your input.

JMRoberts's picture

Here is the end result, if anybody needs it:

 

REM WinPE Copying Required Drivers
REM Windows XP Systems
@echo off

FOR /F "tokens=2 delims==" %%G IN ('WMIC computersystem get model /format:VALUE') DO SET Model=%%G

ECHO Model: %Model%

"J:\Task Handler\rdeploy\firm.exe" -recurse copy chr(34)K:\WindowsXP\%Model%chr(34) prod:\

goto Exit

:Exit

Grabs the computer model, then copies a folder which has the model name to the root of the production drive, I put a "Drivers" folder inside each of the model folders so that all drivers are copied to C:\drivers. This will work on XP, 7x32 and 7x64. All you have to do each time you get a new system type is create the folder with the same name as the model name, and put the drivers in there.

Thanks for everyones help.