Archive

Archive for the ‘SCCM Software Deployment’ Category

App-V package not streaming to client using ConfigMgr

April 28, 2011 Leave a comment

 

If you get the following error, or something similar, when trying to deploy an App-V package using ConfigMgr there could be a variety of reasons for it’s cause.

Failed to instantiate Updates UI Server
{2D023958-73D0-4542-8AD6-9A507364F70E} with error 8000401a

Maybe the “Advertised Programs Client Agent” found within the ConfigMgr console in “System Center Configuration Manager – Site Database – Site Management – SITECODE – Site Settings – Client Agents” does not have the appropriate settings (see the screenshot).

image

Maybe IIS is not configured properly on the DP the client is trying to pull from.

Maybe the package is not located on the DP and you have protected sites configured.

Or, as it was in my case, maybe somehow the Windows Firewall is on and does not have any exceptions so it is blocking the traffic.

The bottom line is that it is not necessarily a client-side issue and I would suggest looking for configuration mistakes – we are all human after all.

ConfigMgr program name issue with task sequence

April 22, 2011 2 comments

Ever had a program that would not run in a ConfigMgr OSD task sequence using “Install Multiple Applications” because of extended ASCII characters? I know of several that have…

There is now a hotfix!

Hotfix link http://support.microsoft.com/kb/2507187

Source link: http://blogs.technet.com/b/configurationmgr/archive/2011/04/19/new-hotfix-program-does-not-run-in-a-task-sequence-on-a-system-center-configuration-manager-2007-sp2-client-if-the-program-name-contains-extended-ascii-characters.aspx

SCCM Maintenance Window – Servers

March 31, 2011 Leave a comment

Maintenance Window – a maintenance windows defines times during which ConfigMgr can apply advertisements and software update deployments to devices associated with a collection.

I have two maintenance windows specifically for server devices. In this case I want to never deploy anything to server devices. While this will change down the road and we will need to re-think how this is done it meets our requirements for today. The maintenance window blocked times overlap and therefore no advertisements can run ever unless there is an override. Please note that an override can be set via an advertisement (“ignore maintenance windows”). This is not set by default and would need to be set by a SCCM Administrator.

The first maintenance window is on the “All Windows Server Systems” collection. This collection contains all devices that have a Windows Server OS regardless of having the SCCM client or not (discovery can determine the OS without the client). The window is set to the smallest possible period of time (5 minutes) and is set for the 1st day every 1 month from 1:00:00 AM to 1:05:00 AM.

clip_image002

The second maintenance window is on the “All Windows Server Systems with the Client Installed” and is set to the smallest possible period of time (5 minutes) and is set for the 15th day every 1 month from 1:00:00 AM to 1:05:00 AM.

clip_image004

App-V Recipe – SCCM 2007 Console with App-V 4.6 RTM

March 10, 2011 Leave a comment

– Not all functions may exist within the console if running on x64 when sequenced on x86.
– I am not claiming that this is necessarily the best way, or only way to build the package.
– This recipe was done on a Windows 7 SP1 x86 VM with the App-V Sequencer installed on Hyper-V. Nothing more.
– The folder structure used is what I use in production and are only suggested locations.
– I use SCCM with App-V integration.
– I use “B:\” as the App-V drive. You can use whatever you would like.
– The final App-V package was tested with SCCM for both cached and streaming successfully.

Instructions:

1. Before starting do the following if you have not already:
a. On a device with the SCCM Console already installed locally export the following registry keys and store them in \\SERVERNAME\install\Packages\Microsoft\SCCM Console\2007 SP2\R018_Custom Actions
i. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\SnapIns\FX:{6de537a5-7a1c-4fa4-ac3a-1b6fc1036560}]
ii. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MMC\SnapIns\FX:{a77b774c-ce32-4ab0-982a-6bb3c078e5c1}]
iii. [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConfigMgr\AdminUI\QueryProcessors\WQL]

2. Join the VM to your domain

3. Reboot

4. Log in as the local administrator

5. Add your domain account as a local administrator

6. Logoff

7. Be certain that your domain account has access to the SCCM console (this has to be set in the console by a SCCM administrator)

8. Logon with your domain account

9. Create a folder in “B:\” named “SCCM.001”

clip_image002

10. Navigate to \\SERVERNAME\install\Packages\Microsoft\SCCM Console\2007 SP2\R011_Original Source Media and be sure you have access

