Mark Minasi's Reader Forum
Mark Minasi's Reader Forum
Home | Profile | Register | Active Topics | Active Polls | Members | Search | FAQ | Minasi Forum RSS Feed
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 HALP! Questions on Windows and Windows Server
 Deployment: Windows and apps
 DISM at Startup?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sixdoubleo
Major Contributor

USA
859 Posts
Status: offline

Posted - 10/05/2011 :  12:22:49 PM  Show Profile  Click to see sixdoubleo's MSN Messenger address  Send sixdoubleo a Yahoo! Message  Reply with Quote
I'm trying to enable some RSAT features from a startup script. Everything works interactively, but not within the context of system startup. I'm wondering if DISM leverages some Windows facility that isn't started yet.

I'll go ahead and post my whole script, but the DISM part is highlighted in red.




' Install RSAT and add features with DISM
' 9-27-2011 - D. Akins
' ------------------------------------------------------------------------------
Option Explicit

Dim objShell, strScriptDir, strCmd, q, nBits, objFSO, strAdminToolsPath
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objShell = CreateObject("WScript.Shell")

' This gets the directory that the script resides in
strScriptDir = objFSO.GetParentFolderName(WScript.ScriptFullName)

q = chr(34)

' Launch WUSA with correct MSU update file for OS architecture
nBits = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth
If nBits = 64 Then
   strCmd = "wusa " & strScriptDir & "\Windows6.1-KB958830-x64-RefreshPkg.msu /quiet /norestart"
Else
   strCmd = "wusa " & strScriptDir & "\Windows6.1-KB958830-x86-RefreshPkg.msu /quiet /norestart"
End If

'wscript.echo "Launching Command: [" &  strcommandline & "]"
objShell.Run strCmd,1,True


' Add RSAT features (same as Control Panel, Programs and Features)
strCmd = "dism /online /quiet /enable-feature /featurename:RemoteServerAdministrationTools " _
		& "/featurename:RemoteServerAdministrationTools-Roles " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-DS " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-DS-SnapIns " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-Powershell " _
		& "/featurename:RemoteServerAdministrationTools-Features " _ 
		& "/featurename:RemoteServerAdministrationTools-Features-BitLocker"
WScript.Echo "Command: [" & strCmd & "]"
objShell.Run strCmd,1,True


' Delete AD-related shortcuts from Administrative Tools Start Menu
strAdminToolsPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools"
DelIfExist(strAdminToolsPath & "\Active Directory Administrative Center.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Domains and Trusts.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Module for Windows PowerShell.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Sites and Services.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Users and Computers.lnk")
DelIfExist(strAdminToolsPath & "\ADSI Edit.lnk")

Function DelIfExist(strFile)
   Dim objFSO
   Set objFSO = CreateObject("Scripting.FileSystemObject") 
   If objFSO.FileExists(strFile) Then
      objFSO.DeleteFile(strFile)
   End If
End Function

sixdoubleo
Major Contributor

USA
859 Posts
Status: offline

Posted - 06/05/2012 :  8:32:19 PM  Show Profile  Click to see sixdoubleo's MSN Messenger address  Send sixdoubleo a Yahoo! Message  Reply with Quote
I finally figured this out and thought I'd supply the solution here. If any of you are trying to do similar things with DISM from SCCM you are likely running into the same problem.

The problem is that these processes are running in a WOW64 session and therefore launch the 32-bit version of DISM (from %windir%\system32). If you are operating on a 64-bit OS you'll receive an error indicating that the 32-bit version of DISM cannot service a 64-bit OS (which you aren't seeing because it's running silent).

The solution is to deliberately launch the 64-bit DISM from the SysNative folder (which only exists as a junction within a WOW64 session).

I imagine the new version of SCCM 2012 will get around this issue as I believe it has a 64-bit agent. Nonetheless, if you're running some other deployment tool that launches as a 32-bit process this is how to get around it. I actually discovered this while troubleshooting a similar issue with pkgmgr.exe, which behaves the same as dism in this respect.

