Harris, Jeffrey E. wrote:

-----Original Message-----
From: Patrick Flaherty [mailto:pflah...@rampageinc.com]
Sent: Saturday, March 23, 2013 5:22 PM
To: Tomcat Users List
Subject: runtime.exec "cmd.exe /C net use"

Hi,

I'm trying to run the following command ( runtime.exec "cmd.exe /C net
use" ) from my tomcat app and it's returning :

net use
New connections will be remembered.

There are no entries in the list.

This only happen when I run as a Windows service. If I run the tomcat
batch file to start tomcat then "net use" returns all my mapped network
drives. The service login is an account that has access to the network
shares as my app uses those shares, but the service login should not
preclude the command from executing properly. If I substitute "dir" for
"net use"
that works and I get a directory listing. The combo of "net use"
command using cmd.exe and running as a service seems to be the
conflict.

Any input much appreciated.

Thanks
Pat


There could be a few things here.

If I execute a net use command at the command prompt on my system, it responds:

"New connections will not be remembered.

There are no entries in the list."

(And I have no mapped drives.)

Even if the current logged in user is the same user as running the service, 
they are different sessions,
so normally the mappings would be different.  If you log in as the service 
account and map some drives,
those mappings are not accessible to Tomcat through the service account.

It is possible that if you have mapped drives remembered in a roaming profile 
that is used by the service account,
those mappings would be available to the service account, but I do not believe 
that service accounts normally load
any profile information.

Are you sure that you are not using UNCs (i.e., \\servername\sharename) to 
access the network shares, or are
you mapping the shares within your Tomcat application?  Do you map any drives 
prior to starting Tomcat from a batch file?  Please share with us how you 
establish your mappings for Tomcat, both for the service start and the batch 
file start, if different.


I would add that it is kind of doubtful that this has anything directly to do with Tomcat, or even Java. Maybe that question would belong more to some Windows forum.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to