11. Launch the App-V sequencer from the “Start Menu”

12. Click on “Create a Package”

clip_image004

13. Type “SCCM_Console” in the “Package Name” field and click “Next”

clip_image006

14. Click “Begin Monitoring”

clip_image008

15. Select the “SCCM.001” folder in “B:\” and click “OK”

clip_image010

16. The sequencer will get ready for the installation

clip_image012

17. The sequencer will let you know when to begin the application installation

clip_image014

18. Run “splash” from \\SERVERNAME\install\Packages\Microsoft\SCCM Console\2007 SP2\R011_Original Source Media

clip_image016

19. Click on “Configuration Manager 2007 SP2”

clip_image018

20. Click “Next”

clip_image020

21. Click “Next”

clip_image022

22. Accept the EULA and click “Next”

23. Click “Next”

clip_image024

24. Click “Next”

clip_image026

25. Type the name of your primary site server and then click “Next”

26. Click “Next”

clip_image030

27. Click “Begin Install”

clip_image032

28. The console will install

clip_image034

29. Click “Next”

clip_image036

30. Click “Finish”

clip_image038

31. Launch “adminconsole.msc” from “C:\Program Files\Microsoft Configuration Manager Console\AdminUI\bin”

32. In the console expand “Site Database”, expand all features, and click on them

33. Close the SCCM console

34. Import the three registry keys from \\vdawwsccm1\install\Packages\Microsoft\SCCM Console\2007 SP2\R018_Custom Actions

35. In the App-V sequencer click “Stop Monitoring”

clip_image042

36. The changes will be applied

clip_image044

37. Click “Next”

clip_image046

38. Expand “Virtual Machine Manager” and click on “Shortcuts”

39. Right click “ConfigMgr Console” and click “Edit”

clip_image048

40. Click on “Change Icon…” and browse to “C:\Program Files\Microsoft Configuration Manager Console\bin\i386\” and select “SETUP.EXE”

clip_image050

41. Select the proper icon

clip_image052

42. Click “Save”

clip_image054

43. Right click “ConfigMgr Documentation” and click “Edit”

clip_image056

44. Click on “Change Icon…” and browse to “C:\Windows” and select “hh”

clip_image058

45. Select the proper icon

clip_image060

46. Click “Save”

clip_image062

47. Click “Next”

clip_image064

48. Click “Launch All” and verify that all of the applications open

clip_image066

49. The applications will launch (close each one when done)

clip_image068

50. Click “Next”

clip_image070

51. The application sequencing will finalize

clip_image072

52. Click “Finish”

clip_image074

53. Click “Package – Save”

clip_image076

54. Save in “B:\SCCM.001” as the default name

clip_image078

55. The project will save

clip_image080

56. In the “Deployment” tab make the application available to all Operating Systems

clip_image082

57. Save and close the App-V sequencer

58. Copy “B:\SCCM.001” to \\SERVERNAME\install\Packages\Microsoft\SCCM Console\2007 SP2\R019_App-V

SCCM Software Deployment – Application Deployment Wizard

May 18, 2010 6 comments
***Critical Note***  This is to be used this at your own risk and this is not a supported solution.  This includes a framework to provide a solution – you as the IT Professional are responsible for making the appropriate changes to the script and determining any deployment methods if any.
.
.
.
Source (not sure if this will work – .zip in a .docx so I can upload it):
 
Background:
 
The one thing I have learned with SMS/SCCM over the years is that it is not always easy to keep everybody happy when deploying software.  Some people want silent installs while others want to see when it installs with a progress bar and the End-Users want the autonomy to postpone the install if desired.  Now of course you can use the Task Sequencer in SCCM 2007 to do the install to get the progress bar but the End-User cannot postpone the install and the bigger issue presents itself if you need to have the package cached (I do not think there is an option to do this with TS still).
 
Bottom line – we had IT and business users with different ideas of how software deployments should work.
 
My boss worked at a company that used SMS 2003 and had all of their software installs run through a process the leveraged a VBScript to install the software combined with the SMS client and the user was prompted for the install.  Their version of the used .txt files and some registry values from what I understand.  The logic behind this is the SMS advertisement is mandatory and set to run every day at a certain time so the script always runs.  With proper code it never really makes an impact on the client unless the software needs to be installed as it will determine from a registry lookup if the software is installed or not (the registry key is written as part of the install process).  The reason to have this run every day is as follows:
 
  • The script can run to check if the software was installed or if the user was prompted and postponed the install
  • Reinstallation can be accomplished by removing a registry entry and having the same advertisement for the install