Modified code below:


' Install RSAT and add features with DISM
' 6-4-2012 - D. Akins
' ------------------------------------------------------------------------------
Option Explicit

Dim objShell, strScriptDir, strCmd, q, nBits, objFSO, strAdminToolsPath, strDismEXE
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objShell = CreateObject("WScript.Shell")

' This gets the directory that the script resides in
strScriptDir = objFSO.GetParentFolderName(WScript.ScriptFullName)

q = chr(34)

' Launch WUSA with correct MSU update file for OS architecture
nBits = GetObject("winmgmts:root\cimv2:Win32_Processor='cpu0'").AddressWidth
If nBits = 64 Then
   strCmd = "wusa " & strScriptDir & "\Windows6.1-KB958830-x64-RefreshPkg.msu /quiet /norestart"
Else
   strCmd = "wusa " & strScriptDir & "\Windows6.1-KB958830-x86-RefreshPkg.msu /quiet /norestart"
End If

'wscript.echo "Launching Command: [" &  strcommandline & "]"
objShell.Run strCmd,1,True

' Add RSAT features (same as Control Panel, Programs and Features)
If nBits = 64 Then
   strDismEXE = "C:\Windows\SysNative\dism"
Else
   strDismEXE = "C:\Windows\System32\dism"
End If

strCmd = strDismEXE & " /online /quiet /enable-feature /featurename:RemoteServerAdministrationTools " _
		& "/featurename:RemoteServerAdministrationTools-Roles " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-DS " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-DS-SnapIns " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter " _
		& "/featurename:RemoteServerAdministrationTools-Roles-AD-Powershell " _
		& "/featurename:RemoteServerAdministrationTools-Features " _ 
		& "/featurename:RemoteServerAdministrationTools-Features-BitLocker"
'WScript.Echo "Command: [" & strCmd & "]"
objShell.Run strCmd,1,True


' Delete AD-related shortcuts from Administrative Tools Start Menu
strAdminToolsPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools"
DelIfExist(strAdminToolsPath & "\Active Directory Administrative Center.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Domains and Trusts.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Module for Windows PowerShell.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Sites and Services.lnk")
DelIfExist(strAdminToolsPath & "\Active Directory Users and Computers.lnk")
DelIfExist(strAdminToolsPath & "\ADSI Edit.lnk")

Function DelIfExist(strFile)
   Dim objFSO
   Set objFSO = CreateObject("Scripting.FileSystemObject") 
   If objFSO.FileExists(strFile) Then
      objFSO.DeleteFile(strFile)
   End If
End Function
Go to Top of Page

arwidmark
Old Timer

Sweden
530 Posts
Status: offline

Posted - 06/06/2012 :  04:24:15 AM  Show Profile  Visit arwidmark's Homepage  Reply with Quote
Thanks for posting back the solution... Another fix is selecting the "Disable 64-bit file system redirection" check box in the "Run Command Line" action.

/ Johan

Regards

Johan Arwidmark
Microsoft MVP - Setup / Deployment
http://www.deploymentresearch.com
http://www.facebook.com/DeploymentResearch
Twitter: @jarwidmark
Go to Top of Page

sixdoubleo
Major Contributor

USA
859 Posts
Status: offline

Posted - 06/07/2012 :  11:58:29 AM  Show Profile  Click to see sixdoubleo's MSN Messenger address  Send sixdoubleo a Yahoo! Message  Reply with Quote
quote:
Originally posted by arwidmark

Thanks for posting back the solution... Another fix is selecting the "Disable 64-bit file system redirection" check box in the "Run Command Line" action.

/ Johan



I'm actually not using SCCM....was just speculating that SCCM likely would have the same problem given that it's agent is 32-bit....but good to know, thank you!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Mark Minasi's Reader Forum © 2002-2011 Mark Minasi Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000