Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Java - start prog on pc start and other funtions

Posted on 2004-08-06
3
Medium Priority
?
312 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
[X]
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
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

670 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