Of course over time the advertisement would be changed so it was not running every day…

Anyway, this is how this idea came about and why I developed this.

Solution:
Of course the aforementioned solution sounded good from a high-level but I had to put my own spin on it.  I get the user autonomy and what they were trying to accomplish but it was lacking something more…like corporate branding.  When I was at MMS in 2009 Microsoft discussed how they have found in studies that End-Users tend to have a more positive reaction to installations that have a company logo and will be more inclined to pay attention.  Let’s face it…we tell our customers to be concerned if something runs and they do not know what it is.

The installation writes to the registry.  Specifically “HKEY_LOCAL_MACHINESOFTWARECOMPANYNAME_SoftwarestrAppName”.  This is where the script references before the user would ever see anything.  It checks if we wrote a key to tell it that it is installed.  If that does not exist it does a WMI query to see if it was installed by another means.  If it finds it installed it will write to the registry to note that it is installed and stop.  If it does not find it installed the HTA fires up (of course only if a user is logged in – if nobody is logged in it will install without any prompts).

ApplicationDeploymentWizard_User

ApplicationDeploymentWizard_Reg

The key here is when you publish this to SMS or SCCM it needs to run with administrative rights but you need to check the box to allow the user to interact with the program (a big thank you to Sherry Kissinger for helping me with that mental hurdle a while back – sometimes things are too simple).

Directory Structure:

  • ImagesCOMPANYLOGO.GIG
  • Imageswinicon.ico
  • Source*SETUPFILES* (this is for the setup files)
  • ExecuteSoftwareDeployment.vbs
  • ExecuteSoftwareRemoval.vbs
  • InstallDetails.ini
  • RemovalDetails.ini
  • SoftwareDeployment.HTA

INI Files (How much easier could this be?):

One of the things I love about this one is I developed it to use two .ini files to read from – AKA you do not need to edit the VBScript or the HTA once you do the customizations I mention below.  It is a real speedy process to use this for all software distributions and the best thing is not everybody needs to understand VBScript to use this.  Please note that the commas separate the values and if there is a quote after the .msi it needs to be there.

InstallDetails.ini

SoftwareTitle, Commandline, Transform (if there is not a tranform then put N/A)

Copy and paste the single line below into the .ini file…
—————————————————————————————–
Adobe Reader 9.3,acroread.msi” /qb!,QBEReader9.mst
—————————————————————————————–

RemoveDetails.ini

SoftwareTitle, Commandline (I only have this working for removing .MSI installs right now)

Copy and paste the single line below into the .ini file…
—————————————————————————————–
Adobe Reader 9.3,Acroread.msi”
—————————————————————————————–

VBScript Files

ExecuteSoftwareDeployment.vbs (change “COMPANY_Software” where “COMPANY is your company name)

‘————————————————–

‘————————————————–
‘Execute Software Deployment
‘Written by Josh Mueller
‘created January 14, 2010
‘updates
‘n/a
‘————————————————–

option explicit

‘————————————————–
‘Set Variables
‘————————————————–

Dim strIniFile, strKeyPath, strValuePrompt, strFullPromptKey, strValueInstall, strFullInstallKey
Dim strAppName, objNetwork, objFSO, objShell, colComputer, objWMIService, objSoftware, strInstallCommand
Dim objRegistry, strComputer, strPromptValue, strInstallValue, colSoftware, strRegKey, strTransform
Dim objTextFile, strNextLine, arrApplication, i, strCurrentDir, strInputFile, objFileHandle, strDirectory
Dim objEnv, strVar1, strVar2, strVar3, strVar4, strVar5, strCommandline, objComputer, strLogonUser, strFileName, objFolder

‘Constants used in opening files.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const HKEY_LOCAL_MACHINE = &H80000002
Const TristateFalse = 0

strComputer = “.”
strCurrentDir = Replace(WScript.ScriptFullName, WScript.ScriptName, “”)
strIniFile = “InstallDetails.ini”
strInputFile = strcurrentdir & strIniFile
strDirectory = “c:Logs”

