Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Java - start prog on pc start and other funtions

Posted on 2004-08-06
3
288 Views
Last Modified: 2012-05-05
Hi,

I am writing a small utility program for myself. I am wanting the program to have the following functionality:

1. Program should automatically run when the OS runs.
2. And i want to be able to log off, restart and shutdown the system when I want (i will use buttons for this).

The OS i am using for myself is MS Windows XP, I am aware that I could use the Win32 API (by using JNI), but I have hardly none Win32 API and the JNI experience. Is there a java class solution for this?

Thanks!
0
Comment
Question by:Ravi Singh
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
ID: 11733964
1) add a registry entry to:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

a String key like:

key: "myapplication" value: "path to your script to start the application"

2)  Try:

// shutdown Windows
Runtime.getRuntime().exec( "cmd /C \"rundll32.exe shell32.dll,SHExitWindowsEx\"" ) ;

// reboot Windows
Runtime.getRuntime().exec( "cmd /C \"rundll32.exe shell32.dll,SHExitWindowsEx 2\"" ) ;

// power down
Runtime.getRuntime().exec( "cmd /C \"rundll32.exe shell32.dll,SHExitWindowsEx 3\"" ) ;

That may work :-)
0
 
LVL 18

Author Comment

by:Ravi Singh
ID: 11734011
Thanks Tim :)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11734030
Did it work?

Cool :-)

Good luck!!

Tim
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

809 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