none
Is there a VB Script that can edit an Ini file and the place it in the user profile. RRS feed

  • Question

  • Hello Script Guy,

    I am fairly new to scripting and need your guidance. I have repackaged an .msi using Wise package studio. When this msi is launched for the first time after installation, it creates a .ini file which contains Licensing server details, port number & a location where user can save his/her work in a private folder. 

    While checking the .ini file created by .msi after launch, I found out that it contains incorrect license server details & was pointing to my user profile. Hence I want to know, is there a way through which I can overwrite the .ini file created by .msi and copy it to the user profile path. 

    Thanks in advance !!

    • Moved by Bill_Stewart Tuesday, December 5, 2017 3:40 PM This is not "scripts on demand"
    Thursday, November 2, 2017 1:13 PM

All replies

  • I can give you a sample code on how to create an ini file using powershell.

    $functionText = @" [Options] UpdateKey=04/28/2015 12:50:27 AM WINDOW_LEFT=258 WINDOW_TOP=149 WINDOW_WIDTH=666 WINDOW_HEIGHT=519 WINDOW_MAX=0 BackupDir=C:\Windows\System32 UpdateCheck=1 Language=1033 (App)Sun Java=False NewVersion=5.05.5176 SkipUAC=1 FinderInclude1=PATH|C:\|*.*|RECURSE FinderInclude2=PATH|D:\|*.*|RECURSE FinderIncludeStates=1|1 I see SkipUAC=1 ShowCleanWarning=False ShowFirefoxCleanWarning=False WipeFreeSpaceDrives=C:\ RunICS=0 CookiesToSave=*.piriform.com|google.com "@ New-Item "C:\Program Files\Ccleaner\Ccleaner.ini" -type file -force -value $functionText

    $functionText = @"
    [Options]
    UpdateKey=04/28/2015 12:50:27 AM
    WINDOW_LEFT=258
    WINDOW_TOP=149
    WINDOW_WIDTH=666
    WINDOW_HEIGHT=519
    WINDOW_MAX=0
    BackupDir=C:\Windows\System32
    UpdateCheck=1
    Language=1033
    (App)Sun Java=False
    NewVersion=5.05.5176
    SkipUAC=1
    FinderInclude1=PATH|C:\|*.*|RECURSE
    FinderInclude2=PATH|D:\|*.*|RECURSE
    FinderIncludeStates=1|1
    I see SkipUAC=1
    ShowCleanWarning=False
    ShowFirefoxCleanWarning=False
    WipeFreeSpaceDrives=C:\
    RunICS=0
    CookiesToSave=*.piriform.com|google.com
    "@
    
    New-Item "C:\Program Files\Ccleaner\Ccleaner.ini" -type file -force -value $functionText
    
    Test-Path "C:\Program Files\Ccleaner\Ccleaner.ini"
    Copy-Item "C:\Program Files\Ccleaner\Ccleaner.ini" c:\users\kdcpcd


    Lets see if it works for you.

    or you can go through this websites to check with VB scripts

    Read & Write INI Files

    or

    Get-Content old.ini |
    ForEach { $_ -replace 'Host="KBFIE01"','Host="vKBprt01"' } |
    Out-file new.ini


    Naveen Basati


    • Edited by BASATI Thursday, November 2, 2017 1:44 PM addition of code
    Thursday, November 2, 2017 1:36 PM
  • You can fix this in Wise by specifying the correct meta variables and setting up the MSI t correctly do the installation.

    You can also use the PowerShell module that reads and manages INI files.

    find-module IniManager | Install-Module


    \_(ツ)_/

    Thursday, November 2, 2017 3:51 PM
  • Thank you Naveen for your prompt response. Unfortunately, In our environment we use VB as a Standard, hence Powershell script might not be applicable(though it is easy and quite useful). I'll go through the weblink you shared for the VB Script option. 

    Thanks once again :)

     
    Friday, November 3, 2017 8:29 AM