Set objNetwork = CreateObject(“Wscript.Network”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objShell = createObject(“wscript.shell”)
Set objEnv = objShell.Environment(“User”)
Set objRegistry = GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & strComputer & “rootdefault:StdRegProv”)
Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!\” _
    & strComputer & “rootcimv2”)
Set colSoftware = objWMIService.ExecQuery _
    (“Select * from Win32_Product”)
Set colComputer = objWMIService.ExecQuery (“Select * from Win32_ComputerSystem”)

‘————————————————–
‘Create Logs Folder if it does not exist
‘————————————————–

If objFSO.FolderExists (strDirectory) Then

‘WScript.Echo “No need to create ” & strDirectory
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
‘WScript.Echo “Created ” & strDirectory
End If

‘————————————————–
‘Body
‘————————————————–

Set objTextFile = objFSO.OpenTextFile (strInputFile, ForReading)
Do Until objTextFile.AtEndOfStream

strNextLine = objTextFile.Readline
arrApplication = Split(strNextLine , “,”)
  strAppName = arrApplication(0)
  ‘Wscript.Echo “Application Name: ” & strAppName
  strCommandline = arrApplication(1)
  ‘Wscript.Echo “Commandline: ” & arrApplication(1)
  strTransform = arrApplication(2)
  ‘Wscript.Echo “Transform: ” & arrApplication(2)

Loop

objTextFile.Close

‘————————————————–
strKeyPath = “SoftwareCOMPANYNAME_Software” & strAppName & “”
strValuePrompt = “InstallPrompt”
strFullPromptKey = “HKEY_LOCAL_MACHINE” & strKeyPath & strValuePrompt
strValueInstall = “InstallCode”
strFullInstallKey = “HKEY_LOCAL_MACHINE” & strKeyPath & strValueInstall

objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath, strValuePrompt, strPromptValue
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath, strValueInstall , strInstallValue
‘————————————————–

If strInstallValue = 1 Then
‘Wscript.echo “The product is installed”
objEnv(“var2”) = strAppName
strFileName = “c:Logs” & strAppName & “.txt”

Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
  objTextFile.WriteLine(“————————————————–“)
  objTextFile.WriteLine Now
  objTextFile.WriteLine strAppName  & ” is already installed. ”
  objTextFile.WriteLine(“————————————————–“)
objTextFile.Close

objEnv(“var2”) = “”
 
wscript.quit
Else
CheckInstalledApps
objEnv(“var2”) = strAppName
objEnv(“var3”) = strCommandline
objEnv(“var4”) = strTransform
strVar2 = objEnv(“var2”)
strVar3 = objEnv(“var3”)
strVar4 = objEnv(“var4”)

If strVar4 = “N/A” Then
  strInstallCommand = chr(34) & strCurrentDir & “Source” & strVar3
Else
  strInstallCommand = chr(34) & strCurrentDir & “Source” & strVar3 & ” TRANSFORMS=” & chr(34) & strCurrentDir & “Source” & strVar4 & chr(34)
End if

objEnv(“var5”) = strInstallCommand
strVar5 = objEnv(“var5”)
strFileName = “c:Logs” & strAppName & “.txt”
Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
  objTextFile.WriteLine(“————————————————–“)
  objTextFile.WriteLine Now
  objTextFile.WriteLine strAppName  & ” is not installed. ”
objTextFile.Close
For Each objComputer in colComputer
  IF not objComputer.UserName = “” Then
   If strPromptValue = 1 Then
    ‘wscript.echo “prompted once”
    objEnv(“var1”) = strPromptValue
    strVar1 = objEnv(“var1”)
    CHECKOS
    GETFREESPACE
    USERDEVICE
    Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
     objTextFile.WriteLine “The End-User has been prompted only once.”
     objTextFile.WriteLine “Launching the HTA at ” & Now & “.”
    objTextFile.Close
    objShell.RegWrite strFullPromptKey, 2
    strPromptValue = “2”
    ObjShell.Run (chr(34) & strCurrentDir & “SoftwareDeployment.HTA” & chr(34))
    Set objShell = Nothing
    Set objEnv = Nothing
   Else  
    If strPromptValue = 2 Then 
     ‘wscript.echo “force install”
     objEnv(“var1”) = strPromptValue
     strVar1 = objEnv(“var1”)
     CHECKOS
     GETFREESPACE
     USERDEVICE
     Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
      objTextFile.WriteLine “The End-User has been prompted twice.”
      objTextFile.WriteLine “Launching the HTA at ” & Now & “.”
     objTextFile.Close
     ObjShell.Run (chr(34) & strCurrentDir & “SoftwareDeployment.HTA” & chr(34))
     Set objShell = Nothing
     Set objEnv = Nothing
    Else
     ‘wscript.echo “never prompted”
     objEnv(“var1”) = 1
     strVar1 = objEnv(“var1”)
     CHECKOS
     GETFREESPACE
     USERDEVICE
     Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
      objTextFile.WriteLine “The End-User has never been prompted.”
      objTextFile.WriteLine “Launching the HTA at ” & Now & “.”
     objTextFile.Close
     objShell.RegWrite strFullPromptKey, 1
     ObjShell.Run (chr(34) & strCurrentDir & “SoftwareDeployment.HTA” & chr(34))
     Set objShell = Nothing
     Set objEnv = Nothing
    End if
   End if
  Else
   ObjShell.Run strInstallCommand
   wscript.quit

  End if
