Solved

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

Posted on 2013-11-26
3
1,276 Views
Last Modified: 2013-11-28
we need to Change the Setting
deployment.security.level   to MEDIUM like displayed at the code at the bottom
within
%userprofile%\AppData\LocalLow\Sun\Java\Deployment\deployment.properties

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.

#deployment.properties
#Tue Nov 26 11:29:51 CET 2013
deployment.expiration.decision.timestamp.10.40.2=1385050638
deployment.security.level=MEDIUM
Sun\\Java\\Deployment\\cache\\6.0\\splash\\splash.xml
deployment.version=7.21

I am unable do write scripts ... can someone help me please?
0
Comment
Question by:Dirk Kotte
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39677454
Try this, in powershell:

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

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

# add the required line
echo "deployment.security.level=MEDIUM" >> $file


HTH,
Dan
0
 
LVL 23

Author Comment

by:Dirk Kotte
ID: 39677498
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...:
...
deployment.javaws.jre.0.args=
   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
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39677533
It should of been
echo "`ndeployment.security.level=MEDIUM" >> $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 :)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to implement Singleton Design Pattern in Java.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now