none
Copying from a text file into an existing ini file RRS feed

  • Question

  • Hi, I created a 2 line script that finds a part number of a laptop and puts it into a txt file. What I need assistance doing is taking the data from that and putting it into an existing ini file.
    So the script I currently have spits out "SKU=PT251U" into a parts.txt
    I need to take line one fron parts.txt and have it copied and pasted into install.ini on the 2nd line and leaving everything else as is.
    Is this possible?

    Thanks!
    • Moved by Just Karl Friday, February 27, 2015 3:04 PM Looking for the proper forum.
    Thursday, February 26, 2015 10:00 PM

Answers

  • For those interested I managed to create a powershell script that does exactly what I needed and doesn't even require to create a text file.

    $a = Get-ItemProperty -Path "HKLM:\HARDWARE\DESCRIPTION\System\BIOS"
    $SystemSKU = $a.psobject.Properties | ?{$_.Name -eq "SystemSKU" }
    $SKU = $a.psobject.Properties["SystemSKU"].Value
    (Get-Content C:\setup\Drivers\z30\INSTALL.ini) | ForEach-Object { $_ -replace "PT251U", $SKU } | Set-Content C:\setup\Drivers\z30\INSTALL.ini


    Monday, March 2, 2015 9:40 PM

All replies

  • Hello,

    The TechNet Sandbox forum is designed for users to try out the new forums functionality. Please be respectful of others, and do not expect replies to questions asked here.

    As it's off-topic here, I am moving the question to The Official Scripting Guys Forum!

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    Friday, February 27, 2015 3:03 PM
  • Hello,

    While I am at it, you might want to review Posting Guidelines and Handy tips for posting to this forum.

    Karl


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

    Friday, February 27, 2015 3:05 PM
  • Sorry I thought I posted it in the right forum, must have accidentally chosen the wrong one.
    Friday, February 27, 2015 5:36 PM
  • Sorry I thought I posted it in the right forum, must have accidentally chosen the wrong one.

    Karl has moved your thread to an appropriate forum, so you can continue here after you've read the links in his last post.

    You'll need to post your current script and your errors.


    Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)

    Friday, February 27, 2015 5:51 PM
  • Currently I have a script that spits out the part number of the laptop into a text file.

    @echo off
    echo.
    for /f "tokens=2*" %%a in ('REG QUERY "HKLM\HARDWARE\DESCRIPTION\System\BIOS" /v SystemSKU') do set "SystemSKU=%%~b"
    echo SKU=%SystemSKU% >C:\setup\part.txt

    What I would like help with is to get the data from the txt file into an existing file called install.ini (specifically add it to the 2nd line within that file.

    The reason is I run an installer which forces to have the part number of the laptop your using it on and if you don't add the part number it won't run and every time Toshiba changes something or if it's from a different region it is a different part number.

    Friday, February 27, 2015 10:18 PM
  • For those interested I managed to create a powershell script that does exactly what I needed and doesn't even require to create a text file.

    $a = Get-ItemProperty -Path "HKLM:\HARDWARE\DESCRIPTION\System\BIOS"
    $SystemSKU = $a.psobject.Properties | ?{$_.Name -eq "SystemSKU" }
    $SKU = $a.psobject.Properties["SystemSKU"].Value
    (Get-Content C:\setup\Drivers\z30\INSTALL.ini) | ForEach-Object { $_ -replace "PT251U", $SKU } | Set-Content C:\setup\Drivers\z30\INSTALL.ini


    Monday, March 2, 2015 9:40 PM