Next
End if

‘————————————————–
‘Check Installed Apps
‘————————————————–
Sub CheckInstalledApps

For Each objSoftware in colSoftware
If objSoftware.Name = strAppName Then
  objShell.RegWrite strFullInstallKey, 1
  wscript.quit
End If
Next

End Sub

‘————————————————–
‘Check the OS Version
‘————————————————–
SUB CHECKOS

Dim strOSkey, strOSproductname

strOSkey = “HKEY_LOCAL_MACHINESoftwareMicrosoftWindows NTCurrentVersionproductname”
strOSproductname = objshell.regread (strOSkey)

Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
objTextFile.WriteLine “The current Operating System is ” & strOSproductname & “.”
objTextFile.Close

END SUB

‘————————————————–
‘Logged on user and current domain
‘————————————————–
SUB USERDEVICE

For Each objComputer in colComputer
IF not objComputer.UserName = “” Then
  strLogonUser = Split(objComputer.UserName,””)
  strLogonUser(1) = UCase(Left(strLogonUser(1),1)) & Trim(Mid(strLogonUser(1),2,20))

  Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
   objTextFile.WriteLine strLogonUser(1) & ” is logged on.”
   objTextFile.WriteLine objNetwork.ComputerName & ” is the device name.”
   objTextFile.WriteLine objNetwork.UserDomain & ” is the user domain.”
  objTextFile.Close
END IF
Next

END SUB

‘————————————————–
‘Get Free Space Sub
‘————————————————–
SUB GETFREESPACE

Dim coldisks, objDisk, intFreeSpace, intTotalSpace, pctFreeSpace

Set colDisks = objWMIService.ExecQuery (“Select * from Win32_LogicalDisk Where DeviceID = ‘C:'”)

For Each objDisk in colDisks
     intFreeSpace = objDisk.FreeSpace
     intTotalSpace = objDisk.Size
     pctFreeSpace = intFreeSpace / intTotalSpace
Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
  objTextFile.WriteLine “The percentage of free space on C: is ” & FormatPercent(pctFreeSpace) & “.”
objTextFile.Close 
Next

END SUB

‘————————————————–

ExecuteSoftwareRemoval.vbs (change “COMPANY_Software” where “COMPANY is your company name)

‘————————————————–

‘————————————————–
‘Execute Software Deployment
‘Written by Josh Mueller
‘created January 14, 2010
‘updates
‘n/a
‘————————————————–

option explicit

‘————————————————–
‘Set Variables
‘————————————————–

Dim strIniFile, strKeyPath, strValueInstall, strFullInstallKey
Dim strAppName, objNetwork, objFSO, objShell, colComputer, objWMIService, objSoftware, strRemovalCommand
Dim objRegistry, strComputer, strInstallValue, colSoftware, strRegKey
Dim objTextFile, strNextLine, arrApplication, i, strCurrentDir, strInputFile, objFileHandle
Dim objEnv, strCommandline, objComputer, Returncode

‘Constants used in opening files.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const HKEY_LOCAL_MACHINE = &H80000002
Const TristateFalse = 0

strComputer = “.”
strCurrentDir = Replace(WScript.ScriptFullName, WScript.ScriptName, “”)
strIniFile = “RemovalDetails.ini”
strInputFile = strcurrentdir & strIniFile

Set objNetwork = CreateObject(“Wscript.Network”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objShell = createObject(“wscript.shell”)
Set objEnv = objShell.Environment(“User”)
Set objRegistry = GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & strComputer & “rootdefault:StdRegProv”)
Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!\” _
    & strComputer & “rootcimv2”)
