title: changing configuration files with Group Policy
body: <p>Trying to wrap my head around a problem.  Using Owncloud sync client, default bandwidth settings are 'unlimited' and I need to set an enterprise to use a configured limit.  This is possible in the owncloud.cfg file, and the specific section is seen here:</p>
  
  <pre><code>...
  
  [Bandwidth]
  maxUpload=10
  maxDownload=50
  useMaxUpload=0
  useMaxDownload=0
  
  ...
  </code></pre>
  
  <p>What I want is to set new values in the maxUp/maxDn values, and set the useMax values to '1'.</p>
  
  <p>All I have been able to come up with is to write a logon script that runs a script to check the file and set the [Bandwidth] section in case a user has changed the pushed settings.  </p>
  
  <p>The rub here is that .bat files are terrible at this.  I can't use powershell as I cannot verify that all users have it on their machines, but if someone wants to correct me on that, there are mostly Win 10, but it's the Win 7 that I fear cannot do PS scripts.</p>
  
  <p>Anyhoo, I'm not a big M$ Winderp user and would have sed/awk'd this issue without any hassle on a *nix box.  I don't want to install cygwin or any third party, just use whats on the OS.  </p>
  
  <p>Can anyone please 1. Point me to the correct tool, like vbs or ps or .bat or .cmd etc.  and 2. Offer a simple starting point to where I can build from?  I intend to push this from a GPO.</p>
  
  <p>EDIT- So I'll use powershell.  Now my challenge is to write better PS scripts </p>
  
  <pre><code>(Get-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg) -replace '^useDownloadLimit=\d$', 'useDownloadLimit=1' | Set-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg   
  
  (Get-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg) -replace '^useUploadLimit=\d$', 'useUploadLimit=1' | Set-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg
  
  (Get-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg) -replace '^DownloadLimit=\d*$', 'DownloadLimit=500' | Set-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg
  
  (Get-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg) -replace '^UploadLimit=\d*$', 'UploadLimit=500' | Set-Content %LOCALAPPDATA%\ownCloud\owncloud.cfg
  </code></pre>
  
  <p>EDIT 2-
  For owncloud.exe, this being run from the local machine works perfectly</p>
  
  <pre><code>@echo off
  (@echo
  @echo [BWLimit]
  @echo downloadLimit=500
  @echo uploadLimit=500
  @echo useDownloadLimit=1
  @echo useUploadLimit=1) &gt;&gt; "%LOCALAPPDATA%\ownCloud\owncloud.cfg"
  
  taskkill /f /im "owncloud.exe" &amp;&amp; start "" "C:\Program Files (x86)\ownCloud\owncloud.exe" --logdir cv_logs --logexpire 72
  REM LOGS ARE FOUND AT - C:\Users\'username'\AppData\Local|VirtualStore\Program Files (x86)\ownCloud\
  </code></pre>
  
  <p>But I'm not seeing the cfg file change after a few logoff/logons
  Any ideas?</p>