Reading specific .ini key change

Welcome Forums General PowerShell Q&A Reading specific .ini key change

Viewing 2 reply threads
  • Author
    • #174787
      Topics: 7
      Replies: 9
      Points: 102
      Rank: Participant

      Hello, I'm having a hard time understanding how to read an .ini file change prior to my If/ Elseif/Else.
      Previously, I read the value that changed from the Registry – no problem. (shown below)
      Now the software no longer writes the default source there. Instead the vendor decided to include it in an .ini file.
      Can someone please show me what I need to add in order to pick up the Key value?

      One of the lines in Section "Defaults" is DefaultSource32. This can only be set as one item, but there are many options. I'm only running my IF statement when this changes from Software Import to Fujitsu fi-7160 or Fujitsu fi-7260.

      .ini file
      DefaultSource32=Software Import

      Here's my previous script.

      Start-Process -FilePath "C:\Program Files (x86)\Kofax\Capture\ImgCtls\Bin\ScannerConfigUtil.exe" -Wait
      $src_dir1 = "C:\Program Files (x86)\Kofax Set Default Scanner\Fujitsu 7160"
      $src_dir2 = "C:\Program Files (x86)\Kofax Set Default Scanner\Fujitsu 7260"
      $dst_dir1 = "C:\ProgramData\Kofax\Vrs"
      $dst_dir2 = "C:\Program Files (x86)\Kofax\Capture\ImgCtls\bin\Profiles"
      #This no longer applies#
      $value = Get-ItemPropertyValue "HKLM:\SOFTWARE\WOW6432Node\Kofax\Condor\1.0\*" -Name 'Default Source'
      if ($value -like 'Fujitsu fi-7160*'){
      Copy-Item "$src_dir1\*.cps" -Destination "$dst_dir2" -WhatIf
      Copy-Item "$src_dir1\*" -Exclude "*.cps" -Destination "$dst_dir1" -WhatIf
      elseif($value -like 'Fujitsu fi-7260*'){
      Copy-Item "$src_dir2\*.cps" -Destination "$dst_dir2" -WhatIf
      Copy-Item "$src_dir2\*" -Exclude "*.cps" -Destination "$dst_dir1" -WhatIf
      $wshell = New-Object -ComObject Wscript.Shell
      $Output = $wshell.Popup("Selection was not a correct model. Please re-open utility and choose Fujitsu 7160 or 7260")

      Thank you!

    • #174802
      Senior Moderator
      Topics: 8
      Replies: 1141
      Points: 3,927
      Helping Hand
      Rank: Community Hero

      You can use below link to get some help. It has a function to convert from ini.

      Managing INI Files with PowerShell

    • #174823
      Topics: 7
      Replies: 9
      Points: 102
      Rank: Participant

      Thanks, kvprasoon.

      I did some digging around and ultimately tested this. It works and returns exactly what I need.

      $DefaultSource32 = Get-Content -Path C:\ProgramData\Kofax\Vrs\kofax200.ini | Where-Object { $_ -match 'DefaultSource32' }
      Thanks again!
Viewing 2 reply threads
  • The topic ‘Reading specific .ini key change’ is closed to new replies.