Set colSoftware = objWMIService.ExecQuery _
    (“Select * from Win32_Product”)
Set colComputer = objWMIService.ExecQuery (“Select * from Win32_ComputerSystem”)

‘————————————————–
‘Body
‘————————————————–
Set objTextFile = objFSO.OpenTextFile (strInputFile, ForReading)
Do Until objTextFile.AtEndOfStream

strNextLine = objTextFile.Readline
arrApplication = Split(strNextLine , “,”)
For Each strNextLine in arrApplication
  strAppName = arrApplication(0)
  ‘Wscript.Echo “Application Name: ” & arrApplication(0)
  strCommandline = arrApplication(1)
  ‘Wscript.Echo “Commandline: ” & arrApplication(1)
Next

Loop

objTextFile.Close

‘————————————————–
strKeyPath = “SoftwareCOMPANYNAME_Software” & strAppName & “”
strValueInstall = “InstallCode”
strFullInstallKey = “HKEY_LOCAL_MACHINE” & strKeyPath & strValueInstall
‘————————————————–

strRemovalCommand = “C:WindowsSystem32msiexec.exe /x ” & chr(34) & strCurrentDir & “Source” & strCommandline
‘msgbox strRemovalCommand
Returncode = objShell.Run(strRemovalCommand,, True)
objShell.RegWrite strFullInstallKey, 0

If Returncode = 1602 Then
msgbox “You chose not to remove ” & strAppName & “.”
wscript.quit
Else
If Returncode = 1605 Then
  msgbox strAppName & ” is not installed.”
  wscript.quit
Else
  msgbox strAppName & ” returned a code of ” & returncode & “.  You will now be prompted to reboot…”
  objShell.Run(“shutdown -r -f -t 30”), 1, TRUE
End if
End if

‘————————————————–

HTA File

SoftwareDeployment.HTA (Change “COMPANYLOGO.gif”, “DEPARTMENT”, and “COMPANY NAME”)

‘————————————————–

<script language=”vbscript”>

‘————————————————–
‘ Global Variables
‘————————————————–
Dim strComputer, strAppName, objFSO, objShell, objWMIService, colComputer, objRegistry, objNetwork
Dim strCurrentDir, strHost, strInstallCommand, strDirectory, strFileName
Dim strFullPromptKey, strValuePrompt, strKeyPath, strPromptValue, strInstallValue, strRegKey, strPromptScript
Dim strVBSFile, strVar1, objEnv, strVar2, strVar3, strVar5
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const adOpenStatic1 = 3
Const adLockOptimistic1 = 3
const HKEY_LOCAL_MACHINE = &H80000002

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objShell = CreateObject(“WScript.Shell”)
Set objEnv = objShell.Environment(“User”)

strComputer = “.”
strPath = left(location.pathname,InStrRev(location.pathname,””))
strHost = Location.HostName
strCurrentDir = objShell.CurrentDirectory
strDirectory = “c:Logs”

Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\” & strComputer & “rootcimv2”)
Set colComputer = objWMIService.ExecQuery (“Select * from Win32_ComputerSystem”)
Set objRegistry = GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & strComputer & “rootdefault:StdRegProv”)

‘————————————————–
‘ End of Global Variables
‘————————————————–

‘——————————————————————-
‘ Onload_Window
‘——————————————————————-
Sub Onload_Window

Window.resizeTo 300,300
window.moveTo (screen.width-300) ,(screen.height – 300)

strVar1 = objEnv(“var1”)
strVar2 = objEnv(“var2”)
strVar3 = objEnv(“var3”)
strVar4 = objEnv(“var4”)
strVar5 = objEnv(“var5”)
‘msgbox strVar1
‘msgbox strVar2
‘msgbox strVar3
‘msgbox strVar4

strFileName = “c:Logs” & strVar2 & “.txt”

If strVar4 = “N/A” Then
If strHost = “” Then
  strInstallCommand = chr(34) & strHost & strPath & “Source” & strVar3
Else
  strInstallCommand = chr(34) & “\” & strHost & strPath & “Source” & strVar3
