need a script to change one line within a java settings file

we need to Change the Setting   to MEDIUM like displayed at the code at the bottom

this line can have some different Settings or completely missing
other lines should not be altered
the user should call the script while logging in or before starting the app.
#Tue Nov 26 11:29:51 CET 2013

I am unable do write scripts ... can someone help me please?
LVL 25
Dirk KotteSEAsked:
Who is Participating?
Dan CraciunConnect With a Mentor IT ConsultantCommented:
It should of been
echo "`" >> $file

to force a new line.

Yes, you're right, it's $env:userprofile . I wrote the script for a text file and then copied your path :)
Dan CraciunIT ConsultantCommented:
Try this, in powershell:

# name and path of the file
$file = %userprofile%\AppData\LocalLow\Sun\Java\Deployment\

# delete the line containing, if it exists
(Get-Content $file) | Foreach-Object {$_ -replace "^deployment\.security\.level=.*?$", ""} |
Set-Content $file

# add the required line
echo "" >> $file

Dirk KotteSEAuthor Commented:
great, nearly perfect :-)
$file = %userprofile%\AppData\Loc...    has to be
$file = "$env:userprofile\AppData\Local...

but results in leading spaces and a space between every character...:
   d e p l o y m e n t . s e c u r i t y . l e v e l = M E D I U M
All Courses

From novice to tech pro — start learning today.