Board index » jbuilder » Start and stop program from command prompt

Start and stop program from command prompt


2006-01-13 07:00:00 AM
jbuilder23
Hello ,
I finishing program in java and my vision is that after start Windows 2003
is going to start my program .
Is working fine . I run it from bat file in startup and it looks like :
xxx.bat
start "MyApplication" /min java -jar MyApplication.jar start
Problem is and I working on it couple of days without any solution. That I
know that if low battery event
is generated on UPS after that is run bat file on Windows 2003 , where are
commands for safe shutdown of
virtual disks and operating system and I need firstly from the same bat file
safe shutdown MyApplication
where is running in thread INSERTs commands and after that is starting timer
which can be set from 1 to 99
minutes and during this time I would like shutdown MyApplication ... and it
run to round of course ..
for example
yyy.bat
start "MyApplication" /min java -jar MyApplication.jar stop
Have you any idea how it can do this ? I tried something but it didn`t work
but I like to hear some other
opinion.
Thanks
 
 

Re:Start and stop program from command prompt

Peter POCATKO wrote:
Quote
Hello ,

I finishing program in java and my vision is that after start Windows 2003
is going to start my program .
Is working fine . I run it from bat file in startup and it looks like :
xxx.bat
start "MyApplication" /min java -jar MyApplication.jar start

Problem is and I working on it couple of days without any solution. That I
know that if low battery event
is generated on UPS after that is run bat file on Windows 2003 , where are
commands for safe shutdown of
virtual disks and operating system and I need firstly from the same bat file
safe shutdown MyApplication
where is running in thread INSERTs commands and after that is starting timer
which can be set from 1 to 99
minutes and during this time I would like shutdown MyApplication ... and it
run to round of course ..
for example
yyy.bat
start "MyApplication" /min java -jar MyApplication.jar stop

Have you any idea how it can do this ? I tried something but it didn`t work
but I like to hear some other
opinion.

Thanks


Further to Paul's "run as a service" option, you might want to read this
article on BDN:
bdn.borland.com/article/0,1410,32068,00.html
--
Regards,
Lori Olson [TeamB]
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
www.google.ca/advanced_group_search
Other Newsgroup Searches:
www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
www.visi.com/~gyles19/fom-serve/cache/1.html
 

Re:Start and stop program from command prompt

Peter POCATKO wrote:
Quote


Have you any idea how it can do this ? I tried something but it didn`t
work but I like to hear some other
opinion.

I do not know of any way you can do this from a batch file per se. The only
thing I can see is:
(1) You will need to configure Windows 2003 to stop this app from running.
You would have to set this up in :
The registry
As a Windows service
Put a COM wrapper around the batch file using Windows notification
API
Perhaps use JNI to write a C Routine to shut this down, again using Windows
Notification API.
If you were using Unix/Linux/Mac, you could probably do this from a shell
script. But without a full shell scripting language that has access to the
kernel APIs, I do not know how you could do this other than the methods I
described above,
Just remember, when you are wanting to use native OS operations, you have to
do some low level API work (unless, as stated you are using Unix or a Unix
derivative, where shell scripts give you additional power). Even on Unix,
you will invariably have to go outside Java or use JNI to call services or
Kernel/GDI apis direct.
Hope this helps!
 

{smallsort}