End if
Else
If strHost = “” Then
  strInstallCommand = chr(34) & strHost & strPath & “Source” & strVar3 & ” TRANSFORMS=” & chr(34) & strHost & strPath & “Source” & strVar4 & chr(34)
Else
  strInstallCommand = chr(34) & “\” & strHost & strPath & “Source” & strVar3 & ” TRANSFORMS=” & chr(34) & “\” & strHost & strPath & “Source” & strVar4 & chr(34)
End if

End if

‘msgbox strInstallCommand

strKeyPath = “SoftwareCOMPANYNAME_Software” & strVar2 & “”
strValueInstall = “InstallCode”
strFullInstallKey = “HKEY_LOCAL_MACHINE” & strKeyPath & strValueInstall

If strVar1 = 1 Then
intAnswer = Msgbox(“Is now a good time to install ” & strVar2 & “?  If you are answering yes please take the time to close all other applications.”, vbYesNo  + vbSystemModal + vbQuestion, “Install Software”)
  If intAnswer = vbYes Then
   Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
    objTextFile.WriteLine “The End-User chose to start the installation now.”
   objTextFile.Close
   SoftwareInstall
  Else
   Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
    objTextFile.WriteLine “The End-User chose to postpone the installation.”
   objTextFile.Close
   SetPrompt
  End If
Else
If strVar1 = 2 Then
  intAnswer = Msgbox(strVar2 & ” is about to install.  Please take the time to close all other applications and click OK.”, vbSystemModal + vbInformation + vbOKOnly, “Install Software”)
  Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
   objTextFile.WriteLine “The End-User has to do a mandatory installation.”
  objTextFile.Close
  SoftwareInstall
End if
End if

End Sub

‘——————————————————————-
‘ SoftwareInstall
‘——————————————————————-
Sub SoftwareInstall

Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
objTextFile.WriteLine “The installation is about to start at ” & Now & “.”
objTextFile.WriteLine “The command line is ” & strVar5
objTextFile.Close

ReturnCode = objShell.Run(strVar5,, True)
‘msgbox ReturnCode

Set objTextFile = objFSO.OpenTextFile (strFileName, ForAppending, True)
objTextFile.WriteLine “The installation has completed at ” & Now & “.”
objTextFile.writeline “Return Code of: ” & ReturnCode
objTextFile.WriteLine(“————————————————–“)
objTextFile.Close

If ReturnCode = 0 Then
Msgbox “Thank you for your time!  ” & strVar2 & ” is now installed.”, vbSystemModal + vbInformation + vbOKOnly, “Software Installed”
Else
If ReturnCode = 3010 Then
  msgbox “The installation requires a reboot.  Please reboot at your earliest convenience.”, vbSystemModal + vbCritical + vbOKOnly, “Reboot Required”
Else
  If ReturnCode = 1641 Then
   Window.close
  Else
   msgbox “The installation failed with a value of ” & ReturnCode & “.  Please contact the Service Desk with this information for assistance.”, vbSystemModal + vbCritical + vbOKOnly, “Software Error”
  End if
End if
End if

objEnv(“var1”) = “”
objEnv(“var2”) = “”
objEnv(“var3”) = “”
objEnv(“var4”) = “”
objEnv(“var5”) = “”

window.Close

End Sub

‘——————————————————————-
‘ CheckPrompt
‘——————————————————————-
Sub SetPrompt

Msgbox “You have postponed the install.  This will run again tomorrow, or the next day your device is on the corporate network.  The next time you see this you will be required to install ” & strVar2 & “.”, vbSystemModal + vbInformation + vbOKOnly, “Software Install Postpone”
Window.close

End Sub

–>
</script>

<html>
<head>

<title>Software Deployment Wizard</title>

<HTA:APPLICATION ID=”HTA1″ APPLICATIONNAME=”SoftwareDeploymentWizardHTA” ICON=”imageswinicon.ico”
  BORDER=”thin”
  BORDERSTYLE=”normal”
  CAPTION=”yes”
  INNERBORDER=”no”
  SELECTION=”no”
  MAXIMIZEBUTTON=”no”
  MINIMIZEBUTTON=”no”
  SHOWINTASKBAR=”no”
  SINGLEINSTANCE=”yes”
  SYSMENU=”no”
  VERSION=”1.0″ /> 
 
</head>

<body onload=Onload_Window>

