Need help using a script to modify an INI file
hello all-
I need your help with this script I am trying to write . I have this file located in the windows dir on a couple workstations I just need to modify one line in that file. I figure a script should be able to modify right here is the file. then do a push using kace
[Globals]
Bank=812
Branch=001
ExePath=\\Enet-03\Teller Train\ExePath
ShrPath=\\Enet-03\Teller Train\ShrPath
alphaFldUpperCase=YES
hostName=192.168.5.151
portNumber=27201
DisplayPrintInDemo=NO
DeviceTable=SPECTRUM
AutoDownLoad=NO
[Teller]
autoInquiry=Yes
CTRAdviseMsg=yes
ctrLimit1=3000.01
ctrLimit2=10000.01
CheckBatching=YES
ChecksPerfSkipLines=3
CUNameOnCheck=NO
InquiryFontName=Lucida Console
InquiryFontSize=8
HoldCodeOption=OPTIONAL
NoDecimal=YES
AutoCashCount=YES
AutoCashOutCount=YES
AutoBillMix=1,2,3,2,2,0,1
AvailableCoin=N,N,Y,Y,Y,Y
AutoChkCalc=YES
TroyLJPrinter=NO
RepeatTranEnabled=NO
ForcePostForward=YES
CashCountTotalReq=NO
CashCountFocus=100
[ApplicationSetup]
GUISpectrum=
AccountHolderProfileSupport=NO
LenderAdvantageSupport=NO
LenderAdvantagePathName=
BranchSuiteSupport=NO
WebServicesURL=http://YourHost/ASTellerUI/services/VB6Service?wsdl
ReturnToBRanch=NO
IMMChkScan=NO
Next=NO
[ImageManSystem]
DocManSupport=NO
ArcHostName=YourHost
ArcPortNumber=5671
Autoarchive=NO
AutoSigCapture=NO
SigTransfers=NO
SigCashOut=NO
SigCheckWD=NO
SigChkCashing=NO
SigWithdrawal=NO
SigFTCodes=
SigWindow=YES
DocManSignatureCaptureURL=http://YourHost/TrueImageTellerUI/Signature/SigCapture.jsp
DocManPathName=http://YourHost/shared
IDViewerSupport=NO
IDViewerPathName=http://YourHost/ASTellerUI/memberid
[CashDispenser]
CoinDispenser=NO
CashOutDisplay=NO
[Security]
HostUpRetry=5
JournalRetentionDays=15 this is the line I need to modify
PasswordAttempts=3
UpdateHosts=none
[NarrowReceipts]
CFReceipts=NO
CFPrinter=
CFFontSize=8
CFFont=Lucida Console
[LocalPrinter]
LocalPrint=NO
LPPrinter=\\enet-01\Xerox Phaser 4500N-Train
LPFont=Lucida Console
LPFontSize=10
Please let me know!
Thanks
Alex
Answers (6)
this is what i have so far ' This script opens up an ini file and changes
' the JournalRetentionDays= string from 5 to 15.
Const ForReading = 1
Const ForWriting = 2
fileToChange = "C:\windows\specwin.ini"
set fso = CreateObject("Scripting.FileSystemObject")
set oFile = fso.OpenTextFile(iniFile, ForReading)
sText = oFile.ReadAll
oFile.Close
sNewText = Replace(sText, "JournalRetentionDays=5", "JournalRetentionDays=15")
set oFile = fso.OpenTextFile(fileToChange, ForWriting)
oFile.WriteLine sNewText
oFile.close
Comments:
-
here is a link for vbscript, you look good so far
http://blogs.technet.com/b/heyscriptingguy/archive/2005/02/08/how-can-i-find-and-replace-text-in-a-text-file.aspx - SMal.tmcc 12 years ago -
create an application and upload your script, use cscript.exe as the app and list the script as a dependancy - SMal.tmcc 12 years ago
I believe in power shell
Get-Content C:\windows\specwin.ini | ForEach-Object { $_ -replace "JournalRetentionDays=5", "JournalRetentionDays=15" } | Set-Content C:\windows\specwin.ini
Comments:
-
thanks i got it to work now how can i push it using kace - brighstarcuit 12 years ago
-
powershell.exe -nologo -executionpolicy bypass -WindowStyle hidden -noprofile -file "script.ps1"
cscript your.vbs if your are using the vb script you created - SMal.tmcc 12 years ago -
i am gonna use the script i created do i need to upload the script in the distribution or go to the scripting tab this is my first time doing a push in kace using a vbs script - brighstarcuit 12 years ago
-
create an application and upload your script, use cscript.exe as the app and list the script as a dependancy - SMal.tmcc 12 years ago
This can be done using VBScript/Wise Script/MSI/PowerShell etc...
If you want to do it using WiseScript, the link is here
http://www.symantec.com/connect/articles/editing-ini-file-using-wisescript
I use this script to find and replace. There are many scripts in the forums but many of them do now work. I use this dynamic script which you can modify a little to suit your needs.
http://msiworld.blogspot.com.au/2012/07/vbscript-to-find-and-replace.html