This project is read-only.

Dynamic dism.exe check?

Mar 23, 2011 at 2:42 PM

I foremost want to say this rocks and thanks for the time developing it.  I have some suggestions for the script since not everyone installs into C: or the default program directory.  Also if you are running Windows 7 or 2008R2  I believe Dism is already included and in the %systemroot%\system32 or syswow64 depending on version.

 I would think that you could do something like the following:

$osversion = Get-WmiObject Win32_OperatingSystem -property 'version'

If([Regex]::IsMatch($osversion.version,'6.1')) {write-host "windows 7/2008R2"

if($env:processor_Architecture -eq 'AMD64') {

If((test-path -path ($env:windir + '\SysWow64\dism.exe')) -eq $true) {$dismpath = ($env:windir + '\SysWow64\dism.exe');write-host $dismpath}

} Else {

if((test-path -path $env:windir'\System32\dism.exe') -eq $true) {$dismpath = $env:windir + '\System32\dism.exe'} # end system32 check      

} # close test-path if state syswow64

write-host dism.ex in $dismpath

}else{

$dismLOC = get-childitem $ENV:PROGRAMFILES\* -include dism.exe -recurse #searches program files as defined by env variable
foreach($item in $dismloc) { $temppath = $item.pspath #walks through collection
$dismLocpath = $temppath.replace("Microsoft.PowerShell.Core\FileSystem::","") #cleans up path returned by PS cause i don't know any better
 

if([Regex]::IsMatch($dismLocpath,$env:processor_Architecture)) {$dismpath=$dismLocpath} #checks proc arch matches path found
} else {  
Write-host dism.exe not found...  exit.  # Couldn't find it in any place

<add code to prompt for path to dism>


}# end foreach dimloc

} #OS