ViciousXUSMC Posted December 18, 2014 Share Posted December 18, 2014 So I am trying to take a program that installs and has per user profile settings and deploy it in an enterprise scenario where I will have over 80 people per computer that I need to set settings for. I tracked down the programs configuration file to an AppData directory, so I used this script to copy it to all current users and the default profile user so that new users would have the file already applied at first log on. ;Push to all users Local AppData including Default User $folder = StringLeft(@UserProfileDir,StringInStr(@UserProfileDir,"\",0,-1)) $search = FileFindFirstFile($folder&"*") While 1 $profile = FileFindNextFile($search) If @error Then ExitLoop If FileExists($folder&$profile&"\AppData\Local") Then ;DirCreate($folder&$profile&"\AppData\Local\bluesoleil") DirCopy(@ScriptDir & "\bluesoleil", $folder&$profile&"\AppData\Local\bluesoleil", 1) EndIf WEnd FileClose($search) Well that did not work so well... I think it broke the program and upon second look at the config file I saw there are lines specific to the profile like "CURRENTUSERNAME" so I cant use a "master" copy. So now onto this thread topic, is there a way to parse a config file and then with AutoIT make selective changes to the document easily? Theory: Search the config file for the line starting with "CURRENTUSERNAME" and replace that line by copying the entire line, using a stringtrim and then pasting in the current user profile name via the macro for @UserName and then save the file. Here is a copy of the config file to help make sense of it. [AudioDeviceInfo] AudioDevice=53007000650061006B00650072007300200028005200650061006C00740065006B0020004800690067006800200044006500660069006E006900740069006F006E00200041007500640069006F00290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004D006900630072006F00700068006F006E006500200028005200650061006C00740065006B0020004800690067006800200044006500660069006E006900740069006F006E00200041007500640069006F0029000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000007C [LocalBluetooth] FirstRuninCurrentUser=0 CURRENTUSERNAME=frpatrmo LocalDiscoveryMode=13 [OPPSERVER] INBOXFOLDER=C:\Sansio\Bluetooth OUTBOXFOLDER=C:\Sansio\Bluetooth OWNCARDNAME=TOUGHBOOK5828.vcf VCARD_SUPPORT=259 [FTPSERVER] SHAREFOLDER=C:\Sansio\Bluetooth DESIRED_ACCESS=1 [BIPSERVER] BIPFOLDER=C:\Sansio\Bluetooth [Ad] UpdateTimer=168 OverTime=1419517321 While I am stuck on this I'll see about just automating the changes with standard stuff (winwait, send input, etc) but I definitly want to see if there is a better soltion along the lines of what I have in mind above. Thanks for the help. Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted December 18, 2014 Moderators Solution Share Posted December 18, 2014 ViciousXUSMC,That looks like a standard ini file format - you should be able to use the Ini* functions to modify it very easily. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 18, 2014 Moderators Share Posted December 18, 2014 As Melba points out, the ini files should be easy to manipulate. However, if you're looking to manipulate the installation itself (and it is an MSI) I would suggest Googling Active Setup; you can configure this with an open source tool such as Orca. You configure the setting, and then if the system sees anything "missing" for the user, it will automatically install it silently. It's clean, silent, and will work for any new user who logs into the system. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted December 18, 2014 Author Share Posted December 18, 2014 (edited) Just updating that I have a working script, it's crude and I am sure there is a better way to go about this, but atleast its working. $file = FileOpen ( "C:\Users\" & @UserName & "\AppData\Local\bluesoleil\bsps.ini", 0 ) Dim $Contents While 1 $Line = FileReadLine ( $file ) If @error Then Exitloop If $Line = "LocalDiscoveryMode=8" Then $Line = "LocalDiscoveryMode=13" If $Line = "LocalDiscoveryMode=9" Then $Line = "LocalDiscoveryMode=13" If $Line = "VCARD_SUPPORT=771" Then $Line = "VCARD_SUPPORT=259" If $Line = "INBOXFOLDER=C:\Users\" & @UserName & "\Documents\Bluetooth\inbox\" Then $Line = "INBOXFOLDER=C:\Sansio\Bluetooth\" If $Line = "SHAREFOLDER=C:\Users\" & @UserName & "\Documents\Bluetooth\Share\" Then $Line = "SHAREFOLDER=C:\Sansio\Bluetooth\" $Contents = $Contents & @CRLF & $Line WEnd FileClose ( $file ) $file = FileOpen ( "C:\Users\" & @UserName & "\AppData\Local\bluesoleil\bsps.ini", 2 ) FileWrite ( $file, $Contents ) Edited December 18, 2014 by ViciousXUSMC Link to comment Share on other sites More sharing options...
Spider001 Posted December 18, 2014 Share Posted December 18, 2014 just a question can this work for your script ? https://www.autoitscript.com/autoit3/docs/functions/IniWrite.htm https://www.autoitscript.com/autoit3/docs/functions/IniRead.htm Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted December 18, 2014 Author Share Posted December 18, 2014 ViciousXUSMC, That looks like a standard ini file format - you should be able to use the Ini* functions to modify it very easily. M23 Thanks for this (and others who also suggested) I had not known about these. I already wrote that one script before I saw these replies. I just recreated it with a simple 4 line script. Is this the cleanest way to use the .ini functions? Simply a write statment over and over, feels dirty because its too easy lol. Am I missing anything to make it more "professional" or a way to keep the file open for all writes without probably opening and closing it 4 times (not a big deal) IniWrite("C:\Users\" & @UserName & "\AppData\Local\bluesoleil\bsps.ini", "OPPSERVER", "INBOXFOLDER", "C:\Sansio\Bluetooth\") IniWrite("C:\Users\" & @UserName & "\AppData\Local\bluesoleil\bsps.ini", "OPPSERVER", "VCARD_SUPPORT", "259") IniWrite("C:\Users\" & @UserName & "\AppData\Local\bluesoleil\bsps.ini", "LocalBluetooth", "LocalDiscoveryMode", "13") IniWrite("C:\Users\" & @UserName & "\AppData\Local\bluesoleil\bsps.ini", "FTPSERVER", "SHAREFOLDER", "C:\Sansio\Bluetooth\") Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 18, 2014 Moderators Share Posted December 18, 2014 Try like this: $sINI = @AppDataDir & "\Local\bluesoleil\bsps.ini" IniWrite($sINI, "OPPSERVER", "INBOXFOLDER", "C:\Sansio\Bluetooth\") IniWrite($sINI, "OPPSERVER", "VCARD_SUPPORT", "259") IniWrite($sINI, "LocalBluetooth", "LocalDiscoveryMode", "13") IniWrite($sINI, "FTPSERVER", "SHAREFOLDER", "C:\Sansio\Bluetooth\") Then, if you change your INI location, you need only change it once. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted December 19, 2014 Author Share Posted December 19, 2014 (edited) Try like this: $sINI = @AppDataDir & "\Local\bluesoleil\bsps.ini" IniWrite($sINI, "OPPSERVER", "INBOXFOLDER", "C:\Sansio\Bluetooth\") IniWrite($sINI, "OPPSERVER", "VCARD_SUPPORT", "259") IniWrite($sINI, "LocalBluetooth", "LocalDiscoveryMode", "13") IniWrite($sINI, "FTPSERVER", "SHAREFOLDER", "C:\Sansio\Bluetooth\") Then, if you change your INI location, you need only change it once. Fair enough, this was my final config The @AppDataDir wont quite work I think it takes you directly to the Roaming subdirectory of AppData $pINI = "C:\Users\" & @UserName & "\AppData\Local\bluesoleil\bsps.ini" If FileExists($pINI) Then IniWrite($pINI, "OPPSERVER", "INBOXFOLDER", "C:\Sansio\Bluetooth") IniWrite($pINI, "OPPSERVER", "VCARD_SUPPORT", "259") IniWrite($pINI, "LocalBluetooth", "LocalDiscoveryMode", "13") IniWrite($pINI, "FTPSERVER", "SHAREFOLDER", "C:\Sansio\Bluetooth") MsgBox(0, "Auto Installer", "The Bluesoleil settings for " & @UserName & " have been configured and saved.") Else MsgBox(0, "Auto Installer", "The configuration file for Bluesoleil was not found and no actions were taken") EndIf Edited December 19, 2014 by ViciousXUSMC Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 19, 2014 Moderators Share Posted December 19, 2014 You are correct, apologies I glossed over that you were going into the local directory. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now