App Development Help

Page 2 of 4 FirstFirst 1234 LastLast

  1. Posts : 3,453
       #11

    You're welcome...

    I haven't tested in PE yet - the Enterprise story is a known registry bug with Pro.

    I will look into this a bit later....
      My Computer


  2. Posts : 3,453
       #12

    Yup, Edition is a problem in PE - is that required? Without it we can do this:

    Code:
    if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
    
    
    $WinPEDrive = 'C'  # Note: Change to $WinPEDrive = 'X' if running this script in WinPE
    
    
    $WinPEProduct = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty ProductName
    
    
    $WinPEArch = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty BuildLabEx
    
    
    $WinPECurrentVersion =  Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty CurrentVersion
    
    
    if ($WinPEArch.Split(".") -contains 'x86fre') {$WinPEArch = $true} else {$WinPEArch = $false}
    
    
    $Drives = Get-PSDrive -PSProvider FileSystem | Select-Object Name, Root | Where-Object {$_.Name -notcontains $WinPEDrive}
    
    
    foreach ($Drive in $Drives)
    {
        $HivePath = Join-Path($Drive.Root) -ChildPath "Windows\System32\config\SOFTWARE"
       
        if (Test-Path($HivePath))
        {
            Reg.exe Load 'HKLM\TempHive' $HivePath | Out-Null
            $ProductName = Get-ItemProperty -Path 'HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty ProductName
            $BuildLabEx = Get-ItemProperty -Path 'HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty BuildLabEx
            $CurrentVersion =  Get-ItemProperty -Path 'HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty CurrentVersion
            Reg.exe Unload 'HKLM\TempHive'| Out-Null
        
            if ($BuildLabEx.Split(".") -contains 'x86fre') {$Arch = $true} else {$Arch = $false}
    
    
            #If a Matching OS and Arch are found then export and integrate drivers
            if ($WinPECurrentVersion -eq $CurrentVersion -and $WinPEArch -eq $Arch){
                
                Write-Host "Export drivers from " $HivePath.Replace("config\SOFTWARE", "Drivers")
                } 
            else {   
                
                Write-Host "No drivers to export "
            }
        }
    }
    
    
    Write-Host "Done"
    
    
    Read-Host
    Last edited by Superfly; 03 Jul 2019 at 03:01.
      My Computer


  3. Posts : 4,131
    Windows 3.1 to Windows 11
    Thread Starter
       #13

    you still up too.....

    Just need Windows 10 / 8.1 and arch

    Hello SIW2

    I'll test tomorrow - if not i'll be all night over night
      My Computer


  4. Posts : 3,453
       #14

    Kyhi said:
    you still up too.....

    Just need Windows 10 / 8.1 and arch

    Hello SIW2

    I'll test tomorrow - if not i'll be all night over night
    Cool .. I made the same copy-paste mistake before posting the last script - I really should version these things. LOL
      My Computer


  5. Posts : 4,131
    Windows 3.1 to Windows 11
    Thread Starter
       #15

    if WinPE = Windows 10 and Host OS = Windows 10 then Set, True
      My Computer


  6. Posts : 4,131
    Windows 3.1 to Windows 11
    Thread Starter
       #16

    It is finding Drive by Arch in WinPE and Host..
    Now can you have it list those "Found" drives By Windows Edition

    Then Ask which $Drive - $Edition "do you want to export drivers from"

    because eventually we will need just the $DriveLetter for our Dism command

    dism /Image:$DriveLetter :\ /Export-Driver /Destination:"%UserProfile%\Desktop\ExportedDrivers"

    I assumed $DriveLetter = single digit

    Else

    dism /Image:$DriveLetter /Export-Driver /Destination:"%UserProfile%\Desktop\ExportedDrivers"

    PS I can test Export if you can add to script
      My Computer


  7. Posts : 3,453
       #17

    Kyhi said:
    It is finding Drive by Arch in WinPE and Host.. Now can you have it list those "Found" drives By Windows Edition Then Ask which $Drive - $Edition "do you want to export drivers from" because eventually we will need just the $DriveLetter for our Dism command dism /Image:$DriveLetter :\ /Export-Driver /Destination:"%UserProfile%\Desktop\ExportedDrivers" I assumed $DriveLetter = single digit Else dism /Image:$DriveLetter /Export-Driver /Destination:"%UserProfile%\Desktop\ExportedDrivers" PS I can test Export if you can add to script
    Hmmm.... are drivers edition specific? PE seems to ignore edition - anyway regarding user choice see this one (note I removed edition) - I'll add the exact export cmd if the various scenarios passes testing
    Code:
    if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))  {      Start-Process PowerShell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs     Exit }  $WinPEDrive =  $env:SystemDrive -replace ':'  $WinPEArch = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty BuildLabEx  $WinPECurrentVersion =  Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty CurrentVersion  if ($WinPEArch -Split '.' -contains 'x86fre') {$WinPEArch = $true} else {$WinPEArch = $false}  $Drives = Get-PSDrive -PSProvider FileSystem | Select-Object Name, Root | Where-Object {$_.Name -notcontains $WinPEDrive}  $List = @()  foreach ($Drive in $Drives) {     $HivePath = Join-Path($Drive.Root) -ChildPath "Windows\System32\config\SOFTWARE"         if (Test-Path($HivePath))     {         Reg.exe Load 'HKLM\TempHive' $HivePath | Out-Null         $BuildLabEx = Get-ItemProperty -Path 'HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty BuildLabEx         $CurrentVersion =  Get-ItemProperty -Path 'HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty CurrentVersion         Reg.exe Unload 'HKLM\TempHive'| Out-Null              if ($BuildLabEx -Split '.' -contains 'x86fre') {$Arch = $true} else {$Arch = $false}          #If a Matching OS and Arch are found then export and integrate drivers         if ($WinPECurrentVersion -eq $CurrentVersion -and $WinPEArch -eq $Arch){              $List += ($HivePath.Replace("config\SOFTWARE", "Drivers"))                       }          else {                             Write-Host "No drivers to export "         }     } }  #User choice export foreach($Item in $List) { Write-Host $Item } if ($List.Length -gt 1) {      Write-Host "`r`n"     Write-Host "Choose a Drive letter from the above list from which to export..."       $Drive = Read-Host       foreach($Item in $List){         if ($Item.StartsWith($Drive.ToUpper())) {Write-Host "Exporting.... " $Item}     } } else {     Write-Host "Exporting.... " $Item } Write-Host "Done" Read-Host
    Last edited by Superfly; 03 Jul 2019 at 15:55.
      My Computer


  8. Posts : 4,131
    Windows 3.1 to Windows 11
    Thread Starter
       #18

    Hmmm.... are drivers edition specific?
    Yes, There are Drivers For Windows 8 and There are Drivers for Windows 10

    No Difference between Home, Pro, Enterprise Drivers
      My Computer


  9. Posts : 4,131
    Windows 3.1 to Windows 11
    Thread Starter
       #19

    Test from Post 12 in PE shows all x64 OS's
    E:\ is Windows 8.1
    the other two are windows 10
    App Development Help-image75.jpg

    Current Test lists all OS
    App Development Help-image74.jpg

    Need some thing like to list $Driveletter and $edition - from test in post 12 which Matches against Arch

    Export Drivers From $DriveLetter - $Edition

    Export Drivers From E:\ - Windows 8.1 Pro
    Export Drivers From F:\ - Windows 10 Pro
    Export Drivers From I:\ - Windows 10 Pro
      My Computer


  10. Posts : 3,453
       #20

    Try this one I think I got the versions wrong again
    Code:
    if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) 
    { 
        Start-Process PowerShell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
        Exit
    }
    
    $WinPEDrive =  $env:SystemDrive -replace ':'
    
    $WinPEArch = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty BuildLabEx
    
    $WinPECurrentVersion =  Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty CurrentVersion
    
    if ($WinPEArch -Split '.' -contains 'x86fre') {$WinPEArch = $true} else {$WinPEArch = $false}
    
    $Drives = Get-PSDrive -PSProvider FileSystem | Select-Object Name, Root | Where-Object {$_.Name -notcontains $WinPEDrive}
    
    $List = @()
    
    foreach ($Drive in $Drives)
    {
        $HivePath = Join-Path($Drive.Root) -ChildPath "Windows\System32\config\SOFTWARE"
       
        if (Test-Path($HivePath))
        {
            Reg.exe Load 'HKLM\TempHive' $HivePath | Out-Null
            $BuildLabEx = Get-ItemProperty -Path 'HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty BuildLabEx
            $CurrentVersion =  Get-ItemProperty -Path 'HKLM:\TempHive\Microsoft\Windows NT\CurrentVersion' | Select-Object -ExpandProperty CurrentVersion
            Reg.exe Unload 'HKLM\TempHive'| Out-Null
        
            if ($BuildLabEx -Split '.' -contains 'x86fre') {$Arch = $true} else {$Arch = $false}
    
            #If a Matching OS and Arch are found then export and integrate drivers
            if ($WinPECurrentVersion -eq $CurrentVersion -and $WinPEArch -eq $Arch){
    
                $List += ($HivePath.Replace("config\SOFTWARE", "Drivers"))
             
                } 
            else {   
                
                Write-Host "No drivers to export "
            }
        }
    }
    
    #User choice export
    foreach($Item in $List) { Write-Host $Item }
    if ($List.Length -gt 1) {
    
        Write-Host "`r`n"
        Write-Host "Choose a Drive letter from the above list from which to export..." 
    
        $Drive = Read-Host 
    
        foreach($Item in $List){
            if ($Item.StartsWith($Drive.ToUpper())) {Write-Host "Exporting.... " $Item}
        }
    }
    else {
        Write-Host "Exporting.... " $Item
    }
    Write-Host "Done"
    Read-Host
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 16:01.
Find Us




Windows 10 Forums