File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Runtime.exec , application is invisible Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Runtime.exec , application is invisible" Watch "Runtime.exec , application is invisible" New topic
Author

Runtime.exec , application is invisible

hauze richard
Greenhorn

Joined: Apr 08, 2010
Posts: 4
I'm making some web server for managing specific application.
at first, I want to run or stop a application at remote desktop using JSP server.

So, I used following code.

Process process = Runtime.getRuntime().exec("C:\\test.exe");

then I confirm that 'test.exe' is running at remote desktop but background.
I could find 'test.exe' from windows task manager. but I can't see it's window.
It's invisible.

how can I make it visible at remote desktop? anybody give me some advices.

thanks in advance.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Welcome to JavaRanch

coming to your question, read this . it may show some light to you

hauze richard
Greenhorn

Joined: Apr 08, 2010
Posts: 4
Seetharaman Venkatasamy wrote:Welcome to JavaRanch

coming to your question, read this . it may show some light to you



thanks for your reply

actually, my issue is running application by JSP(TOMCAT).
when I run my java code directly ( in eclipse, or command line ), it works well.

do you have any other idea?
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 497
    
    5
(Assuming remote OS is Windows) Check the username under which test.exe is running. If it's system or localservice or something like that (probably it'll be same credentials as the web server itself), app may not be visible since these credentials are not assigned a window station (i.e, they don't have access to desktop).
hauze richard
Greenhorn

Joined: Apr 08, 2010
Posts: 4
Karthik Shiraly wrote:(Assuming remote OS is Windows) Check the username under which test.exe is running. If it's system or localservice or something like that (probably it'll be same credentials as the web server itself), app may not be visible since these credentials are not assigned a window station (i.e, they don't have access to desktop).


You are right. The username is 'SYSTEM'.
So, do you mean that I can't run my apps at remote PC with being visible?


thanks your opinion on target.


Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 497
    
    5
App can be visible even on remote system. It needs to run under the same credentials as the remote desktop user account.
Am not to sure how to achieve that using Windows alone. There is a 'runas' command ("cmd runas <options> test.exe") but I think it has the problem that the account password has to be entered manually.
Another option is the Sysinternals free tool, psexec which can take both username and password in commandline.

Am not sure what your app is all about - if tomcat/jsp are in picture only to launch a remote app, then you can replace them totally with only psexec. It can execute an app in remote machine.
But if remote app launch is just one step in a bigger web application, then you can use psexec to launch it under remote desktop user account.

There may be other ways. Better to check in a Windows forum like codeproject or programmersheaven too.
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 497
    
    5
Another option you can try, if you're running Tomcat as a service, is use 'services.msc' to set the option 'Allow service to interact with desktop' for Tomcat service.
hauze richard
Greenhorn

Joined: Apr 08, 2010
Posts: 4
thanks Karthik Shiraly

Your reply is a big help to me. You are a superb engineer undoubtedly.
Have a good day
Karthik Shiraly
Ranch Hand

Joined: Apr 04, 2009
Posts: 497
    
    5
You're welcome! And thank you for those nice words - you made my day!!
 
jQuery in Action, 2nd edition
 
subject: Runtime.exec , application is invisible