<p><td><center><img src=”imagesCOMPANYNAME.gif” hspace=5 vspace=5></center></td></p>

<p><td><center><b><font face=”Arial” size=”4″>DEPARTMENT</font></b></center></td></p>

</body>
</html>

‘————————————————–

Refresh all Packages on a SCCM DP

February 26, 2010 4 comments
I used this successfully in an environment with a primary and multiple secondaries.  Below are the instructions how it works and a few things that you will likely want to change to customize it.
 
Overview:
This is to be saved as a HTA file.  There are 3 fields for you to fill in:
 
  • SCCM Primary Site Code
  • SCCM Primary Server Name
  • SCCM Site Code (to Refresh)

These variables get passed to enable the connection to the primary and ultimatly the DP refresh.  The "SCCM Site Code" is the code for the site you wish to refresh.  For example if your primary is ABC and a secondary is 123 – ABC is the "SCCM Primary Site Code" and 123 would be the "SCCM Site Code".  If 123 has multiple DP’s in the infrastructure design all of them will have their packages refreshed.

Customizations:
  • Replace LOGO.gif with your company’s logo
  • I use an images folder for LOGO.gif and winicon.ico

HTA CODE:

<Script language="VBScript">
‘————————————————–
‘ Variables
‘————————————————–
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
‘——————————————————————-
‘ Onload_Window
‘——————————————————————-
Sub Onload_Window
 Window.resizeTo 500,275
 window.moveTo (screen.width -900) ,(screen.height -900)
End Sub
‘——————————————————————-
‘ Refresh
‘——————————————————————-
Sub Refresh
 
Dim strSiteName , strServerName, strPrimaryCode
 
strPrimaryCode = PrimaryCode.Value
strSiteCode = SiteCode.Value
strPrimaryServerName = PrimaryServer.Value
 
Set loc = CreateObject("WbemScripting.SWbemLocator")
Dim WbemServices
 
Set WbemServices = loc.ConnectServer(strPrimaryServerName, "rootSMSsite_" & strPrimaryCode)
 
Set DPs = wbemServices.ExecQuery("Select * From SMS_DistributionPoint WHERE SiteCode=’" & strSiteCode & "’")
For Each DP In DPs
   DP.RefreshNow = True
   DP.Put_
Next
 
Msgbox "DP packages have been refreshed for " & strSiteCode & "."
 
Window.close
 
End Sub
 
</Script>
<HTML>
<HEAD>
<title>SCCM DP Refresh</title>
<HTA:APPLICATION ID="HTA1" APPLICATIONNAME="SCCMDPRefresh" ICON="imageswinicon.ico"
  BORDER="thin"
  BORDERSTYLE="normal"
  CAPTION="yes"
  INNERBORDER="no"
  SELECTION="no"
  MAXIMIZEBUTTON="no"
  MINIMIZEBUTTON="no"
  SHOWINTASKBAR="Yes"
  SINGLEINSTANCE="yes"
  SYSMENU="Yes"
  VERSION="1.0" /> 
 
</HEAD>
<BODY onload=Onload_Window>
<p><td><center><img src="imagesLOGO.gif" hspace=5 vspace=5></center></td></p>
<table style="width: 100%" class="bodyText">
 <tr>
  <td style="width: 300px"><strong>SCCM Primary Site Code:</strong></td>
  <td><span id="PrimaryCodeText"></span>       
    <input name="PrimaryCode" type="text" style="width: 150px"> 
  </td>
 </tr>
 <tr>
  <td style="width: 300px"><strong>SCCM Primary Server Name:</strong></td>
  <td><span id="PrimaryServerText"></span>       
   <input name="PrimaryServer" type="text" style="width: 150px"> 
  </td>
 </tr>
 <tr>
  <td style="width: 300px"><strong>SCCM Site Code (to Refresh):</strong></td>
  <td><span id="SiteCodeText"></span>       
   <input name="SiteCode" type="text" style="width: 150px"> 
  </td>
 </tr>
</table>
<td><center><input id=runbutton  type="button" value="Refresh Packages" name="run_button"  onClick="Refresh"></center></td>
</BODY>
</HTML>

SCCM Software Deployment – Updated Application Deployment Wizard

February 2, 2010 2 comments
I have updated my Application Deployment Wizard.  It now has logging capabilities (C:Logs\APPNAME.txt) and does a little better with the system environmental variables.
 
%d bloggers like this: