You are currently browsing the tag archive for the 'VBScript' tag.

This VBScript is for disabling the Fingerprint device in BIOS.  It has only been tested on a few newer HP models.

‘============================================================
‘ AUTHOR: Nick Moseley ,
http://t3chn1ck.wordpress.com
‘ DATE  : 5/29/2009
‘ COMMENT: This script is for disabling the Fingerprint Device in BIOS
‘ It has been tested on HP models – 6515b, 6535b, 2510p – but may
‘ function for other models
‘============================================================
Option Explicit

Click Here for Full DisableFingerprintDevice.vbs Code

There are plenty of examples out there for how to get the most out of Task Sequences for SCCM 2007 OS deployment.  But I wasn’t motivated to find out how others were doing it…Until I saw a demonstration by Jarvis Davis that he presented at MMS 2009. 

From that I built my own custom HTML Application to do what I needed.  At the moment, I have not enabled HTA support in my WinPE boot images.  So the below example is purely a “BackEnd” script which simply means that it needs to run at the towards the end of the Task Sequence so that the end-operator (or end-user) does not need to wait for much of the imaging to complete.

This HTA does the following

  • Field to enter in the name of user to add into the local Administrators group
  • Selection for US time zone to configure Windows to use (defaults to MST, since that is where I am)
  • Option to install one of 6 flavors of Adobe Acrobat
  • Option to install one of 2 flavors of Project 2003
  • Option to install one of 2 flavors of Visio 2003
  • Option to install BlackBerry desktop
  • Option to install Streets and Trips 2006

Additional things to note

  • In order to add a domain user to your local admins group, the value sDomainName = “YourDomainName” must be filled in appropriately.
  • All activity is logged into C:\CustomSystemOptions.log
  • If one of the options to install software is selected, a Task Sequence variable is created and set to True.  To utilize this, you would need to have an Install Software task that is limited to only install of the corresponding variable is set to True.  Note: the Install Software task must be after the execution of the HTA!

Hope this is helpful!

<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>
<title>OSD Option Choser</title>

Full CustomSystemSettings.hta Code Here

Today I was troubleshooting some client communication problems and found that one of the causes was that they were generating bad MIFs, so SCCM was rejecting the hardware inventory they were sending.  Along the way, I also found that there 230 bad MIFs on my site server.  Instead of manually opening each file to ‘document’  which system it was, I decided to script it.  I must give credit to a blog posting by Don Hite, which gave me the original idea to do this in the first place.

‘==========================================================================
‘ NAME: Get_BADMIFS

‘ AUTHOR: Nick Moseley, http://t3chn1ck.wordpress.com
‘ DATE  : 5/14/2009

‘ COMMENT: Ensure the value for sSMSInbox is the UNC path to your SCCM inboxes
‘==========================================================================

Const ForReading = 1
Dim sSMSInbox, sNamePosition, bNameFound, sFileLine, sSystemName, iFileCount, oExcel, iRow
sSMSInbox = “\\ServerName\SMS_XYZ\inboxes”

Set oShell = CreateObject(“WScript.Shell”)
Set oFSO = CreateObject(“Scripting.FileSystemObject”)

Full GetBADMIFS.vbs Code Here

One of the challenges with condensing workstation task sequences into a single task sequence is being able to distinguish between desktops and laptops as each typically has their own set of functions to perform when being imaged.  One of the best ways to determine this is by querying ChassisTypes in Win32_SystemEnclosure.  Unfortunately, ChassisTypes is an array value; the WQL that is used in the task sequence is limited to single values. 

To work with this, add the following vbscript to a Run Command Line task.  It creates a custom Task Sequence variable that can then be used to dynamically limit certain tasks to “desktops” and others to “laptops”.

‘==========================================================================
‘ NAME: SMSTSEnvChassisType.vbs

‘ AUTHOR: Nick Moseley, SCCM Administrator
‘ DATE  : 4/24/2009

‘ COMMENT: Script creates custom TS variable that can be used to distinguish
‘ between a desktop and a laptop for dynamically selecting which tasks
‘ to run in the sequence. Note that the echo statements are logged in SMSTS.log
‘==========================================================================

Full SMSTSEnvChassisType.vbs Code Here

When doing a baremetal image in SCCM OSD, the task sequences will generate a random name for the system. To define a specific name the system is to receive, use the following VBScript.  It will prompt the end-operator to input a name and then it will set the TS variable “OSDComputerName”. 

Add the script to the TS by adding a Run Command Line task after Partition Disk and before Apply Operating System.

promptsystemname

 

' NAME: PromptForSystemName.vbs
'
' AUTHOR: Nick Moseley
' DATE  : 6/1/2009
'
' COMMENT: This script will detect if the current assigned value for the computer name
' begins with MININT, indicating that this image is bare metal image.  It then prompts
' the end-user to enter a new computer name.
'
' VERSION : 1.1
' 1.0 (12/08/2008)- Intial script to check if the computer name begins with
'  "minint", which indicates the system was booted with CD or PXE.
' 1.1 (06/01/2009)- Added check if the computer name equals "minwinpc",
'  which indicates the system was booted with USB key

Full PromptForSystemName.vbs Code Here

In a corporate environment, distributing software can frequently be tricky.  One thing that can cause the most headaches is when there are registry changes that need to be made within the HKCU hive of any or even every user.  For example,  Apple designed QuickTime to allow every user to decide whether or not to enable automatic updates.  So this value is set in HKCU\Software\Apple Computer, Inc.\QuickTime\LocalUserPreferences\.  But in a controlled environment, you really don’t want the users doing their own thing.  So the package needs to be designed in such a way that edits the aforementioned registry key.

With SMS/SCCM, one could always build a script to make the change and configure the Program to run every time a user logs on.  I used to do it this way, but grew tired of constantly needing to monitor that the advertisement is successful and there are not alot of failures…so I became my own thinktank to figure out a new process.  What I realized is that I could use the existing WinXP registry tool (reg.exe) to make all the changes I need. 

The process kind of looks like this: once there is no user logged into Windows, I run a script that

  1. Parses HKLM for every user profile
  2. Loads the discovered user’s registry hive
  3. Makes the HKCU change
  4. Unloads the user’s registry hive
  5. Moves onto the next profile

This even modifies the Default User’s profile so that anyone who logs onto the computer for the first time will already have this setting!  Rinse.  Repeat.  Done.


'==========================================================================
' AUTHOR: Nick Moseley
' DATE  : 04/07/2009
' COMMENT: This script will parse all User profiles on the computer, load their
'  HKCU hive, then set the appropriate registry keys.
'==========================================================================
Full ScriptHKCU.vbs Code Here
I was recently tasked with automating a disk cleanup and defrag for the XP workstations in our environment.  Simple enough of a task using the built-in disk cleanup and defrag.  But I thought I’d share some details of how I automated them…
 
Disk Cleanup
Grasping how to peforming an unattended cleanup can be tricky.  The first thing to understand is that selecting the various caches (Internet files, temporary files, trash, etc etc) is controlled through a “sageset”.  You can think of a sageset as the configuration number which inidicates what diskclean should remove.  So one could have a sageset which cleans up only trash, another sageset which cleans up trash and internet files, another sageset which cleans up all items except memory dump files, etc etc.
 
This sageset are DWORD values in HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\ in each subkey.  For example, I want to cleanup only Internet Cache Files and assign sageset 99 to it.  Within subkey “Internet Cache Files” I create the DWORD value name StateFlags0099 and give it the value 2.  Then to cleanup this item, I simply run cleanmgr.exe /sagerun:99 – That’s it!  To add more items to the sageset, all one needs do is add that StateFlags0000 (where the zeos are the sageset number created).
 
Make sense?  For more information, see Q315246
 
Disk Defrag
Not too much doin’ here.  I simply trigger defrag.exe c: -f
 
A neat thing about defrag is that you can first have it analyze the disk to see its fragmentation stats.  Since I log SCCM installs/operations for workstations into a custom log file, I thought it would good to capture this analysis in the log file.  Below is the vbscript code that I used to facilitate this…

Dim oFSO, oShell, oLogFile
Const cForAppending = 8
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
Set oLogFile = oFSO.OpenTextFile ("C:\CustomLog.txt", cForAppending, True)
Set oExecRun = oShell.Exec ("C:\Windows\system32\defrag.exe c: -a")
 
Full DiskCleanup.vbs Code Here

Queue of Upcoming Posts

  1. Scripting XP Power Settings
  2. "Homegrown" Client Health Solution
  3. SCCM Superflows
  4. Creative Solution for Using Different Network Settings in Task Sequences
  5. Scripting the backup of VMWare Server 2 VMDKs

Blog Stats

  • 13,594

World Map of Blog Hits

Most Recent Visitors!

 

December 2009
M T W T F S S
« Nov    
 123456
78910111213
14151617181920
21222324252627
28293031