Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6817663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:04:59+00:00 2026-05-26T21:04:59+00:00

I have this code to insert an executable to the start up registry: private

  • 0

I have this code to insert an executable to the start up registry:

private static void addToWin( File f, String param ) throws IOException {
    String name = generateName(f);
    String cmd = "reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v " + name + " /t REG_SZ /d \"" + f.getAbsolutePath() + param + "\"";
    Runtime.getRuntime().exec(cmd);
}

This works, but the problem is that after running it I have a process in task manager called reg.exe that takes the 10% of the CPU. This prevent the JVM to shutdown at the end of the running ( even with a System.exit() at the end )

The code that removes the same entry from the registry works well and does not have this problem.

Do you have an idea of what is going on and how to solve this?

Thankyou

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:05:00+00:00Added an answer on May 26, 2026 at 9:05 pm

    I seem to remember having a similar issue and finding out that the process would not terminate until its output was consumed. Try keeping a reference to the Process object returned by the runtime exec method, like so…

    Process proc = Runtime.getRuntime().exec(cmd);
    

    … then get an input stream from the Process and simply read from it until it ends.

    InputStream ips = proc.getInputStream();
    while(ips.read() != -1) {}
    

    Error handling needs to be added. You might have to do the same for stderr, not only stdout.

    EDIT: oh, and certainly don’t forget to close the stream. Seems like the kind of thing that holds on to system resources.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code : private void insertValus() { ContentValues initialValues = new ContentValues();
I have this code: string insertSql = INSERT INTO aspnet_GameProfiles(UserId,GameId) VALUES(@UserId, @GameId); using (SqlConnection
Have stumbled upon this code to insert the contents of a file into a
I have this code: cursor = conn.cursor() cursor.execute((insert into new_files (videos_id, filename, is_processing) values
I have this JS code: Download.prototype.insert = function(stocks, exchange, cb){ var self = this
I have this code $(.insert).click(function(){ $(.insert).ajaxStop(function(){ $(.load).hide(); }); $(.insert).ajaxStart(function(){ $(.load).show(); }); $.ajax({ type: GET,
I have this code below to insert serialized data in a field (order_pictures): $pictures_id
I have this code: void BaseOBJ::update(BaseOBJ* surround[3][3]) { forces[0]->Apply(); //in place of for loop
I have this code (mySql 5.1.36) CREATE TRIGGER problem_description AFTER INSERT ON problem_description FOR
Right now I have this code: $mysqldate = date(time()); mysql_query(INSERT INTO permissions (date) VALUES

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.