You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Patrick Flaherty <pf...@rampageinc.com> on 2013/03/23 22:22:15 UTC

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

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


Re: runtime.exec "cmd.exe /C net use"

Posted by David Kerber <dc...@verizon.net>.
On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>
>
>> -----Original Message-----
>> From: André Warnier [mailto:aw@ice-sa.com]
>> Sent: Saturday, March 23, 2013 8:10 PM
>> To: Tomcat Users List
>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>
>> Harris, Jeffrey E. wrote:
>>>
>>>> -----Original Message-----
>>>> From: Patrick Flaherty [mailto:pflahrty@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
>>
>> 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.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>
> I absolutely agree.  I would expect to see the same behavior with Apache HTTPD, IIS, or
> any other service that accesses mapped drives.  It is a question of how service accounts behave
> in the windows architecture, rather than something specific with Tomcat.
>
> Jeffrey Harris

It will depend on what user your TC service is running under.    If it's 
running as the LocalSystem user,  it will not have access to any network 
drives, or many other network resources.  It can hit some, such as 
databases.

If you want your TC to be able to see networked drives, you need to run 
it under the logged-on user's ID.  Keep in mind, though, that if the 
user logs off, the drives will be disconnected.  Your best bet in that 
case it to not connect by drive letter, but rather by the UNC name (what 
you used to map it when you were logged on).  That will work if the user 
TC is running has has the appropriate permissions to the network resource.

D


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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 24, 2013, at 4:01 PM, André Warnier wrote:

> Patrick Flaherty wrote:
>> On Mar 24, 2013, at 2:56 PM, André Warnier wrote:
>>> Harris, Jeffrey E. wrote:
>>>>> -----Original Message-----
>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>>> Sent: Sunday, March 24, 2013 12:18 PM
>>>>> To: Tomcat Users List
>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>
>>>>>
>>>>> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
>>>>>
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>>>>> Sent: Sunday, March 24, 2013 10:20 AM
>>>>>>> To: Tomcat Users List
>>>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>>>
>>>>>>>
>>>>>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>>>>>>
>>>>>>>> On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> Thanks for all the input. I know about service logins being only
>>>>> able
>>>>>>> to use UNC paths (not drive letters) to access network shares. I
>>>>> know
>>>>>>> the service login & password have to have a matching account  
>>>>>>> on the
>>>>>>> server with the shares in order for the tomcat app to use  
>>>>>>> (access)
>>>>>>> those shares. We do all of this. Out tomcat app depends on  
>>>>>>> network
>>>>>>> shares to function and it always has worked as long as the  
>>>>>>> service
>>>>>>> login account matches an account on the server with the shares.
>>>>>>>
>>>>>>> What I'm trying to do in an html interface is make a pulldown  
>>>>>>> menu
>>>>>>> list of my mapped drives as a location for our database  
>>>>>>> backup. It's
>>>>>>> a preference setup to where an automated scheduled backup will  
>>>>>>> write
>>>>>>> the backups. I'm using "net use" to produce what you would  
>>>>>>> expect
>>>>> for
>>>>>>> output (all the mapped network drives) and parsing the output to
>>>>>>> produce the pulldown menu item containing the unc portion  
>>>>>>> gleaned
>>>>>>> from the "net use" output. I need the unc portion as this is  
>>>>>>> what a
>>>>>>> tomcat app needs. No matter what I do outside the app I cannot
>>>>>>> produce the effectively empty list that the app is producing.  
>>>>>>> I'm
>>>>>>> logged into Windows as the same account as the service and I  
>>>>>>> open a
>>>>>>> command prompt and see all my mapped drives via "net use". I  
>>>>>>> have
>>>>>>> tried UAC on and off and it changes nothing. I added a simple  
>>>>>>> "dir"
>>>>>>> to the app and I can get that output but not the "net use"
>>>>>>> output. I do know it has to do with the service as I said  
>>>>>>> because
>>>>>>> when tomcat is started via the startup.bat it works great.
>>>>>>>
>>>>>>> Maybe it is a Windows question but thought someone may have  
>>>>>>> had some
>>>>>>> similar experience.
>>>>>>>
>>>>>>> Thanks for eveyone's thoughts.
>>>>>>>
>>>>>>> -Pat
>>>>>>>
>>>>>> You still have not answered how the mapping are being made in the
>>>>>> first place.  Is the service account dynamically setting the  
>>>>>> mapping
>>>>>> using net use, or through the Windows API?  Are you relying on  
>>>>>> static
>>>>>> mappings in the user account profile?
>>>>> Hi Jeffrey,
>>>>>
>>>>> The drive mapping are happening through the Windows Explorer  
>>>>> interface.
>>>>> The file server is browsed and the shares on the file server are  
>>>>> mapped
>>>>> by right-clicking the share, mapping it to a drive letter and I  
>>>>> check
>>>>> the checkbox "Reconnect at logon". Then I start my app.
>>>>> (I'm not using any user profiles.)
>>>>>
>>>>> -Pat
>>>>>
>>>>>> Jeffrey Harris
>>>>>>
>>>> Pat,
>>>> I do not think that will work for a service account.  The drive  
>>>> mappings are stored in the user profile,
>>>> and since I do not think service accounts access user profiles,  
>>>> the service account will not remap
>>>> the drives when using the account to start a service (it will  
>>>> when you actually log in interactively with
>>>> the account).  You can try setting some custom environment  
>>>> variables in the user profile (not the system profile)
>>>> and see if they are accessible by the service account using the  
>>>> set command as a test to see if mapping
>>>> might be accessible.
>>>> What you probably need to do is actually set the drive mappings  
>>>> using the Windows API dynamically when Tomcat starts,
>>>> or use UNCs.  I know you want to display the drive mappings, but  
>>>> you could fake the display by doing a net use >myfilemappings.txt  
>>>> from the command line (when logged into the account), and just  
>>>> calling the file to display the mappings.  Obviously, if the  
>>>> mappings change, you would have to redo the file.
>>>> I think those are your only options.  You might want to do a  
>>>> Google search and see if there is a way for
>>>> service accounts to use remembered mapped drives.
>>>
>>> I routinely use "net use \\hostname\share" from inside programs  
>>> running as Windows Services (not in Java, though, but it should  
>>> not matter). "Drive letters" don't work.
>>> The exact form I use is :
>>> net use \\hostname\sharename <password> /USER:<userid>
>>> And then later I can open/read/write/close files as "\\hostname 
>>> \sharename\filepath".
>>>
>>> It works, but I have noticed one "quirk" in my programs : after  
>>> doing the "net use", the very first access to the share doesn't  
>>> work and returns an error. The second access and all subsequent  
>>> ones work though.  I have no idea why this is, but I have just  
>>> adapted my programs to work around this issue (by doing a first  
>>> dummy access and ignoring the result), and never had any problem  
>>> since. (**)
>>>
>>> To be able to do this, the Service *cannot* run as the LocalSystem  
>>> or LocalService user. By design in Windows, these special users do  
>>> not have access to any "Windows network" functions or resources.   
>>> Any "normal" user (*) will do, depending on the environment (such  
>>> as, if the current host is a member of a Windows Domain, and the  
>>> Windows network resource is defined in that domain, then the user  
>>> will need to be a Domain user; if the resource is a share on a  
>>> Linux Samba host e.g., then any user will do, as long as it is  
>>> known to Samba).
>>> This all concerns only "Windows network" resources.  Anything  
>>> accessed via standard TCP/IP protocols (HTTP, NFS, FTP, SSL..)  
>>> works, even when running as one of these special users.
>>>
>>> As a not very precise technical definition, "Windows network  
>>> resources" are all the things  like "shares" (network  
>>> directories), Windows network printers, anything that is accessed  
>>> via the SMB or CIFS protocol, anything that requires the usage of  
>>> a "workgroup" or "domain" name, etc.
>>>
>>>
>>> (*) with one additional caveat : the user must be granted the  
>>> "right to run services".
>>>
>>> (**) Maybe this is a hint to the OP : what happens if you ignore  
>>> the result of the first command call, and try the same command a  
>>> second time ?
>>> And I agree : there a bit of hocus-pocus here, but then many  
>>> things are, in a Windows environment.
>>>
>> You are not hearing me. The drives are mapped and set to reconnect  
>> at logon. Therefore if I reboot my machine the network drive  
>> mapping are in place after
>> logging in. I *do not* try and map a drive from within my app. My  
>> app has full access to the network shares as soon as my app is up.  
>> No problem with network
>> shares and my app !
>
> Well, only if your app is running on your computer though.  As soon  
> as your app is moved somewhere else, it will stop working unless you  
> set up that computer the same way.
>
> My app needs to read and write to those network
>> share to function and has no problems.
>> The problem is after I'm up and running, I try to run "cmd.exe /C  
>> net use" from within the app it does not return any mapped drives.  
>> it returns:
>> net use
>> New connections will be remembered.
>> There are no entries in the list.
>> Again, the return above happen only when running as a service  but  
>> works fine when tomcat starts from startup.bat in a console. Works  
>> fine means
>> it returns drive letter, unc equivalent etc ... basically what you  
>> normally see when you have mapped network drives and run "net use"  
>> from cmd.exe.
>> It make no sense I know but I'm at a loss.
> Yes, it does make sense.  When something is running as a Service  
> under a given user-id, it does not have the same environment as when  
> you login to a computer with that same user-id.
> The "service environment" is different from the "interactive login"  
> environment.
> In how many ways exactly under Windows, I do not know; but many.  
> (One of the ways is that a Service does not have a console, while  
> your interactive session does; that alone already make a lot of  
> programs act differently.  Another way is the permissions, which are  
> different between services and interactive users).
>
> The crux of the matter is : if you want your Service (whatever  
> program it runs in whatever programming language) to have access to  
> certain resources, you should make sure that it is the service  
> itself which acquires/connect to these resources, and not rely on,  
> for example, "mappings" that have been made under another  
> environment, to be present in the service environment.
>
> Think of it as follows : when you - personally - login to the  
> machine, you get a "session" under your user-id. And then inside  
> that session you run Tomcat, as an application, within that same  
> session.
> When a service starts, it does its own login and it gets a different  
> "session", also under the same user-id, but a different session  
> anyway.
> And there is nothing that says that everything that you have in your  
> interactive user session is automatically there in that (separate)  
> service session.  And if anything is, it may just be a bug in this  
> particular Windows version, and may go away at the next version.

Hi Andre,

I  do understand and well said. The bottom line is I cannot expect  
"interactive" command calls to work like 'Service" based command calls
So "net use" can execute but not return the same results as an  
interactive user. Dang !

Thanks for the WIndows lesson, the place I *thought* I knew well.
Pat

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


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


Re: runtime.exec "cmd.exe /C net use"

Posted by André Warnier <aw...@ice-sa.com>.
Patrick Flaherty wrote:
> 
> On Mar 24, 2013, at 2:56 PM, André Warnier wrote:
> 
>> Harris, Jeffrey E. wrote:
>>>> -----Original Message-----
>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>> Sent: Sunday, March 24, 2013 12:18 PM
>>>> To: Tomcat Users List
>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>
>>>>
>>>> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>>>> Sent: Sunday, March 24, 2013 10:20 AM
>>>>>> To: Tomcat Users List
>>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>>
>>>>>>
>>>>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>>>>>
>>>>>>> On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Thanks for all the input. I know about service logins being only
>>>> able
>>>>>> to use UNC paths (not drive letters) to access network shares. I
>>>> know
>>>>>> the service login & password have to have a matching account on the
>>>>>> server with the shares in order for the tomcat app to use (access)
>>>>>> those shares. We do all of this. Out tomcat app depends on network
>>>>>> shares to function and it always has worked as long as the service
>>>>>> login account matches an account on the server with the shares.
>>>>>>
>>>>>> What I'm trying to do in an html interface is make a pulldown menu
>>>>>> list of my mapped drives as a location for our database backup. It's
>>>>>> a preference setup to where an automated scheduled backup will write
>>>>>> the backups. I'm using "net use" to produce what you would expect
>>>> for
>>>>>> output (all the mapped network drives) and parsing the output to
>>>>>> produce the pulldown menu item containing the unc portion gleaned
>>>>>> from the "net use" output. I need the unc portion as this is what a
>>>>>> tomcat app needs. No matter what I do outside the app I cannot
>>>>>> produce the effectively empty list that the app is producing. I'm
>>>>>> logged into Windows as the same account as the service and I open a
>>>>>> command prompt and see all my mapped drives via "net use". I have
>>>>>> tried UAC on and off and it changes nothing. I added a simple "dir"
>>>>>> to the app and I can get that output but not the "net use"
>>>>>> output. I do know it has to do with the service as I said because
>>>>>> when tomcat is started via the startup.bat it works great.
>>>>>>
>>>>>> Maybe it is a Windows question but thought someone may have had some
>>>>>> similar experience.
>>>>>>
>>>>>> Thanks for eveyone's thoughts.
>>>>>>
>>>>>> -Pat
>>>>>>
>>>>> You still have not answered how the mapping are being made in the
>>>>> first place.  Is the service account dynamically setting the mapping
>>>>> using net use, or through the Windows API?  Are you relying on static
>>>>> mappings in the user account profile?
>>>> Hi Jeffrey,
>>>>
>>>> The drive mapping are happening through the Windows Explorer interface.
>>>> The file server is browsed and the shares on the file server are mapped
>>>> by right-clicking the share, mapping it to a drive letter and I check
>>>> the checkbox "Reconnect at logon". Then I start my app.
>>>> (I'm not using any user profiles.)
>>>>
>>>> -Pat
>>>>
>>>>> Jeffrey Harris
>>>>>
>>> Pat,
>>> I do not think that will work for a service account.  The drive 
>>> mappings are stored in the user profile,
>>> and since I do not think service accounts access user profiles, the 
>>> service account will not remap
>>> the drives when using the account to start a service (it will when 
>>> you actually log in interactively with
>>> the account).  You can try setting some custom environment variables 
>>> in the user profile (not the system profile)
>>> and see if they are accessible by the service account using the set 
>>> command as a test to see if mapping
>>> might be accessible.
>>> What you probably need to do is actually set the drive mappings using 
>>> the Windows API dynamically when Tomcat starts,
>>> or use UNCs.  I know you want to display the drive mappings, but you 
>>> could fake the display by doing a net use >myfilemappings.txt from 
>>> the command line (when logged into the account), and just calling the 
>>> file to display the mappings.  Obviously, if the mappings change, you 
>>> would have to redo the file.
>>> I think those are your only options.  You might want to do a Google 
>>> search and see if there is a way for
>>> service accounts to use remembered mapped drives.
>>
>> I routinely use "net use \\hostname\share" from inside programs 
>> running as Windows Services (not in Java, though, but it should not 
>> matter). "Drive letters" don't work.
>> The exact form I use is :
>> net use \\hostname\sharename <password> /USER:<userid>
>> And then later I can open/read/write/close files as 
>> "\\hostname\sharename\filepath".
>>
>> It works, but I have noticed one "quirk" in my programs : after doing 
>> the "net use", the very first access to the share doesn't work and 
>> returns an error. The second access and all subsequent ones work 
>> though.  I have no idea why this is, but I have just adapted my 
>> programs to work around this issue (by doing a first dummy access and 
>> ignoring the result), and never had any problem since. (**)
>>
>> To be able to do this, the Service *cannot* run as the LocalSystem or 
>> LocalService user. By design in Windows, these special users do not 
>> have access to any "Windows network" functions or resources.  Any 
>> "normal" user (*) will do, depending on the environment (such as, if 
>> the current host is a member of a Windows Domain, and the Windows 
>> network resource is defined in that domain, then the user will need to 
>> be a Domain user; if the resource is a share on a Linux Samba host 
>> e.g., then any user will do, as long as it is known to Samba).
>> This all concerns only "Windows network" resources.  Anything accessed 
>> via standard TCP/IP protocols (HTTP, NFS, FTP, SSL..) works, even when 
>> running as one of these special users.
>>
>> As a not very precise technical definition, "Windows network 
>> resources" are all the things  like "shares" (network directories), 
>> Windows network printers, anything that is accessed via the SMB or 
>> CIFS protocol, anything that requires the usage of a "workgroup" or 
>> "domain" name, etc.
>>
>>
>> (*) with one additional caveat : the user must be granted the "right 
>> to run services".
>>
>> (**) Maybe this is a hint to the OP : what happens if you ignore the 
>> result of the first command call, and try the same command a second 
>> time ?
>> And I agree : there a bit of hocus-pocus here, but then many things 
>> are, in a Windows environment.
>>
> You are not hearing me. The drives are mapped and set to reconnect at 
> logon. Therefore if I reboot my machine the network drive mapping are in 
> place after
> logging in. I *do not* try and map a drive from within my app. My app 
> has full access to the network shares as soon as my app is up. No 
> problem with network
> shares and my app ! 

Well, only if your app is running on your computer though.  As soon as your app is moved 
somewhere else, it will stop working unless you set up that computer the same way.

My app needs to read and write to those network
> share to function and has no problems.
> 
> The problem is after I'm up and running, I try to run "cmd.exe /C net 
> use" from within the app it does not return any mapped drives. it returns:
> net use
> New connections will be remembered.
> 
> There are no entries in the list.
> 
> Again, the return above happen only when running as a service  but works 
> fine when tomcat starts from startup.bat in a console. Works fine means
> it returns drive letter, unc equivalent etc ... basically what you 
> normally see when you have mapped network drives and run "net use" from 
> cmd.exe.
> 
> It make no sense I know but I'm at a loss.
> 
Yes, it does make sense.  When something is running as a Service under a given user-id, it 
does not have the same environment as when you login to a computer with that same user-id.
The "service environment" is different from the "interactive login" environment.
In how many ways exactly under Windows, I do not know; but many. (One of the ways is that 
a Service does not have a console, while your interactive session does; that alone already 
make a lot of programs act differently.  Another way is the permissions, which are 
different between services and interactive users).

The crux of the matter is : if you want your Service (whatever program it runs in whatever 
programming language) to have access to certain resources, you should make sure that it is 
the service itself which acquires/connect to these resources, and not rely on, for 
example, "mappings" that have been made under another environment, to be present in the 
service environment.

Think of it as follows : when you - personally - login to the machine, you get a "session" 
under your user-id. And then inside that session you run Tomcat, as an application, within 
that same session.
When a service starts, it does its own login and it gets a different "session", also under 
the same user-id, but a different session anyway.
And there is nothing that says that everything that you have in your interactive user 
session is automatically there in that (separate) service session.  And if anything is, it 
may just be a bug in this particular Windows version, and may go away at the next version.


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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 26, 2013, at 4:07 PM, André Warnier wrote:

> Patrick Flaherty wrote:
>> On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:
>>> On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
>>> <pf...@rampageinc.com>wrote:
>>>
>>>> Update: If I'm login interactively (meaning machine boots and I  
>>>> login and
>>>> get my desktop) and that interactive account matches the service  
>>>> login
>>>> account
>>>> then "net use" from within the service does return all mapped  
>>>> drives.
>>>>
>>>>
>>> I expected as much. It seems as though you cannot get away from the
>>> requirement of having to login 'first'...to get everything working  
>>> as
>>> designed/expected in your app.
>>>
>>> Excuse me, if I missed the business requirement specification  
>>> (earlier in
>>> this conversation), but is the requirement only to get a list of  
>>> mapped
>>> drives for 'your' user login or any enduser that logs into the  
>>> production
>>> server/client/PC/machine?
>>>
>>> can you add the list of network drives to a database table, and  
>>> maintain
>>> the database table and retrieve the list from that database table  
>>> via the
>>> tomcat-app-running-as-service?
>>>
>>> if you only need a list of mapped network drives for your user  
>>> login, can
>>> you just maintain a 'file' that has this list on the target/ 
>>> production
>>> server, and whenever it changes, can you update the file, and make  
>>> the
>>> topcat-app-running-as-service to always read the file instead of  
>>> having to
>>> call 'net use'?
>>>
>>> IMHO and FWIW, i would never go with the approach of relying on a  
>>> windows
>>> 'command line' to do this/that for me. yes, in my app, i allow  
>>> endusers to
>>> update files/documents, and the app saves the files/documents to a  
>>> certain
>>> folder on the server, and my app will list those files on a web  
>>> page, and
>>> they can view/download those files from/via the web app... all  
>>> that is done
>>> via java instead of doing a 'cmd.exe dir'. i'm new to java, always  
>>> wanted
>>> to be java developer, and loving what i can do with java. i'm almost
>>> getting to the point, where my days of a 'windows user' are  
>>> done... one
>>> day, i hope to migrate to linux for target server instead of windows
>>> server. :)
>> This is what I see. If my service logs in as "service-user" and I  
>> login normally to my desktop as "dt-user".
>> I call "net use" from my service and get an empty list. Now I  
>> logout as "dt-user"and login as "service-user" and I mapped
>> 4 drives and only 2 of the drives are mapped persisted (i.e.  
>> reconnect at logon). I logout as "service-user" and
>> now I have my app call "net use" programatically and it returns the  
>> 2 drives that were mapped with persistence.
>> Conclusion: Whatever drives are mapped persisted when logged in as  
>> the user the service logs in as, then your
>> app can call "net use" and get those drives returned from "net use"  
>> even if your logged in as "dt-user" OR nobody
>> is logged in at all !!!!
>> Maybe someone can confirm my finding, but this is what I see.
>
> Hi Patrick.
> Basically, what Jeffrey and I are trying to tell you :
> - we are not saying that your observations above are incorrect, in  
> the context in which you are making them
> - but it seems to us that the way you are going about this, is not  
> the right way to make your application portable to other systems or  
> Windows versions, because it seems to rely on things that may be  
> particular to one or the other Windows version or circumstance.
> In other words, it makes your application "fragile".
>
> The point is : when you login interactively to a Windows computer as  
> "user-1", or when you run a Service which logs-in to that computer  
> as the same "user-1", the environment in each case is *different* in  
> many ways.  It may be that under one or more particular versions of  
> Windows, when comparing certain particular aspects (like prior drive  
> mappings), you cannot see a difference.  But differences there are,  
> and they may show up on another version of Windows that you have not  
> tried yet, or maybe with the same version somewhere else which has  
> other "network policies" or "security policies" than the ones you  
> are testing under right now.
>
> If you totally control your environment, notice that something is  
> working and are happy with that because you are never going to use  
> this anywhere else, then that's fine, keep doing it and don't spend  
> more time figuring out what may be or not portable somewhere else.
>
> But if you want to make something portable, then you have to take  
> into account that, for example, the host on which your app may be  
> running one day, will not allow you to login interactively ahead of  
> time to make drive mappings for the service's user-id.
> For example, because the sysadmins have decided that anything that  
> runs as a service needs a special "service account" (which,  
> contrarily to all the others has a password that never runs out  
> e.g.); but on the other hand, according to their organisation's  
> rules, a service account can *not* be used to login interactively  
> anywhere. And since this rule already applies to the 10,000  
> workstations and servers of that organisation, they are not going to  
> change it just for you.
>
> And I believe that now, we are really far from any topic that  
> relates to the Tomcat-specific help that is the point of this  
> mailing list.
Hi Andre,

You are absolutely right. This is not 100%  guaranteed to be future  
proof. The cases you layout are enlightening. I'm not sure we will
go this route with all the potential pitfalls we could hit in the  
future. We are rethinking this now.

Thanks again.
Pat


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


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


Re: runtime.exec "cmd.exe /C net use"

Posted by André Warnier <aw...@ice-sa.com>.
Patrick Flaherty wrote:
> 
> On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:
> 
>> On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
>> <pf...@rampageinc.com>wrote:
>>
>>> Update: If I'm login interactively (meaning machine boots and I login 
>>> and
>>> get my desktop) and that interactive account matches the service login
>>> account
>>> then "net use" from within the service does return all mapped drives.
>>>
>>>
>> I expected as much. It seems as though you cannot get away from the
>> requirement of having to login 'first'...to get everything working as
>> designed/expected in your app.
>>
>> Excuse me, if I missed the business requirement specification (earlier in
>> this conversation), but is the requirement only to get a list of mapped
>> drives for 'your' user login or any enduser that logs into the production
>> server/client/PC/machine?
>>
>> can you add the list of network drives to a database table, and maintain
>> the database table and retrieve the list from that database table via the
>> tomcat-app-running-as-service?
>>
>> if you only need a list of mapped network drives for your user login, can
>> you just maintain a 'file' that has this list on the target/production
>> server, and whenever it changes, can you update the file, and make the
>> topcat-app-running-as-service to always read the file instead of 
>> having to
>> call 'net use'?
>>
>> IMHO and FWIW, i would never go with the approach of relying on a windows
>> 'command line' to do this/that for me. yes, in my app, i allow 
>> endusers to
>> update files/documents, and the app saves the files/documents to a 
>> certain
>> folder on the server, and my app will list those files on a web page, and
>> they can view/download those files from/via the web app... all that is 
>> done
>> via java instead of doing a 'cmd.exe dir'. i'm new to java, always wanted
>> to be java developer, and loving what i can do with java. i'm almost
>> getting to the point, where my days of a 'windows user' are done... one
>> day, i hope to migrate to linux for target server instead of windows
>> server. :)
> 
> This is what I see. If my service logs in as "service-user" and I login 
> normally to my desktop as "dt-user".
> I call "net use" from my service and get an empty list. Now I logout as 
> "dt-user"and login as "service-user" and I mapped
> 4 drives and only 2 of the drives are mapped persisted (i.e. reconnect 
> at logon). I logout as "service-user" and
> now I have my app call "net use" programatically and it returns the 2 
> drives that were mapped with persistence.
> Conclusion: Whatever drives are mapped persisted when logged in as the 
> user the service logs in as, then your
> app can call "net use" and get those drives returned from "net use" even 
> if your logged in as "dt-user" OR nobody
> is logged in at all !!!!
> 
> Maybe someone can confirm my finding, but this is what I see.
> 

Hi Patrick.
Basically, what Jeffrey and I are trying to tell you :
- we are not saying that your observations above are incorrect, in the context in which 
you are making them
- but it seems to us that the way you are going about this, is not the right way to make 
your application portable to other systems or Windows versions, because it seems to rely 
on things that may be particular to one or the other Windows version or circumstance.
In other words, it makes your application "fragile".

The point is : when you login interactively to a Windows computer as "user-1", or when you 
run a Service which logs-in to that computer as the same "user-1", the environment in each 
case is *different* in many ways.  It may be that under one or more particular versions of 
Windows, when comparing certain particular aspects (like prior drive mappings), you cannot 
see a difference.  But differences there are, and they may show up on another version of 
Windows that you have not tried yet, or maybe with the same version somewhere else which 
has other "network policies" or "security policies" than the ones you are testing under 
right now.

If you totally control your environment, notice that something is working and are happy 
with that because you are never going to use this anywhere else, then that's fine, keep 
doing it and don't spend more time figuring out what may be or not portable somewhere else.

But if you want to make something portable, then you have to take into account that, for 
example, the host on which your app may be running one day, will not allow you to login 
interactively ahead of time to make drive mappings for the service's user-id.
For example, because the sysadmins have decided that anything that runs as a service needs 
a special "service account" (which, contrarily to all the others has a password that never 
runs out e.g.); but on the other hand, according to their organisation's rules, a service 
account can *not* be used to login interactively anywhere. And since this rule already 
applies to the 10,000 workstations and servers of that organisation, they are not going to 
change it just for you.

And I believe that now, we are really far from any topic that relates to the 
Tomcat-specific help that is the point of this mailing list.


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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Mar 25, 2013 at 10:10 PM, Howard W. Smith, Jr. <
smithh032772@gmail.com> wrote:

> On Mon, Mar 25, 2013 at 6:57 PM, Patrick Flaherty <pflahrty@rampageinc.com
> > wrote:
>
>>
>> On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:
>>
>>  On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
>>> <pf...@rampageinc.com>**wrote:
>>>
>>>  Update: If I'm login interactively (meaning machine boots and I login
>>>> and
>>>> get my desktop) and that interactive account matches the service login
>>>> account
>>>> then "net use" from within the service does return all mapped drives.
>>>>
>>>>
>>>>  I expected as much. It seems as though you cannot get away from the
>>> requirement of having to login 'first'...to get everything working as
>>> designed/expected in your app.
>>>
>>> Excuse me, if I missed the business requirement specification (earlier in
>>> this conversation), but is the requirement only to get a list of mapped
>>> drives for 'your' user login or any enduser that logs into the production
>>> server/client/PC/machine?
>>>
>>> can you add the list of network drives to a database table, and maintain
>>> the database table and retrieve the list from that database table via the
>>> tomcat-app-running-as-service?
>>>
>>> if you only need a list of mapped network drives for your user login, can
>>> you just maintain a 'file' that has this list on the target/production
>>> server, and whenever it changes, can you update the file, and make the
>>> topcat-app-running-as-service to always read the file instead of having
>>> to
>>> call 'net use'?
>>>
>>> IMHO and FWIW, i would never go with the approach of relying on a windows
>>> 'command line' to do this/that for me. yes, in my app, i allow endusers
>>> to
>>> update files/documents, and the app saves the files/documents to a
>>> certain
>>> folder on the server, and my app will list those files on a web page, and
>>> they can view/download those files from/via the web app... all that is
>>> done
>>> via java instead of doing a 'cmd.exe dir'. i'm new to java, always wanted
>>> to be java developer, and loving what i can do with java. i'm almost
>>> getting to the point, where my days of a 'windows user' are done... one
>>> day, i hope to migrate to linux for target server instead of windows
>>> server. :)
>>>
>>
>> This is what I see. If my service logs in as "service-user" and I login
>> normally to my desktop as "dt-user".
>> I call "net use" from my service and get an empty list. Now I logout as
>> "dt-user"and login as "service-user" and I mapped
>> 4 drives and only 2 of the drives are mapped persisted (i.e. reconnect at
>> logon). I logout as "service-user" and
>> now I have my app call "net use" programatically and it returns the 2
>> drives that were mapped with persistence.
>> Conclusion: Whatever drives are mapped persisted when logged in as the
>> user the service logs in as, then your
>> app can call "net use" and get those drives returned from "net use" even
>> if your logged in as "dt-user" OR nobody
>> is logged in at all !!!!
>>
>> Maybe someone can confirm my finding, but this is what I see.
>>
>>
> Your findings are all good; reading and digesting and wanting to
> respond/participate since I'm definitely a developer using/deploying-app to
> Windows/tomcat7 . :)
>
> If you could provide a WAR (little test app), I would be more than willing
> to give this a shot on my Windows Server 2008 64-bit (standard/Vista)
> development server and maybe even try it on my Windows Server 2008 R2
> 64-bit (R2 = Windows 7, from what I understand), but I'd have to setup a
> Windows user/environment for this...to mimic what you're doing.
>
> Now, onto the other responses. :)
>
>
Sorry, I was going to say, I still would develop some type of batch file or
some type of app that could run when user logs out of the machine...that
will do a 'net use > \someDriveLetter\someFolder\someFile.txt', and I would
make sure the app reads that file instead of going through the procedure of
logging in as a certain user, logging out, and then running your
tomcat-app-as-service...just so the app can reliably call 'net use' and get
the expected/desired output.

maybe i should have written this response against the last email that you
sent. :)



>
>> Thanks again
>> Pat
>>
>>
>>
>>
>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Mar 25, 2013 at 6:57 PM, Patrick Flaherty
<pf...@rampageinc.com>wrote:

>
> On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:
>
>  On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
>> <pf...@rampageinc.com>**wrote:
>>
>>  Update: If I'm login interactively (meaning machine boots and I login and
>>> get my desktop) and that interactive account matches the service login
>>> account
>>> then "net use" from within the service does return all mapped drives.
>>>
>>>
>>>  I expected as much. It seems as though you cannot get away from the
>> requirement of having to login 'first'...to get everything working as
>> designed/expected in your app.
>>
>> Excuse me, if I missed the business requirement specification (earlier in
>> this conversation), but is the requirement only to get a list of mapped
>> drives for 'your' user login or any enduser that logs into the production
>> server/client/PC/machine?
>>
>> can you add the list of network drives to a database table, and maintain
>> the database table and retrieve the list from that database table via the
>> tomcat-app-running-as-service?
>>
>> if you only need a list of mapped network drives for your user login, can
>> you just maintain a 'file' that has this list on the target/production
>> server, and whenever it changes, can you update the file, and make the
>> topcat-app-running-as-service to always read the file instead of having to
>> call 'net use'?
>>
>> IMHO and FWIW, i would never go with the approach of relying on a windows
>> 'command line' to do this/that for me. yes, in my app, i allow endusers to
>> update files/documents, and the app saves the files/documents to a certain
>> folder on the server, and my app will list those files on a web page, and
>> they can view/download those files from/via the web app... all that is
>> done
>> via java instead of doing a 'cmd.exe dir'. i'm new to java, always wanted
>> to be java developer, and loving what i can do with java. i'm almost
>> getting to the point, where my days of a 'windows user' are done... one
>> day, i hope to migrate to linux for target server instead of windows
>> server. :)
>>
>
> This is what I see. If my service logs in as "service-user" and I login
> normally to my desktop as "dt-user".
> I call "net use" from my service and get an empty list. Now I logout as
> "dt-user"and login as "service-user" and I mapped
> 4 drives and only 2 of the drives are mapped persisted (i.e. reconnect at
> logon). I logout as "service-user" and
> now I have my app call "net use" programatically and it returns the 2
> drives that were mapped with persistence.
> Conclusion: Whatever drives are mapped persisted when logged in as the
> user the service logs in as, then your
> app can call "net use" and get those drives returned from "net use" even
> if your logged in as "dt-user" OR nobody
> is logged in at all !!!!
>
> Maybe someone can confirm my finding, but this is what I see.
>
>
Your findings are all good; reading and digesting and wanting to
respond/participate since I'm definitely a developer using/deploying-app to
Windows/tomcat7 . :)

If you could provide a WAR (little test app), I would be more than willing
to give this a shot on my Windows Server 2008 64-bit (standard/Vista)
development server and maybe even try it on my Windows Server 2008 R2
64-bit (R2 = Windows 7, from what I understand), but I'd have to setup a
Windows user/environment for this...to mimic what you're doing.

Now, onto the other responses. :)


> Thanks again
> Pat
>
>
>
>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Mar 25, 2013 at 7:13 PM, Harris, Jeffrey E. <
Jeffrey.Harris@mantech.com> wrote:

>
> You are on a Windows 7 system, which supports one user logged in at a time.
> I would be interested in seeing how this behaves on a Windows Server 2008
> R2 system,
> configured for multiple users to be logged on at the same time (the
> default for remote
> administration mode is one user at a time).  I do believe this is an
> artifact of the
> Windows 7 architecture (one user at a time) because Windows Server 2008 R2
> has different
> "security zones" (rings) in its kernel implementation for access by
> different components
> (services, drivers, and users) which affect the presentation to the user.
>

First of all, interesting/nice response!

I have Windows Server 2008 R2 (hosting tomcat7/tomee, which is running my
java/JSF web app), but I currently do not have the server
on-or-connected-to any domain (at the moment, and currently there is no
need/requirement for it to be connected to the current Windows domain on
the network); my Windows Server 2003 R2 server is currently (and has
been...for years) running as the domain controller on the network. So, my
Windows Server 2008 R2 server is currently not configured to test this and
provide test results.



> Also, persistent mappings are user specific.  So if usera has two
> persistent drive mappings and
> userb has three different persistent mappings, usera will see his two when
> he is logged on and
> userb will see his three when he is logged on.  Do you have the same
> persistent mappings for dt-user
> and service-user?  You have also stated that you see no mapped drives when
> you run the service, so
> it seems as though starting the service first (and never having anyone
> logged in or dt-user) is an exception.
> Therefore, by extension of what you said above, you only receive the
> mapped drives if
> 1) the service starts first and then the service account logs in
> interactively, or
> 2) the service starts after logging in with the service account.  Did you
> try both of these?
> But once the service "sees" the mappings, it retains it until:  the
> service restarts?  Does
> it matter whether the service restarts with someone logged on (i.e., the
> service account) or no one
> logged in?
>
> I do not think that you have explored all of the conditions required for
> the service to maintain
> its mappings, and that may be fine for your application, but then again,
> it may not be.  That is
> for you to decide.
>
> Jeffrey Harris
>
> This e-mail and any attachments are intended only for the use of the
> addressee(s) named herein and may contain proprietary information. If you
> are not the intended recipient of this e-mail or believe that you received
> this email in error, please take immediate action to notify the sender of
> the apparent error by reply e-mail; permanently delete the e-mail and any
> attachments from your computer; and do not disseminate, distribute, use, or
> copy this message and any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: runtime.exec "cmd.exe /C net use"

Posted by Jeffrey Janner <Je...@PolyDyne.com>.
> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> Sent: Monday, March 25, 2013 7:06 PM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
> 
> 
> On Mar 25, 2013, at 7:13 PM, Harris, Jeffrey E. wrote:
> 
> >
> >
> >> -----Original Message-----
> >> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> >> Sent: Monday, March 25, 2013 6:58 PM
> >> To: Tomcat Users List
> >> Subject: Re: runtime.exec "cmd.exe /C net use"
> >>
> >>
> >> On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:
> >>
> >>> On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
> >>> <pf...@rampageinc.com>wrote:
> >>>
> >>>> Update: If I'm login interactively (meaning machine boots and I
> >> login
> >>>> and get my desktop) and that interactive account matches the
> >>>> service login account then "net use" from within the service does
> >>>> return all mapped drives.
> >>>>
> >>>>
> >>> I expected as much. It seems as though you cannot get away from the
> >>> requirement of having to login 'first'...to get everything working
> >>> as designed/expected in your app.
> >>>
> >>> Excuse me, if I missed the business requirement specification
> >> (earlier
> >>> in this conversation), but is the requirement only to get a list of
> >>> mapped drives for 'your' user login or any enduser that logs into
> >>> the production server/client/PC/machine?
> >>>
> >>> can you add the list of network drives to a database table, and
> >>> maintain the database table and retrieve the list from that
> database
> >>> table via the tomcat-app-running-as-service?
> >>>
> >>> if you only need a list of mapped network drives for your user
> >>> login, can you just maintain a 'file' that has this list on the
> >>> target/production server, and whenever it changes, can you update
> >>> the file, and make the topcat-app-running-as-service to always read
> >>> the file instead of having to call 'net use'?
> >>>
> >>> IMHO and FWIW, i would never go with the approach of relying on a
> >>> windows 'command line' to do this/that for me. yes, in my app, i
> >> allow
> >>> endusers to update files/documents, and the app saves the
> >>> files/documents to a certain folder on the server, and my app will
> >>> list those files on a web page, and they can view/download those
> >> files
> >>> from/via the web app... all that is done via java instead of doing
> a
> >>> 'cmd.exe dir'. i'm new to java, always wanted to be java developer,
> >>> and loving what i can do with java. i'm almost getting to the
> point,
> >>> where my days of a 'windows user' are done...
> >>> one
> >>> day, i hope to migrate to linux for target server instead of
> windows
> >>> server. :)
> >>
> >> This is what I see. If my service logs in as "service-user" and I
> >> login normally to my desktop as "dt-user".
> >> I call "net use" from my service and get an empty list. Now I logout
> >> as "dt-user"and login as "service-user" and I mapped
> >> 4 drives and only 2 of the drives are mapped persisted (i.e.
> >> reconnect
> >> at logon). I logout as "service-user" and now I have my app call
> "net
> >> use" programatically and it returns the 2 drives that were mapped
> >> with persistence.
> >> Conclusion: Whatever drives are mapped persisted when logged in as
> >> the user the service logs in as, then your app can call "net use"
> and
> >> get those drives returned from "net use"
> >> even if your logged in as "dt-user" OR nobody is logged in at all
> >> !!!!
> >>
> >> Maybe someone can confirm my finding, but this is what I see.
> >>
> >> Thanks again
> >> Pat
> >>
> >
> > You are on a Windows 7 system, which supports one user logged in at a
> > time.
> > I would be interested in seeing how this behaves on a Windows Server
> > 2008 R2 system,
> > configured for multiple users to be logged on at the same time (the
> > default for remote administration mode is one user at a time).  I do
> > believe this is an artifact of the Windows 7 architecture (one user
> at
> > a time) because Windows Server
> > 2008 R2 has different
> > "security zones" (rings) in its kernel implementation for access by
> > different components (services, drivers, and users) which affect the
> > presentation to the user.
> >
> > Also, persistent mappings are user specific.  So if usera has two
> > persistent drive mappings and userb has three different persistent
> > mappings, usera will see his two when he is logged on and userb will
> > see his three when he is logged on.  Do you have the same persistent
> > mappings for dt-user and service-user?  You have also stated that you
> > see no mapped drives when you run the service, so it seems as though
> > starting the service first (and never having anyone logged in or
> > dt-user) is an exception.
> > Therefore, by extension of what you said above, you only receive the
> > mapped drives if
> > 1) the service starts first and then the service account logs in
> > interactively, or
> > 2) the service starts after logging in with the service account.
> > Did you try both of these?
> > But once the service "sees" the mappings, it retains it until:  the
> > service restarts?  Does it matter whether the service restarts with
> > someone logged on (i.e., the service account) or no one logged in?
> >
> > I do not think that you have explored all of the conditions required
> > for the service to maintain its mappings, and that may be fine for
> > your application, but then again, it may not be.  That is for you to
> > decide.
> >
> > Jeffrey Harris
> 
> After the the drives are mapped persisted by the "service-user", I
> reboot the computer and have nobody login interactively and my app sees
> all drives that were mapped persistently using "net use". That is my
> app running as a service can programatically see the drives via "net
> use". It is able to derive the drives that were mapped
> *persisted* somehow someway. I have no idea if it's by design or
> whether or not I can hang my hat on it, but it is what I have observed.
> 
> I did not know you could have multiple logins in Windows 2008 R2. You
> don't mean interactive login do you?
> 
> I hope this is clear and thanks for keeping me honest.
> -Pat
> 

Persistence is kept in the user's profile, stored in c:\Documents and Settings\%USER% or the Windows 7 equivalent, which isn't created until someone logs into the system as an Interactive User. The profile is not normally deleted on logoff, so that is why it can persist across reboots, etc.  Note, that persistence is limited to that system unless you set up roaming profiles. If you login on another system, it won't have your mappings, unless you use roaming profiles.  
Services don't do login like interactive user's do.  They will use a profile if it exists, but, by design, do not run login scripts or create/update profiles.  If someone comes along and deletes the profile, then the service will not see the persistent mappings on the next boot.

Relying on Windows for anything in any consistent manner, without fully understanding the underlying architecture, is a recipe for disaster.


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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Mar 25, 2013 at 8:05 PM, Patrick Flaherty
<pf...@rampageinc.com>wrote:

>
> I did not know you could have multiple logins in Windows 2008 R2. You
> don't mean interactive login do you?
>
>
When I first started using Windows Server 2008 (standard/vista version), I
had multiple 'local' users, and the server allowed at least 2 users to be
logged in at one time, and I think I remember the ability to switch between
users via Ctrl-Alt-Delete and/or via Ctrl-L (lock workstation). I would
assume the same is available for Windows Server 2008 R2, but have not tried
it.

did a google search and found this[1]. can you do something similar, create
a separate java app/executable that does your 'net use', and let your
tomcat7-app-running-as-service call the separate app, and 'run as' the
target user that has the network drive list that you desire to
get/retrieve? just a suggestion.

[1] http://stackoverflow.com/questions/1385866/java-run-as-administrator

Re: runtime.exec "cmd.exe /C net use"

Posted by "Terence M. Bandoian" <te...@tmbsw.com>.
On 3/26/2013 8:40 AM, chris derham wrote:
> This thread has been going on for some time now, but why are you using
> drive letters? Can't you just use unc paths and remove all of these
> issues you are having? I searched the thread for UNC and can't see
> that this was asked, but seems like a sensible question.
>
> HTH
>
> Chris


Along those lines, is it possible and practical to modify the shares on 
the file servers to provide the necessary privileges?

-Terence Bandoian

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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Tue, Mar 26, 2013 at 9:40 AM, chris derham <ch...@derham.me.uk> wrote:

> I searched the thread for UNC and can't see that this was asked, but seems
> like a sensible question.
>
>
Jeffrey was the first to respond and that was asked in his first response.
:)

Re: runtime.exec "cmd.exe /C net use"

Posted by chris derham <ch...@derham.me.uk>.
This thread has been going on for some time now, but why are you using
drive letters? Can't you just use unc paths and remove all of these
issues you are having? I searched the thread for UNC and can't see
that this was asked, but seems like a sensible question.

HTH

Chris

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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Tue, Mar 26, 2013 at 9:25 AM, Harris, Jeffrey E. <
Jeffrey.Harris@mantech.com> wrote:

>
>
> > -----Original Message-----
> > From: Howard W. Smith, Jr. [mailto:smithh032772@gmail.com]
> > Sent: Tuesday, March 26, 2013 9:03 AM
> > To: Tomcat Users List
> > Subject: Re: runtime.exec "cmd.exe /C net use"
> >
> > On Tue, Mar 26, 2013 at 8:40 AM, Harris, Jeffrey E. <
> > Jeffrey.Harris@mantech.com> wrote:
> >
> > >
> > >
> > >
> > If you buy a terminal server license, then the cap on two users is
> > removed
> > > (to the limit
> > > specified in the terminal server license), and any users can log in
> > > remotely.
> > >
> > >
> > That's exactly right.
> >
> > In Microsoft terms, terminal server license = Client Access License
> > (CALs).
>
> We are very much off topic here, but that is not exactly right.
>
> A CAL grants the right to access a server (or multiple servers) for
> file and print purposes.
>
> A terminal server license is what lifts the cap on the two remote users.
> And to complicate things further, there are terminal server CALs for
> clients actually using the terminal services enabled by the terminal
> server license!
>
> (And there are separate CALs for other products, such as SQL Server and
> SCCM.)
>
> > Per my experience, Windows Server 2003 (standard version) is sold with
> > 2 CALs, and you can purchase additional, such as 5 CALs, etc...
> >
>
> Standard Editions of Windows Server come bundled with 5 CALs; Enterprise
> editions come bundled with 25.  The two is the limit for remote terminal
> sessions.
>
> > Recently, for the web app that I developed, we got  Windows Server 2008
> > R2, and I think we purchased it with 5 CALs.
> >
> > Client Access Licenses (CALs) allow you to have that many people login
> > simultaneously on the server.
> >
> > For years and ever since we purchased it, only 2 people were able to
> > login to the Windows Server 2003 'remotely' (via Remote Desktop). Why?
> > because we had the default/bundled 2 CALs.
>
>
Understood and I stand corrected. Thanks!


> This e-mail and any attachments are intended only for the use of the
> addressee(s) named herein and may contain proprietary information. If you
> are not the intended recipient of this e-mail or believe that you received
> this email in error, please take immediate action to notify the sender of
> the apparent error by reply e-mail; permanently delete the e-mail and any
> attachments from your computer; and do not disseminate, distribute, use, or
> copy this message and any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Howard W. Smith, Jr. [mailto:smithh032772@gmail.com]
> Sent: Tuesday, March 26, 2013 9:03 AM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
> On Tue, Mar 26, 2013 at 8:40 AM, Harris, Jeffrey E. <
> Jeffrey.Harris@mantech.com> wrote:
>
> >
> >
> >
> If you buy a terminal server license, then the cap on two users is
> removed
> > (to the limit
> > specified in the terminal server license), and any users can log in
> > remotely.
> >
> >
> That's exactly right.
>
> In Microsoft terms, terminal server license = Client Access License
> (CALs).

We are very much off topic here, but that is not exactly right.

A CAL grants the right to access a server (or multiple servers) for
file and print purposes.

A terminal server license is what lifts the cap on the two remote users.
And to complicate things further, there are terminal server CALs for
clients actually using the terminal services enabled by the terminal
server license!

(And there are separate CALs for other products, such as SQL Server and
SCCM.)

> Per my experience, Windows Server 2003 (standard version) is sold with
> 2 CALs, and you can purchase additional, such as 5 CALs, etc...
>

Standard Editions of Windows Server come bundled with 5 CALs; Enterprise
editions come bundled with 25.  The two is the limit for remote terminal sessions.

> Recently, for the web app that I developed, we got  Windows Server 2008
> R2, and I think we purchased it with 5 CALs.
>
> Client Access Licenses (CALs) allow you to have that many people login
> simultaneously on the server.
>
> For years and ever since we purchased it, only 2 people were able to
> login to the Windows Server 2003 'remotely' (via Remote Desktop). Why?
> because we had the default/bundled 2 CALs.

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Tue, Mar 26, 2013 at 8:40 AM, Harris, Jeffrey E. <
Jeffrey.Harris@mantech.com> wrote:

>
>
>
If you buy a terminal server license, then the cap on two users is removed
> (to the limit
> specified in the terminal server license), and any users can log in
> remotely.
>
>
That's exactly right.

In Microsoft terms, terminal server license = Client Access License (CALs).
Per my experience, Windows Server 2003 (standard version) is sold with 2
CALs, and you can purchase additional, such as 5 CALs, etc...

Recently, for the web app that I developed, we got  Windows Server 2008 R2,
and I think we purchased it with 5 CALs.

Client Access Licenses (CALs) allow you to have that many people login
simultaneously on the server.

For years and ever since we purchased it, only 2 people were able to login
to the Windows Server 2003 'remotely' (via Remote Desktop). Why? because we
had the default/bundled 2 CALs.

RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> Sent: Monday, March 25, 2013 8:06 PM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
>
> On Mar 25, 2013, at 7:13 PM, Harris, Jeffrey E. wrote:
>
>
> After the the drives are mapped persisted by the "service-user", I
> reboot the computer and have nobody login interactively and my app sees
> all drives that were mapped persistently using "net use". That is my
> app running as a service can programatically see the drives via "net
> use". It is able to derive the drives that were mapped
> *persisted* somehow someway. I have no idea if it's by design or
> whether or not I can hang my hat on it, but it is what I have observed.
>

Someone would have to do further research to explain why this works.  I cannot.

> I did not know you could have multiple logins in Windows 2008 R2. You
> don't mean interactive login do you?
>

Yes, interactively, but remotely.  Every Windows operating system since Windows Server 2000
supports "remote administration mode" which out of the box allows two remote terminal
sessions by administrators (or other users given the right to log in remotely).
There is actually a third session allowed, which is the console (local) session.  There can
only be one user logged in at a time to the console, but it can be any user that
exists as a local account on the server or a domain user if the server is in a domain
(the one exception is domain controllers; by default, only administrators and accounts
in certain other groups can log in locally to a domain controller).

However, in Windows Server 2008 and later, they changed the default so only one user is logged
in at a time, ala Windows 7, but unlike Windows 7, it can revert to the earlier behavior by
changing local or group policy to allow multiple user logins (up to the three discussed
previously).

If you buy a terminal server license, then the cap on two users is removed (to the limit
specified in the terminal server license), and any users can log in remotely.

> I hope this is clear and thanks for keeping me honest.
> -Pat
>
> >

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 25, 2013, at 7:13 PM, Harris, Jeffrey E. wrote:

>
>
>> -----Original Message-----
>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>> Sent: Monday, March 25, 2013 6:58 PM
>> To: Tomcat Users List
>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>
>>
>> On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:
>>
>>> On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
>>> <pf...@rampageinc.com>wrote:
>>>
>>>> Update: If I'm login interactively (meaning machine boots and I
>> login
>>>> and get my desktop) and that interactive account matches the  
>>>> service
>>>> login account then "net use" from within the service does return  
>>>> all
>>>> mapped drives.
>>>>
>>>>
>>> I expected as much. It seems as though you cannot get away from the
>>> requirement of having to login 'first'...to get everything working  
>>> as
>>> designed/expected in your app.
>>>
>>> Excuse me, if I missed the business requirement specification
>> (earlier
>>> in this conversation), but is the requirement only to get a list of
>>> mapped drives for 'your' user login or any enduser that logs into  
>>> the
>>> production server/client/PC/machine?
>>>
>>> can you add the list of network drives to a database table, and
>>> maintain the database table and retrieve the list from that database
>>> table via the tomcat-app-running-as-service?
>>>
>>> if you only need a list of mapped network drives for your user  
>>> login,
>>> can you just maintain a 'file' that has this list on the
>>> target/production server, and whenever it changes, can you update  
>>> the
>>> file, and make the topcat-app-running-as-service to always read the
>>> file instead of having to call 'net use'?
>>>
>>> IMHO and FWIW, i would never go with the approach of relying on a
>>> windows 'command line' to do this/that for me. yes, in my app, i
>> allow
>>> endusers to update files/documents, and the app saves the
>>> files/documents to a certain folder on the server, and my app will
>>> list those files on a web page, and they can view/download those
>> files
>>> from/via the web app... all that is done via java instead of doing a
>>> 'cmd.exe dir'. i'm new to java, always wanted to be java developer,
>>> and loving what i can do with java. i'm almost getting to the point,
>>> where my days of a 'windows user' are done...
>>> one
>>> day, i hope to migrate to linux for target server instead of windows
>>> server. :)
>>
>> This is what I see. If my service logs in as "service-user" and I  
>> login
>> normally to my desktop as "dt-user".
>> I call "net use" from my service and get an empty list. Now I  
>> logout as
>> "dt-user"and login as "service-user" and I mapped
>> 4 drives and only 2 of the drives are mapped persisted (i.e.  
>> reconnect
>> at logon). I logout as "service-user" and now I have my app call "net
>> use" programatically and it returns the 2 drives that were mapped  
>> with
>> persistence.
>> Conclusion: Whatever drives are mapped persisted when logged in as  
>> the
>> user the service logs in as, then your app can call "net use" and get
>> those drives returned from "net use"
>> even if your logged in as "dt-user" OR nobody is logged in at  
>> all !!!!
>>
>> Maybe someone can confirm my finding, but this is what I see.
>>
>> Thanks again
>> Pat
>>
>
> You are on a Windows 7 system, which supports one user logged in at  
> a time.
> I would be interested in seeing how this behaves on a Windows Server  
> 2008 R2 system,
> configured for multiple users to be logged on at the same time (the  
> default for remote
> administration mode is one user at a time).  I do believe this is an  
> artifact of the
> Windows 7 architecture (one user at a time) because Windows Server  
> 2008 R2 has different
> "security zones" (rings) in its kernel implementation for access by  
> different components
> (services, drivers, and users) which affect the presentation to the  
> user.
>
> Also, persistent mappings are user specific.  So if usera has two  
> persistent drive mappings and
> userb has three different persistent mappings, usera will see his  
> two when he is logged on and
> userb will see his three when he is logged on.  Do you have the same  
> persistent mappings for dt-user
> and service-user?  You have also stated that you see no mapped  
> drives when you run the service, so
> it seems as though starting the service first (and never having  
> anyone logged in or dt-user) is an exception.
> Therefore, by extension of what you said above, you only receive the  
> mapped drives if
> 1) the service starts first and then the service account logs in  
> interactively, or
> 2) the service starts after logging in with the service account.   
> Did you try both of these?
> But once the service "sees" the mappings, it retains it until:  the  
> service restarts?  Does
> it matter whether the service restarts with someone logged on (i.e.,  
> the service account) or no one
> logged in?
>
> I do not think that you have explored all of the conditions required  
> for the service to maintain
> its mappings, and that may be fine for your application, but then  
> again, it may not be.  That is
> for you to decide.
>
> Jeffrey Harris

After the the drives are mapped persisted by the "service-user", I  
reboot the computer and have nobody login interactively
and my app sees all drives that were mapped persistently using "net  
use". That is my app running as a service can programatically see the
drives via "net use". It is able to derive the drives that were mapped  
*persisted* somehow someway. I have no idea if it's by
design or whether or not I can hang my hat on it, but it is what I  
have observed.

I did not know you could have multiple logins in Windows 2008 R2. You  
don't mean interactive login do you?

I hope this is clear and thanks for keeping me honest.
-Pat

>
> This e-mail and any attachments are intended only for the use of the  
> addressee(s) named herein and may contain proprietary information.  
> If you are not the intended recipient of this e-mail or believe that  
> you received this email in error, please take immediate action to  
> notify the sender of the apparent error by reply e-mail; permanently  
> delete the e-mail and any attachments from your computer; and do not  
> disseminate, distribute, use, or copy this message and any  
> attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> Sent: Monday, March 25, 2013 6:58 PM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
>
> On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:
>
> > On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
> > <pf...@rampageinc.com>wrote:
> >
> >> Update: If I'm login interactively (meaning machine boots and I
> login
> >> and get my desktop) and that interactive account matches the service
> >> login account then "net use" from within the service does return all
> >> mapped drives.
> >>
> >>
> > I expected as much. It seems as though you cannot get away from the
> > requirement of having to login 'first'...to get everything working as
> > designed/expected in your app.
> >
> > Excuse me, if I missed the business requirement specification
> (earlier
> > in this conversation), but is the requirement only to get a list of
> > mapped drives for 'your' user login or any enduser that logs into the
> > production server/client/PC/machine?
> >
> > can you add the list of network drives to a database table, and
> > maintain the database table and retrieve the list from that database
> > table via the tomcat-app-running-as-service?
> >
> > if you only need a list of mapped network drives for your user login,
> > can you just maintain a 'file' that has this list on the
> > target/production server, and whenever it changes, can you update the
> > file, and make the topcat-app-running-as-service to always read the
> > file instead of having to call 'net use'?
> >
> > IMHO and FWIW, i would never go with the approach of relying on a
> > windows 'command line' to do this/that for me. yes, in my app, i
> allow
> > endusers to update files/documents, and the app saves the
> > files/documents to a certain folder on the server, and my app will
> > list those files on a web page, and they can view/download those
> files
> > from/via the web app... all that is done via java instead of doing a
> > 'cmd.exe dir'. i'm new to java, always wanted to be java developer,
> > and loving what i can do with java. i'm almost getting to the point,
> > where my days of a 'windows user' are done...
> > one
> > day, i hope to migrate to linux for target server instead of windows
> > server. :)
>
> This is what I see. If my service logs in as "service-user" and I login
> normally to my desktop as "dt-user".
> I call "net use" from my service and get an empty list. Now I logout as
> "dt-user"and login as "service-user" and I mapped
> 4 drives and only 2 of the drives are mapped persisted (i.e. reconnect
> at logon). I logout as "service-user" and now I have my app call "net
> use" programatically and it returns the 2 drives that were mapped with
> persistence.
> Conclusion: Whatever drives are mapped persisted when logged in as the
> user the service logs in as, then your app can call "net use" and get
> those drives returned from "net use"
> even if your logged in as "dt-user" OR nobody is logged in at all !!!!
>
> Maybe someone can confirm my finding, but this is what I see.
>
> Thanks again
> Pat
>

You are on a Windows 7 system, which supports one user logged in at a time.
I would be interested in seeing how this behaves on a Windows Server 2008 R2 system,
configured for multiple users to be logged on at the same time (the default for remote
administration mode is one user at a time).  I do believe this is an artifact of the
Windows 7 architecture (one user at a time) because Windows Server 2008 R2 has different
"security zones" (rings) in its kernel implementation for access by different components
(services, drivers, and users) which affect the presentation to the user.

Also, persistent mappings are user specific.  So if usera has two persistent drive mappings and
userb has three different persistent mappings, usera will see his two when he is logged on and
userb will see his three when he is logged on.  Do you have the same persistent mappings for dt-user
and service-user?  You have also stated that you see no mapped drives when you run the service, so
it seems as though starting the service first (and never having anyone logged in or dt-user) is an exception.
Therefore, by extension of what you said above, you only receive the mapped drives if
1) the service starts first and then the service account logs in interactively, or
2) the service starts after logging in with the service account.  Did you try both of these?
But once the service "sees" the mappings, it retains it until:  the service restarts?  Does
it matter whether the service restarts with someone logged on (i.e., the service account) or no one
logged in?

I do not think that you have explored all of the conditions required for the service to maintain
its mappings, and that may be fine for your application, but then again, it may not be.  That is
for you to decide.

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 25, 2013, at 1:15 PM, Howard W. Smith, Jr. wrote:

> On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
> <pf...@rampageinc.com>wrote:
>
>> Update: If I'm login interactively (meaning machine boots and I  
>> login and
>> get my desktop) and that interactive account matches the service  
>> login
>> account
>> then "net use" from within the service does return all mapped drives.
>>
>>
> I expected as much. It seems as though you cannot get away from the
> requirement of having to login 'first'...to get everything working as
> designed/expected in your app.
>
> Excuse me, if I missed the business requirement specification  
> (earlier in
> this conversation), but is the requirement only to get a list of  
> mapped
> drives for 'your' user login or any enduser that logs into the  
> production
> server/client/PC/machine?
>
> can you add the list of network drives to a database table, and  
> maintain
> the database table and retrieve the list from that database table  
> via the
> tomcat-app-running-as-service?
>
> if you only need a list of mapped network drives for your user  
> login, can
> you just maintain a 'file' that has this list on the target/production
> server, and whenever it changes, can you update the file, and make the
> topcat-app-running-as-service to always read the file instead of  
> having to
> call 'net use'?
>
> IMHO and FWIW, i would never go with the approach of relying on a  
> windows
> 'command line' to do this/that for me. yes, in my app, i allow  
> endusers to
> update files/documents, and the app saves the files/documents to a  
> certain
> folder on the server, and my app will list those files on a web  
> page, and
> they can view/download those files from/via the web app... all that  
> is done
> via java instead of doing a 'cmd.exe dir'. i'm new to java, always  
> wanted
> to be java developer, and loving what i can do with java. i'm almost
> getting to the point, where my days of a 'windows user' are done...  
> one
> day, i hope to migrate to linux for target server instead of windows
> server. :)

This is what I see. If my service logs in as "service-user" and I  
login normally to my desktop as "dt-user".
I call "net use" from my service and get an empty list. Now I logout  
as "dt-user"and login as "service-user" and I mapped
4 drives and only 2 of the drives are mapped persisted (i.e. reconnect  
at logon). I logout as "service-user" and
now I have my app call "net use" programatically and it returns the 2  
drives that were mapped with persistence.
Conclusion: Whatever drives are mapped persisted when logged in as the  
user the service logs in as, then your
app can call "net use" and get those drives returned from "net use"  
even if your logged in as "dt-user" OR nobody
is logged in at all !!!!

Maybe someone can confirm my finding, but this is what I see.

Thanks again
Pat






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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Mar 25, 2013 at 11:14 AM, Patrick Flaherty
<pf...@rampageinc.com>wrote:

> Update: If I'm login interactively (meaning machine boots and I login and
> get my desktop) and that interactive account matches the service login
> account
> then "net use" from within the service does return all mapped drives.
>
>
I expected as much. It seems as though you cannot get away from the
requirement of having to login 'first'...to get everything working as
designed/expected in your app.

Excuse me, if I missed the business requirement specification (earlier in
this conversation), but is the requirement only to get a list of mapped
drives for 'your' user login or any enduser that logs into the production
server/client/PC/machine?

can you add the list of network drives to a database table, and maintain
the database table and retrieve the list from that database table via the
tomcat-app-running-as-service?

if you only need a list of mapped network drives for your user login, can
you just maintain a 'file' that has this list on the target/production
server, and whenever it changes, can you update the file, and make the
topcat-app-running-as-service to always read the file instead of having to
call 'net use'?

IMHO and FWIW, i would never go with the approach of relying on a windows
'command line' to do this/that for me. yes, in my app, i allow endusers to
update files/documents, and the app saves the files/documents to a certain
folder on the server, and my app will list those files on a web page, and
they can view/download those files from/via the web app... all that is done
via java instead of doing a 'cmd.exe dir'. i'm new to java, always wanted
to be java developer, and loving what i can do with java. i'm almost
getting to the point, where my days of a 'windows user' are done... one
day, i hope to migrate to linux for target server instead of windows
server. :)

Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 25, 2013, at 11:59 AM, Harris, Jeffrey E. wrote:

>
>
>> -----Original Message-----
>> Update: If I'm login interactively (meaning machine boots and I login
>> and get my desktop) and that interactive account matches the service
>> login account then "net use" from within the service does return all
>> mapped drives.
>> I'm not sure if that is by design or is something I can hang my hat  
>> on
>> but it is the case with Windows 7 SP1.
>>
>> Thanks again
>> Pat
>>
>>
>>
>
> Interesting.  It is possible that if you are already logged in, and  
> start
> the service, it does not need to log in separately as the service.   
> Does this work
> whether you start the service before or after you log in interactively
> with the same account?

I just tested this and the order does not matter. Works for both  
sequences.
>
> In any case, I am not sure you can rely on that because it does  
> require an interactive
> login, and if your system reboots in the middle of the night  
> (whether because of an
> unplanned event or installation of Microsoft updates, depending on  
> your server is
> configured), you will not be there to log in interactively so the  
> net share list
> is available, and you probably do not want to set automatic login  
> for the account.
We only use it to populate a UI where you select a path that gets  
stored in a DB. Path is used as destination for scheduled backups.
So for us it will not present a problem.

>
> Jeffrey Harris
>
> This e-mail and any attachments are intended only for the use of the  
> addressee(s) named herein and may contain proprietary information.  
> If you are not the intended recipient of this e-mail or believe that  
> you received this email in error, please take immediate action to  
> notify the sender of the apparent error by reply e-mail; permanently  
> delete the e-mail and any attachments from your computer; and do not  
> disseminate, distribute, use, or copy this message and any  
> attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> Update: If I'm login interactively (meaning machine boots and I login
> and get my desktop) and that interactive account matches the service
> login account then "net use" from within the service does return all
> mapped drives.
> I'm not sure if that is by design or is something I can hang my hat on
> but it is the case with Windows 7 SP1.
>
> Thanks again
> Pat
>
>
>

Interesting.  It is possible that if you are already logged in, and start
the service, it does not need to log in separately as the service.  Does this work
whether you start the service before or after you log in interactively
with the same account?

In any case, I am not sure you can rely on that because it does require an interactive
login, and if your system reboots in the middle of the night (whether because of an
unplanned event or installation of Microsoft updates, depending on your server is
configured), you will not be there to log in interactively so the net share list
is available, and you probably do not want to set automatic login for the account.

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 25, 2013, at 6:03 AM, André Warnier wrote:

> Howard W. Smith, Jr. wrote:
>> On Sun, Mar 24, 2013 at 7:14 PM, Howard W. Smith, Jr. <
>> smithh032772@gmail.com> wrote:
>>>
>>>> Hi Jeffrey,
>>>>
>>>> Yes, I now get it. Thanks for the lesson on Windows Networking (I  
>>>> thought
>>>> I knew well) and thanks to Andre as well.
>>>> You also said that if all I wanted to do was make a list of mapping
>>>> appear in an html page (without actually using them
>>>> in your application), you can just fake it as previously  
>>>> discussed. I
>>>> think I missed that part.
>>>>
>>>> Thanks
>>>> Pat
>>>>
>>>>
>>>>
>>> Glad you understand now. I was about to provide a response similar  
>>> to
>>> Andre's previous response. This all reminds me of a similar  
>>> situation
>>> within my TomEE/Tomcat7 web app.
>>>
>>> On my development server (Windows 2008 server 64-bit), I am 'always'
>>> logged in and coding/etc, which means I always test the web app via
>>> NetBeans (which provide the infamous 'console' that is mentioned  
>>> throughout
>>> this thread). I developed this piece of code that uses  
>>> JODConverter to call
>>> OpenOffice.org at/via port 2002, and this allows my web app to  
>>> convert
>>> files to PDF after enduser uploads certain documents (Word docs,  
>>> excel,
>>> etc...). So, that all works on my development server. Why? because  
>>> I am
>>> logged in everytime while testing and the app is 'never' running  
>>> as a
>>> Windows 'service' on my development server.
>>>
>>> So, i deploy my web app to target/production server (Windows 2003  
>>> Server
>>> and/or Windows Server 2008). For many months now, I have wondered  
>>> 'why' the
>>> code will not work on the 'production' server but it runs/works  
>>> 'everytime'
>>> on my development server. Finally, recently (after many months of  
>>> research
>>> and/or multiple attempts of trying to debug/resolve the problem),  
>>> I either
>>> read somewhere or finally realized that the code will 'not' work  
>>> because my
>>> web app is running as a service, and for whatever reason (of  
>>> course a
>>> 'Windows' reason), the code will 'not' work while running as a  
>>> service.
>>>
>>> So, I am left to coding another implementation to convert files  
>>> after
>>> upload, use another library, and ditch the JODConverter/ 
>>> OpenOffice.org
>>> approach.
>>>
>>>
>> Forgot to mention... since OpenOffice.org can be installed in the  
>> Startup
>> folder, i was assuming that it would run as a service on production  
>> server,
>> and/but I forgot that Startup folder just automatically starts the  
>> app
>> immediately when/after you login. OpenOffice.org is 'not' running  
>> as a
>> service, and since my web app is running as a service (in a different
>> 'environment'), my web app was unable to access OpenOffice.org,  
>> because
>> clearly/definitely/evidently, it was not/never running as a  
>> 'service'..
>> which means it was never available to my web app. :(
>
> And, to get back more OT, that may be the fundamental difference  
> with my succesful usage of the same : in my case, it is my service  
> program which launches the background OpenOffice instance, which  
> most probably means that it too is running in the same service  
> context a the main service program.
> (Which brings us back to the same context as this thread).
Update: If I'm login interactively (meaning machine boots and I login  
and get my desktop) and that interactive account matches the service  
login account
then "net use" from within the service does return all mapped drives.  
I'm not sure if that is by design or is something I can hang my hat on  
but it is the case
with Windows 7 SP1.

Thanks again
Pat



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


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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Mar 25, 2013 at 6:03 AM, André Warnier <aw...@ice-sa.com> wrote:

> Howard W. Smith, Jr. wrote:
>
>> On Sun, Mar 24, 2013 at 7:14 PM, Howard W. Smith, Jr. <
>> smithh032772@gmail.com> wrote:
>>
>>
>>>  Hi Jeffrey,
>>>>
>>>> Yes, I now get it. Thanks for the lesson on Windows Networking (I
>>>> thought
>>>> I knew well) and thanks to Andre as well.
>>>> You also said that if all I wanted to do was make a list of mapping
>>>> appear in an html page (without actually using them
>>>> in your application), you can just fake it as previously discussed. I
>>>> think I missed that part.
>>>>
>>>> Thanks
>>>> Pat
>>>>
>>>>
>>>>
>>>>  Glad you understand now. I was about to provide a response similar to
>>> Andre's previous response. This all reminds me of a similar situation
>>> within my TomEE/Tomcat7 web app.
>>>
>>> On my development server (Windows 2008 server 64-bit), I am 'always'
>>> logged in and coding/etc, which means I always test the web app via
>>> NetBeans (which provide the infamous 'console' that is mentioned
>>> throughout
>>> this thread). I developed this piece of code that uses JODConverter to
>>> call
>>> OpenOffice.org at/via port 2002, and this allows my web app to convert
>>> files to PDF after enduser uploads certain documents (Word docs, excel,
>>> etc...). So, that all works on my development server. Why? because I am
>>> logged in everytime while testing and the app is 'never' running as a
>>> Windows 'service' on my development server.
>>>
>>> So, i deploy my web app to target/production server (Windows 2003 Server
>>> and/or Windows Server 2008). For many months now, I have wondered 'why'
>>> the
>>> code will not work on the 'production' server but it runs/works
>>> 'everytime'
>>> on my development server. Finally, recently (after many months of
>>> research
>>> and/or multiple attempts of trying to debug/resolve the problem), I
>>> either
>>> read somewhere or finally realized that the code will 'not' work because
>>> my
>>> web app is running as a service, and for whatever reason (of course a
>>> 'Windows' reason), the code will 'not' work while running as a service.
>>>
>>> So, I am left to coding another implementation to convert files after
>>> upload, use another library, and ditch the JODConverter/OpenOffice.org
>>> approach.
>>>
>>>
>>>  Forgot to mention... since OpenOffice.org can be installed in the
>> Startup
>> folder, i was assuming that it would run as a service on production
>> server,
>> and/but I forgot that Startup folder just automatically starts the app
>> immediately when/after you login. OpenOffice.org is 'not' running as a
>> service, and since my web app is running as a service (in a different
>> 'environment'), my web app was unable to access OpenOffice.org, because
>> clearly/definitely/evidently, it was not/never running as a 'service'..
>> which means it was never available to my web app. :(
>>
>>
> And, to get back more OT, that may be the fundamental difference with my
> succesful usage of the same : in my case, it is my service program which
> launches the background OpenOffice instance, which most probably means that
> it too is running in the same service context a the main service program.
> (Which brings us back to the same context as this thread).
>
>
+1 I have realized that this seems to be necessary (if want a
tomcat-app-running-as-service able to access some other Windows
app-or-command-line-executable, then Windows app must be running as
service, first-and-foremost). I may give this a go, or try it out, ASAP.
thanks!


>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: runtime.exec "cmd.exe /C net use"

Posted by André Warnier <aw...@ice-sa.com>.
Howard W. Smith, Jr. wrote:
> On Sun, Mar 24, 2013 at 7:14 PM, Howard W. Smith, Jr. <
> smithh032772@gmail.com> wrote:
> 
>>
>>> Hi Jeffrey,
>>>
>>> Yes, I now get it. Thanks for the lesson on Windows Networking (I thought
>>> I knew well) and thanks to Andre as well.
>>> You also said that if all I wanted to do was make a list of mapping
>>> appear in an html page (without actually using them
>>> in your application), you can just fake it as previously discussed. I
>>> think I missed that part.
>>>
>>> Thanks
>>> Pat
>>>
>>>
>>>
>> Glad you understand now. I was about to provide a response similar to
>> Andre's previous response. This all reminds me of a similar situation
>> within my TomEE/Tomcat7 web app.
>>
>> On my development server (Windows 2008 server 64-bit), I am 'always'
>> logged in and coding/etc, which means I always test the web app via
>> NetBeans (which provide the infamous 'console' that is mentioned throughout
>> this thread). I developed this piece of code that uses JODConverter to call
>> OpenOffice.org at/via port 2002, and this allows my web app to convert
>> files to PDF after enduser uploads certain documents (Word docs, excel,
>> etc...). So, that all works on my development server. Why? because I am
>> logged in everytime while testing and the app is 'never' running as a
>> Windows 'service' on my development server.
>>
>> So, i deploy my web app to target/production server (Windows 2003 Server
>> and/or Windows Server 2008). For many months now, I have wondered 'why' the
>> code will not work on the 'production' server but it runs/works 'everytime'
>> on my development server. Finally, recently (after many months of research
>> and/or multiple attempts of trying to debug/resolve the problem), I either
>> read somewhere or finally realized that the code will 'not' work because my
>> web app is running as a service, and for whatever reason (of course a
>> 'Windows' reason), the code will 'not' work while running as a service.
>>
>> So, I am left to coding another implementation to convert files after
>> upload, use another library, and ditch the JODConverter/OpenOffice.org
>> approach.
>>
>>
> Forgot to mention... since OpenOffice.org can be installed in the Startup
> folder, i was assuming that it would run as a service on production server,
> and/but I forgot that Startup folder just automatically starts the app
> immediately when/after you login. OpenOffice.org is 'not' running as a
> service, and since my web app is running as a service (in a different
> 'environment'), my web app was unable to access OpenOffice.org, because
> clearly/definitely/evidently, it was not/never running as a 'service'..
> which means it was never available to my web app. :(
> 

And, to get back more OT, that may be the fundamental difference with my succesful usage 
of the same : in my case, it is my service program which launches the background 
OpenOffice instance, which most probably means that it too is running in the same service 
context a the main service program.
(Which brings us back to the same context as this thread).



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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Sun, Mar 24, 2013 at 7:14 PM, Howard W. Smith, Jr. <
smithh032772@gmail.com> wrote:

>
>
>> Hi Jeffrey,
>>
>> Yes, I now get it. Thanks for the lesson on Windows Networking (I thought
>> I knew well) and thanks to Andre as well.
>> You also said that if all I wanted to do was make a list of mapping
>> appear in an html page (without actually using them
>> in your application), you can just fake it as previously discussed. I
>> think I missed that part.
>>
>> Thanks
>> Pat
>>
>>
>>
> Glad you understand now. I was about to provide a response similar to
> Andre's previous response. This all reminds me of a similar situation
> within my TomEE/Tomcat7 web app.
>
> On my development server (Windows 2008 server 64-bit), I am 'always'
> logged in and coding/etc, which means I always test the web app via
> NetBeans (which provide the infamous 'console' that is mentioned throughout
> this thread). I developed this piece of code that uses JODConverter to call
> OpenOffice.org at/via port 2002, and this allows my web app to convert
> files to PDF after enduser uploads certain documents (Word docs, excel,
> etc...). So, that all works on my development server. Why? because I am
> logged in everytime while testing and the app is 'never' running as a
> Windows 'service' on my development server.
>
> So, i deploy my web app to target/production server (Windows 2003 Server
> and/or Windows Server 2008). For many months now, I have wondered 'why' the
> code will not work on the 'production' server but it runs/works 'everytime'
> on my development server. Finally, recently (after many months of research
> and/or multiple attempts of trying to debug/resolve the problem), I either
> read somewhere or finally realized that the code will 'not' work because my
> web app is running as a service, and for whatever reason (of course a
> 'Windows' reason), the code will 'not' work while running as a service.
>
> So, I am left to coding another implementation to convert files after
> upload, use another library, and ditch the JODConverter/OpenOffice.org
> approach.
>
>
Forgot to mention... since OpenOffice.org can be installed in the Startup
folder, i was assuming that it would run as a service on production server,
and/but I forgot that Startup folder just automatically starts the app
immediately when/after you login. OpenOffice.org is 'not' running as a
service, and since my web app is running as a service (in a different
'environment'), my web app was unable to access OpenOffice.org, because
clearly/definitely/evidently, it was not/never running as a 'service'..
which means it was never available to my web app. :(

Re: [somewhat OT] runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
On Mon, Mar 25, 2013 at 5:50 AM, André Warnier <aw...@ice-sa.com> wrote:

> Howard W. Smith, Jr. wrote:
>
>> Hi Jeffrey,
>>>
>>> Yes, I now get it. Thanks for the lesson on Windows Networking (I thought
>>> I knew well) and thanks to Andre as well.
>>> You also said that if all I wanted to do was make a list of mapping
>>> appear
>>> in an html page (without actually using them
>>> in your application), you can just fake it as previously discussed. I
>>> think I missed that part.
>>>
>>> Thanks
>>> Pat
>>>
>>>
>>>
>>>  Glad you understand now. I was about to provide a response similar to
>> Andre's previous response. This all reminds me of a similar situation
>> within my TomEE/Tomcat7 web app.
>>
>> On my development server (Windows 2008 server 64-bit), I am 'always'
>> logged
>> in and coding/etc, which means I always test the web app via NetBeans
>> (which provide the infamous 'console' that is mentioned throughout this
>> thread). I developed this piece of code that uses JODConverter to call
>> OpenOffice.org at/via port 2002, and this allows my web app to convert
>> files to PDF after enduser uploads certain documents (Word docs, excel,
>> etc...). So, that all works on my development server. Why? because I am
>> logged in everytime while testing and the app is 'never' running as a
>> Windows 'service' on my development server.
>>
>> So, i deploy my web app to target/production server (Windows 2003 Server
>> and/or Windows Server 2008). For many months now, I have wondered 'why'
>> the
>> code will not work on the 'production' server but it runs/works
>> 'everytime'
>> on my development server. Finally, recently (after many months of research
>> and/or multiple attempts of trying to debug/resolve the problem), I either
>> read somewhere or finally realized that the code will 'not' work because
>> my
>> web app is running as a service, and for whatever reason (of course a
>> 'Windows' reason), the code will 'not' work while running as a service.
>>
>> So, I am left to coding another implementation to convert files after
>> upload, use another library, and ditch the JODConverter/OpenOffice.org
>> approach.
>>
>>
> Maybe of interest to you : I do use JODConverter+OpenOffice in the
> circumstances which you describe (and for the same reason), within a perl
> program running as a Windows Service, and it works fine.  I don't think I
> have ever precisely done that on a Windows 2008 Server, but I do have that
> running on various other Windows platforms (Win2K, WinXP, Windows-7,
> Windows 2003 server) since years, and have converted hundreds of thousands
> of documents with it.
> (A bit on the side : you may also want to have a look at LibreOffice,
> which does away with the need of a JODConverter-like interface; but I do
> not know (yet) how good it is at generating PDFs from MS-Office documents).
>
> If I can help, we can continue this discussion off-list if you want.
>
>
Interesting indeed and thanks for the response. I knew (and was confident)
that there was way to get it all working, that I was tried-and-tried for
months (multiple attempts) to get it working, and still, i have 'not'
ultimately removed it from the app...lol. I've added many things to the app
and endusers are not using all the nice bells and whistles that I have
added. they pretty much use what they really need to complete day-to-day
operations. sometimes, i add things to the app that I know would be useful
(for power users...like myself).


>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: [somewhat OT] runtime.exec "cmd.exe /C net use"

Posted by André Warnier <aw...@ice-sa.com>.
Howard W. Smith, Jr. wrote:
>> Hi Jeffrey,
>>
>> Yes, I now get it. Thanks for the lesson on Windows Networking (I thought
>> I knew well) and thanks to Andre as well.
>> You also said that if all I wanted to do was make a list of mapping appear
>> in an html page (without actually using them
>> in your application), you can just fake it as previously discussed. I
>> think I missed that part.
>>
>> Thanks
>> Pat
>>
>>
>>
> Glad you understand now. I was about to provide a response similar to
> Andre's previous response. This all reminds me of a similar situation
> within my TomEE/Tomcat7 web app.
> 
> On my development server (Windows 2008 server 64-bit), I am 'always' logged
> in and coding/etc, which means I always test the web app via NetBeans
> (which provide the infamous 'console' that is mentioned throughout this
> thread). I developed this piece of code that uses JODConverter to call
> OpenOffice.org at/via port 2002, and this allows my web app to convert
> files to PDF after enduser uploads certain documents (Word docs, excel,
> etc...). So, that all works on my development server. Why? because I am
> logged in everytime while testing and the app is 'never' running as a
> Windows 'service' on my development server.
> 
> So, i deploy my web app to target/production server (Windows 2003 Server
> and/or Windows Server 2008). For many months now, I have wondered 'why' the
> code will not work on the 'production' server but it runs/works 'everytime'
> on my development server. Finally, recently (after many months of research
> and/or multiple attempts of trying to debug/resolve the problem), I either
> read somewhere or finally realized that the code will 'not' work because my
> web app is running as a service, and for whatever reason (of course a
> 'Windows' reason), the code will 'not' work while running as a service.
> 
> So, I am left to coding another implementation to convert files after
> upload, use another library, and ditch the JODConverter/OpenOffice.org
> approach.
> 

Maybe of interest to you : I do use JODConverter+OpenOffice in the circumstances which you 
describe (and for the same reason), within a perl program running as a Windows Service, 
and it works fine.  I don't think I have ever precisely done that on a Windows 2008 
Server, but I do have that running on various other Windows platforms (Win2K, WinXP, 
Windows-7, Windows 2003 server) since years, and have converted hundreds of thousands of 
documents with it.
(A bit on the side : you may also want to have a look at LibreOffice, which does away with 
the need of a JODConverter-like interface; but I do not know (yet) how good it is at 
generating PDFs from MS-Office documents).

If I can help, we can continue this discussion off-list if you want.



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


Re: runtime.exec "cmd.exe /C net use"

Posted by "Howard W. Smith, Jr." <sm...@gmail.com>.
> Hi Jeffrey,
>
> Yes, I now get it. Thanks for the lesson on Windows Networking (I thought
> I knew well) and thanks to Andre as well.
> You also said that if all I wanted to do was make a list of mapping appear
> in an html page (without actually using them
> in your application), you can just fake it as previously discussed. I
> think I missed that part.
>
> Thanks
> Pat
>
>
>
Glad you understand now. I was about to provide a response similar to
Andre's previous response. This all reminds me of a similar situation
within my TomEE/Tomcat7 web app.

On my development server (Windows 2008 server 64-bit), I am 'always' logged
in and coding/etc, which means I always test the web app via NetBeans
(which provide the infamous 'console' that is mentioned throughout this
thread). I developed this piece of code that uses JODConverter to call
OpenOffice.org at/via port 2002, and this allows my web app to convert
files to PDF after enduser uploads certain documents (Word docs, excel,
etc...). So, that all works on my development server. Why? because I am
logged in everytime while testing and the app is 'never' running as a
Windows 'service' on my development server.

So, i deploy my web app to target/production server (Windows 2003 Server
and/or Windows Server 2008). For many months now, I have wondered 'why' the
code will not work on the 'production' server but it runs/works 'everytime'
on my development server. Finally, recently (after many months of research
and/or multiple attempts of trying to debug/resolve the problem), I either
read somewhere or finally realized that the code will 'not' work because my
web app is running as a service, and for whatever reason (of course a
'Windows' reason), the code will 'not' work while running as a service.

So, I am left to coding another implementation to convert files after
upload, use another library, and ditch the JODConverter/OpenOffice.org
approach.

Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 24, 2013, at 4:29 PM, Harris, Jeffrey E. wrote:

>
>
>> -----Original Message-----
>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>> Sent: Sunday, March 24, 2013 4:15 PM
>> To: Tomcat Users List
>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>
>>
>>> Within your application, do you actually access the mappings by
>>> letter, or by UNC?
>>>
>>>> The problem is after I'm up and running, I try to run "cmd.exe /C
>> net
>>>> use" from within the app it does not return any mapped drives. it
>>>> returns:
>>>> net use
>>>> New connections will be remembered.
>>>>
>>>> There are no entries in the list.
>>>>
>>>
>>> We understand that.  What we are trying to tell you if you want  
>>> those
>>> mappings to appear (regardless of whether they are already mapped or
>>> not), we think you need to dynamically map them within your
>>> application.  Otherwise, we think you will continue to experience  
>>> the
>>> situation you describe above.
>>>
>>>> Again, the return above happen only when running as a service  but
>>>> works fine when tomcat starts from startup.bat in a console. Works
>>>> fine means it returns drive letter, unc equivalent etc ...  
>>>> basically
>>>> what you normally see when you have mapped network drives and run
>>>> "net use"
>>>> from cmd.exe.
>>>>
>>>> It make no sense I know but I'm at a loss.
>>>
>>> I think it makes sense (pending further information on how you
>>> actually access the shares from within your application) because the
>>> application is not actually using a mapped drive, but using its
>> access
>>> rights from a UNC.
>>
>> Hi Jeffrey,
>>
>> I think I'm getting what you might be saying. Because "net use"
>> returns a drive letter in its return
>> then the service cannot deal with it? To answer your question about  
>> how
>> we access shares from within our app, we *have to* use UNC paths that
>> already have the proper credentials provided by a common username &
>> password that the service uses to login (local account with same
>> username and password as an account already on the file server) So  
>> when
>> the app accesses the UNC path for the first time it tries to use it's
>> service login credentials which we require to exist on the file  
>> server
>> with the shares. Therefore when we do our first network access the
>> service login account is used to authenticate with the file server  
>> and
>> because we create an account on the file server with the same  
>> username
>> and password we get clean access to the shares.
>> I never liked having this
>> rule (service login name and password must exist on the file server
>> matching exactly) but it has work for us for years. But getting  
>> back to
>> net use, because drive letters are not usable by code running in the
>> service, we don't get anything back from "net use"
>> because part of its return is
>> a drive letter? I hope I'm making sense, but is that the gist of what
>> you are saying? If it is then it starts to make a lot more sense now.
>>
>> Thanks for hanging in there with me.
>> Pat
>
> Mappings are strictly a convention for using UNCs with drive letters  
> (a fall back
> to the days of Windows 3.1 and 95/98 which did not understand UNCs,  
> and neither
> did applications).  Based on your description, you are using  
> passthrough authentication because you
> are operating in a workgroup environment (if you were in a domain  
> environment,
> you would simply assign a domain account, and give that account the  
> right
> permissions to the share).  Your description above about  
> authentication is
> exactly right - matching accounts and passwords means transparent  
> access to the
> share.
>
> Andre discussed this point in his last post - a service account  
> logging in interactively
> has a different environment than a service account logging in as a  
> service.  Windows is
> basically ignoring any drive mappings that you specify because they  
> were specified outside
> of the service session.  You are gaining access because of the UNCs  
> and the passthrough
> authentication.
>
> If you want to use drive mappings, you need to map them WITHIN your  
> application (or service
> session) to appear.  See the link in Serge's post for some ideas how  
> to do this.  I think
> the best method is to actually map the drives yourself within your  
> application, if you can;
> otherwise, set up a service that does the drive mappings, and then  
> calls your Tomcat service.
>
> If all you want to do is make the list of mappings appear in an HTML  
> page (without actually using
> them in your application), you can just fake the list as I discussed  
> previously.
>
> The key point is because the mappings are not set within the service  
> session itself, you are NOT
> using the mappings, only the UNCs, and they will not appear using  
> the net use command within
> the service.
>
> Jeffrey Harris

Hi Jeffrey,

Yes, I now get it. Thanks for the lesson on Windows Networking (I  
thought I knew well) and thanks to Andre as well.
You also said that if all I wanted to do was make a list of mapping  
appear in an html page (without actually using them
in your application), you can just fake it as previously discussed. I  
think I missed that part.

Thanks
Pat

>
>
> This e-mail and any attachments are intended only for the use of the  
> addressee(s) named herein and may contain proprietary information.  
> If you are not the intended recipient of this e-mail or believe that  
> you received this email in error, please take immediate action to  
> notify the sender of the apparent error by reply e-mail; permanently  
> delete the e-mail and any attachments from your computer; and do not  
> disseminate, distribute, use, or copy this message and any  
> attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> Sent: Sunday, March 24, 2013 4:15 PM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
>
> > Within your application, do you actually access the mappings by
> > letter, or by UNC?
> >
> >> The problem is after I'm up and running, I try to run "cmd.exe /C
> net
> >> use" from within the app it does not return any mapped drives. it
> >> returns:
> >> net use
> >> New connections will be remembered.
> >>
> >> There are no entries in the list.
> >>
> >
> > We understand that.  What we are trying to tell you if you want those
> > mappings to appear (regardless of whether they are already mapped or
> > not), we think you need to dynamically map them within your
> > application.  Otherwise, we think you will continue to experience the
> > situation you describe above.
> >
> >> Again, the return above happen only when running as a service  but
> >> works fine when tomcat starts from startup.bat in a console. Works
> >> fine means it returns drive letter, unc equivalent etc ... basically
> >> what you normally see when you have mapped network drives and run
> >> "net use"
> >> from cmd.exe.
> >>
> >> It make no sense I know but I'm at a loss.
> >
> > I think it makes sense (pending further information on how you
> > actually access the shares from within your application) because the
> > application is not actually using a mapped drive, but using its
> access
> > rights from a UNC.
>
> Hi Jeffrey,
>
> I think I'm getting what you might be saying. Because "net use"
> returns a drive letter in its return
> then the service cannot deal with it? To answer your question about how
> we access shares from within our app, we *have to* use UNC paths that
> already have the proper credentials provided by a common username &
> password that the service uses to login (local account with same
> username and password as an account already on the file server) So when
> the app accesses the UNC path for the first time it tries to use it's
> service login credentials which we require to exist on the file server
> with the shares. Therefore when we do our first network access the
> service login account is used to authenticate with the file server and
> because we create an account on the file server with the same username
> and password we get clean access to the shares.
> I never liked having this
> rule (service login name and password must exist on the file server
> matching exactly) but it has work for us for years. But getting back to
> net use, because drive letters are not usable by code running in the
> service, we don't get anything back from "net use"
> because part of its return is
> a drive letter? I hope I'm making sense, but is that the gist of what
> you are saying? If it is then it starts to make a lot more sense now.
>
> Thanks for hanging in there with me.
> Pat

Mappings are strictly a convention for using UNCs with drive letters (a fall back
to the days of Windows 3.1 and 95/98 which did not understand UNCs, and neither
did applications).  Based on your description, you are using passthrough authentication because you
are operating in a workgroup environment (if you were in a domain environment,
you would simply assign a domain account, and give that account the right
permissions to the share).  Your description above about authentication is
exactly right - matching accounts and passwords means transparent access to the
share.

Andre discussed this point in his last post - a service account logging in interactively
has a different environment than a service account logging in as a service.  Windows is
basically ignoring any drive mappings that you specify because they were specified outside
of the service session.  You are gaining access because of the UNCs and the passthrough
authentication.

If you want to use drive mappings, you need to map them WITHIN your application (or service
session) to appear.  See the link in Serge's post for some ideas how to do this.  I think
the best method is to actually map the drives yourself within your application, if you can;
otherwise, set up a service that does the drive mappings, and then calls your Tomcat service.

If all you want to do is make the list of mappings appear in an HTML page (without actually using
them in your application), you can just fake the list as I discussed previously.

The key point is because the mappings are not set within the service session itself, you are NOT
using the mappings, only the UNCs, and they will not appear using the net use command within
the service.

Jeffrey Harris


This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 24, 2013, at 3:46 PM, Harris, Jeffrey E. wrote:

>
>
>> -----Original Message-----
>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>> Sent: Sunday, March 24, 2013 3:37 PM
>> To: Tomcat Users List
>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>
>>
>> On Mar 24, 2013, at 2:56 PM, André Warnier wrote:
>>
>>> Harris, Jeffrey E. wrote:
>>>>> -----Original Message-----
>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>>> Sent: Sunday, March 24, 2013 12:18 PM
>>>>> To: Tomcat Users List
>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>
>>>>>
>>>>> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
>>>>>
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>>>>> Sent: Sunday, March 24, 2013 10:20 AM
>>>>>>> To: Tomcat Users List
>>>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>>>
>>>>>>>
>>>>>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>>>>>>
>>> (**) Maybe this is a hint to the OP : what happens if you ignore the
>>> result of the first command call, and try the same command a second
>>> time ?
>>> And I agree : there a bit of hocus-pocus here, but then many things
>>> are, in a Windows environment.
>>>
>> You are not hearing me. The drives are mapped and set to reconnect at
>> logon. Therefore if I reboot my machine the network drive mapping are
>> in place after logging in. I *do not* try and map a drive from within
>> my app. My app has full access to the network shares as soon as my  
>> app
>> is up. No problem with network shares and my app ! My app needs to  
>> read
>> and write to those network share to function and has no problems.
>>
>
> I think we have a failure to communicate here.
>
> Mappings set to reconnect are NOT the same as having access to a  
> share.
> If you have access to the share, it is does not depending on a  
> mapping.  The
> mapping only assigns a particular drive letter to a UNC.
>
> Within your application, do you actually access the mappings by  
> letter, or by
> UNC?
>
>> The problem is after I'm up and running, I try to run "cmd.exe /C net
>> use" from within the app it does not return any mapped drives. it
>> returns:
>> net use
>> New connections will be remembered.
>>
>> There are no entries in the list.
>>
>
> We understand that.  What we are trying to tell you if you want  
> those mappings
> to appear (regardless of whether they are already mapped or not), we  
> think you
> need to dynamically map them within your application.  Otherwise, we  
> think you
> will continue to experience the situation you describe above.
>
>> Again, the return above happen only when running as a service  but
>> works fine when tomcat starts from startup.bat in a console. Works  
>> fine
>> means it returns drive letter, unc equivalent etc ... basically what
>> you normally see when you have mapped network drives and run "net  
>> use"
>> from cmd.exe.
>>
>> It make no sense I know but I'm at a loss.
>
> I think it makes sense (pending further information on how you  
> actually access the
> shares from within your application) because the application is not  
> actually using
> a mapped drive, but using its access rights from a UNC.

Hi Jeffrey,

I think I'm getting what you might be saying. Because "net use"  
returns a drive letter in its return
then the service cannot deal with it? To answer your question about  
how we access shares from
within our app, we *have to* use UNC paths that already have the  
proper credentials provided by
a common username & password that the service uses to login (local  
account with same username
and password as an account already on the file server) So when the app  
accesses the UNC path
for the first time it tries to use it's service login credentials  
which we require to exist on the file
server with the shares. Therefore when we do our first network access  
the service login account
is used to authenticate with the file server and because we create an  
account on the file server
with the same username and password we get clean access to the shares.  
I never liked having this
rule (service login name and password must exist on the file server  
matching exactly) but it has
work for us for years. But getting back to net use, because drive  
letters are not usable by code
running in the service, we don't get anything back from "net use"  
because part of its return is
a drive letter? I hope I'm making sense, but is that the gist of what  
you are saying? If it is then
it starts to make a lot more sense now.

Thanks for hanging in there with me.
Pat


>
>>
>> Thanks again
>> Pat
>>
>>
>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>
>
> This e-mail and any attachments are intended only for the use of the  
> addressee(s) named herein and may contain proprietary information.  
> If you are not the intended recipient of this e-mail or believe that  
> you received this email in error, please take immediate action to  
> notify the sender of the apparent error by reply e-mail; permanently  
> delete the e-mail and any attachments from your computer; and do not  
> disseminate, distribute, use, or copy this message and any  
> attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


Re: runtime.exec "cmd.exe /C net use"

Posted by Serge Fonville <se...@gmail.com>.
Hi,

See the second reply on SO
http://stackoverflow.com/questions/182750/map-a-network-drive-to-be-used-by-a-service

HTH

Kind regards/met vriendelijke groet,

Serge Fonville

http://www.sergefonville.nl

Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table


2013/3/24 Harris, Jeffrey E. <Je...@mantech.com>

>
>
> > -----Original Message-----
> > From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> > Sent: Sunday, March 24, 2013 3:37 PM
> > To: Tomcat Users List
> > Subject: Re: runtime.exec "cmd.exe /C net use"
> >
> >
> > On Mar 24, 2013, at 2:56 PM, André Warnier wrote:
> >
> > > Harris, Jeffrey E. wrote:
> > >>> -----Original Message-----
> > >>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> > >>> Sent: Sunday, March 24, 2013 12:18 PM
> > >>> To: Tomcat Users List
> > >>> Subject: Re: runtime.exec "cmd.exe /C net use"
> > >>>
> > >>>
> > >>> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
> > >>>
> > >>>>
> > >>>>> -----Original Message-----
> > >>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> > >>>>> Sent: Sunday, March 24, 2013 10:20 AM
> > >>>>> To: Tomcat Users List
> > >>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
> > >>>>>
> > >>>>>
> > >>>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
> > >>>>>
> > > (**) Maybe this is a hint to the OP : what happens if you ignore the
> > > result of the first command call, and try the same command a second
> > > time ?
> > > And I agree : there a bit of hocus-pocus here, but then many things
> > > are, in a Windows environment.
> > >
> > You are not hearing me. The drives are mapped and set to reconnect at
> > logon. Therefore if I reboot my machine the network drive mapping are
> > in place after logging in. I *do not* try and map a drive from within
> > my app. My app has full access to the network shares as soon as my app
> > is up. No problem with network shares and my app ! My app needs to read
> > and write to those network share to function and has no problems.
> >
>
> I think we have a failure to communicate here.
>
> Mappings set to reconnect are NOT the same as having access to a share.
> If you have access to the share, it is does not depending on a mapping.
>  The
> mapping only assigns a particular drive letter to a UNC.
>
> Within your application, do you actually access the mappings by letter, or
> by
> UNC?
>
> > The problem is after I'm up and running, I try to run "cmd.exe /C net
> > use" from within the app it does not return any mapped drives. it
> > returns:
> > net use
> > New connections will be remembered.
> >
> > There are no entries in the list.
> >
>
> We understand that.  What we are trying to tell you if you want those
> mappings
> to appear (regardless of whether they are already mapped or not), we think
> you
> need to dynamically map them within your application.  Otherwise, we think
> you
> will continue to experience the situation you describe above.
>
> > Again, the return above happen only when running as a service  but
> > works fine when tomcat starts from startup.bat in a console. Works fine
> > means it returns drive letter, unc equivalent etc ... basically what
> > you normally see when you have mapped network drives and run "net use"
> > from cmd.exe.
> >
> > It make no sense I know but I'm at a loss.
>
> I think it makes sense (pending further information on how you actually
> access the
> shares from within your application) because the application is not
> actually using
> a mapped drive, but using its access rights from a UNC.
>
> >
> > Thanks again
> > Pat
> >
> >
> >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: users-help@tomcat.apache.org
> > >
>
>
> This e-mail and any attachments are intended only for the use of the
> addressee(s) named herein and may contain proprietary information. If you
> are not the intended recipient of this e-mail or believe that you received
> this email in error, please take immediate action to notify the sender of
> the apparent error by reply e-mail; permanently delete the e-mail and any
> attachments from your computer; and do not disseminate, distribute, use, or
> copy this message and any attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> Sent: Sunday, March 24, 2013 3:37 PM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
>
> On Mar 24, 2013, at 2:56 PM, André Warnier wrote:
>
> > Harris, Jeffrey E. wrote:
> >>> -----Original Message-----
> >>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> >>> Sent: Sunday, March 24, 2013 12:18 PM
> >>> To: Tomcat Users List
> >>> Subject: Re: runtime.exec "cmd.exe /C net use"
> >>>
> >>>
> >>> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
> >>>
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> >>>>> Sent: Sunday, March 24, 2013 10:20 AM
> >>>>> To: Tomcat Users List
> >>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
> >>>>>
> >>>>>
> >>>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
> >>>>>
> > (**) Maybe this is a hint to the OP : what happens if you ignore the
> > result of the first command call, and try the same command a second
> > time ?
> > And I agree : there a bit of hocus-pocus here, but then many things
> > are, in a Windows environment.
> >
> You are not hearing me. The drives are mapped and set to reconnect at
> logon. Therefore if I reboot my machine the network drive mapping are
> in place after logging in. I *do not* try and map a drive from within
> my app. My app has full access to the network shares as soon as my app
> is up. No problem with network shares and my app ! My app needs to read
> and write to those network share to function and has no problems.
>

I think we have a failure to communicate here.

Mappings set to reconnect are NOT the same as having access to a share.
If you have access to the share, it is does not depending on a mapping.  The
mapping only assigns a particular drive letter to a UNC.

Within your application, do you actually access the mappings by letter, or by
UNC?

> The problem is after I'm up and running, I try to run "cmd.exe /C net
> use" from within the app it does not return any mapped drives. it
> returns:
> net use
> New connections will be remembered.
>
> There are no entries in the list.
>

We understand that.  What we are trying to tell you if you want those mappings
to appear (regardless of whether they are already mapped or not), we think you
need to dynamically map them within your application.  Otherwise, we think you
will continue to experience the situation you describe above.

> Again, the return above happen only when running as a service  but
> works fine when tomcat starts from startup.bat in a console. Works fine
> means it returns drive letter, unc equivalent etc ... basically what
> you normally see when you have mapped network drives and run "net use"
> from cmd.exe.
>
> It make no sense I know but I'm at a loss.

I think it makes sense (pending further information on how you actually access the
shares from within your application) because the application is not actually using
a mapped drive, but using its access rights from a UNC.

>
> Thanks again
> Pat
>
>
>
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >


This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 24, 2013, at 2:56 PM, André Warnier wrote:

> Harris, Jeffrey E. wrote:
>>> -----Original Message-----
>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>> Sent: Sunday, March 24, 2013 12:18 PM
>>> To: Tomcat Users List
>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>
>>>
>>> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>>> Sent: Sunday, March 24, 2013 10:20 AM
>>>>> To: Tomcat Users List
>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>
>>>>>
>>>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>>>>
>>>>>> On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>>>> Hi,
>>>>>
>>>>> Thanks for all the input. I know about service logins being only
>>> able
>>>>> to use UNC paths (not drive letters) to access network shares. I
>>> know
>>>>> the service login & password have to have a matching account on  
>>>>> the
>>>>> server with the shares in order for the tomcat app to use (access)
>>>>> those shares. We do all of this. Out tomcat app depends on network
>>>>> shares to function and it always has worked as long as the service
>>>>> login account matches an account on the server with the shares.
>>>>>
>>>>> What I'm trying to do in an html interface is make a pulldown menu
>>>>> list of my mapped drives as a location for our database backup.  
>>>>> It's
>>>>> a preference setup to where an automated scheduled backup will  
>>>>> write
>>>>> the backups. I'm using "net use" to produce what you would expect
>>> for
>>>>> output (all the mapped network drives) and parsing the output to
>>>>> produce the pulldown menu item containing the unc portion gleaned
>>>>> from the "net use" output. I need the unc portion as this is  
>>>>> what a
>>>>> tomcat app needs. No matter what I do outside the app I cannot
>>>>> produce the effectively empty list that the app is producing. I'm
>>>>> logged into Windows as the same account as the service and I  
>>>>> open a
>>>>> command prompt and see all my mapped drives via "net use". I have
>>>>> tried UAC on and off and it changes nothing. I added a simple  
>>>>> "dir"
>>>>> to the app and I can get that output but not the "net use"
>>>>> output. I do know it has to do with the service as I said because
>>>>> when tomcat is started via the startup.bat it works great.
>>>>>
>>>>> Maybe it is a Windows question but thought someone may have had  
>>>>> some
>>>>> similar experience.
>>>>>
>>>>> Thanks for eveyone's thoughts.
>>>>>
>>>>> -Pat
>>>>>
>>>> You still have not answered how the mapping are being made in the
>>>> first place.  Is the service account dynamically setting the  
>>>> mapping
>>>> using net use, or through the Windows API?  Are you relying on  
>>>> static
>>>> mappings in the user account profile?
>>> Hi Jeffrey,
>>>
>>> The drive mapping are happening through the Windows Explorer  
>>> interface.
>>> The file server is browsed and the shares on the file server are  
>>> mapped
>>> by right-clicking the share, mapping it to a drive letter and I  
>>> check
>>> the checkbox "Reconnect at logon". Then I start my app.
>>> (I'm not using any user profiles.)
>>>
>>> -Pat
>>>
>>>> Jeffrey Harris
>>>>
>> Pat,
>> I do not think that will work for a service account.  The drive  
>> mappings are stored in the user profile,
>> and since I do not think service accounts access user profiles, the  
>> service account will not remap
>> the drives when using the account to start a service (it will when  
>> you actually log in interactively with
>> the account).  You can try setting some custom environment  
>> variables in the user profile (not the system profile)
>> and see if they are accessible by the service account using the set  
>> command as a test to see if mapping
>> might be accessible.
>> What you probably need to do is actually set the drive mappings  
>> using the Windows API dynamically when Tomcat starts,
>> or use UNCs.  I know you want to display the drive mappings, but  
>> you could fake the display by doing a net use >myfilemappings.txt  
>> from the command line (when logged into the account), and just  
>> calling the file to display the mappings.  Obviously, if the  
>> mappings change, you would have to redo the file.
>> I think those are your only options.  You might want to do a Google  
>> search and see if there is a way for
>> service accounts to use remembered mapped drives.
>
> I routinely use "net use \\hostname\share" from inside programs  
> running as Windows Services (not in Java, though, but it should not  
> matter). "Drive letters" don't work.
> The exact form I use is :
> net use \\hostname\sharename <password> /USER:<userid>
> And then later I can open/read/write/close files as "\\hostname 
> \sharename\filepath".
>
> It works, but I have noticed one "quirk" in my programs : after  
> doing the "net use", the very first access to the share doesn't work  
> and returns an error. The second access and all subsequent ones work  
> though.  I have no idea why this is, but I have just adapted my  
> programs to work around this issue (by doing a first dummy access  
> and ignoring the result), and never had any problem since. (**)
>
> To be able to do this, the Service *cannot* run as the LocalSystem  
> or LocalService user. By design in Windows, these special users do  
> not have access to any "Windows network" functions or resources.   
> Any "normal" user (*) will do, depending on the environment (such  
> as, if the current host is a member of a Windows Domain, and the  
> Windows network resource is defined in that domain, then the user  
> will need to be a Domain user; if the resource is a share on a Linux  
> Samba host e.g., then any user will do, as long as it is known to  
> Samba).
> This all concerns only "Windows network" resources.  Anything  
> accessed via standard TCP/IP protocols (HTTP, NFS, FTP, SSL..)  
> works, even when running as one of these special users.
>
> As a not very precise technical definition, "Windows network  
> resources" are all the things  like "shares" (network directories),  
> Windows network printers, anything that is accessed via the SMB or  
> CIFS protocol, anything that requires the usage of a "workgroup" or  
> "domain" name, etc.
>
>
> (*) with one additional caveat : the user must be granted the "right  
> to run services".
>
> (**) Maybe this is a hint to the OP : what happens if you ignore the  
> result of the first command call, and try the same command a second  
> time ?
> And I agree : there a bit of hocus-pocus here, but then many things  
> are, in a Windows environment.
>
You are not hearing me. The drives are mapped and set to reconnect at  
logon. Therefore if I reboot my machine the network drive mapping are  
in place after
logging in. I *do not* try and map a drive from within my app. My app  
has full access to the network shares as soon as my app is up. No  
problem with network
shares and my app ! My app needs to read and write to those network  
share to function and has no problems.

The problem is after I'm up and running, I try to run "cmd.exe /C net  
use" from within the app it does not return any mapped drives. it  
returns:
net use
New connections will be remembered.

There are no entries in the list.

Again, the return above happen only when running as a service  but  
works fine when tomcat starts from startup.bat in a console. Works  
fine means
it returns drive letter, unc equivalent etc ... basically what you  
normally see when you have mapped network drives and run "net use"  
from cmd.exe.

It make no sense I know but I'm at a loss.

Thanks again
Pat



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


Re: runtime.exec "cmd.exe /C net use"

Posted by André Warnier <aw...@ice-sa.com>.
Harris, Jeffrey E. wrote:
> 
>> -----Original Message-----
>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>> Sent: Sunday, March 24, 2013 12:18 PM
>> To: Tomcat Users List
>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>
>>
>> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
>>
>>>
>>>> -----Original Message-----
>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>>>> Sent: Sunday, March 24, 2013 10:20 AM
>>>> To: Tomcat Users List
>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>
>>>>
>>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>>>
>>>>> On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>>> Hi,
>>>>
>>>> Thanks for all the input. I know about service logins being only
>> able
>>>> to use UNC paths (not drive letters) to access network shares. I
>> know
>>>> the service login & password have to have a matching account on the
>>>> server with the shares in order for the tomcat app to use (access)
>>>> those shares. We do all of this. Out tomcat app depends on network
>>>> shares to function and it always has worked as long as the service
>>>> login account matches an account on the server with the shares.
>>>>
>>>> What I'm trying to do in an html interface is make a pulldown menu
>>>> list of my mapped drives as a location for our database backup. It's
>>>> a preference setup to where an automated scheduled backup will write
>>>> the backups. I'm using "net use" to produce what you would expect
>> for
>>>> output (all the mapped network drives) and parsing the output to
>>>> produce the pulldown menu item containing the unc portion gleaned
>>>> from the "net use" output. I need the unc portion as this is what a
>>>> tomcat app needs. No matter what I do outside the app I cannot
>>>> produce the effectively empty list that the app is producing. I'm
>>>> logged into Windows as the same account as the service and I open a
>>>> command prompt and see all my mapped drives via "net use". I have
>>>> tried UAC on and off and it changes nothing. I added a simple "dir"
>>>> to the app and I can get that output but not the "net use"
>>>> output. I do know it has to do with the service as I said because
>>>> when tomcat is started via the startup.bat it works great.
>>>>
>>>> Maybe it is a Windows question but thought someone may have had some
>>>> similar experience.
>>>>
>>>> Thanks for eveyone's thoughts.
>>>>
>>>> -Pat
>>>>
>>> You still have not answered how the mapping are being made in the
>>> first place.  Is the service account dynamically setting the mapping
>>> using net use, or through the Windows API?  Are you relying on static
>>> mappings in the user account profile?
>> Hi Jeffrey,
>>
>> The drive mapping are happening through the Windows Explorer interface.
>> The file server is browsed and the shares on the file server are mapped
>> by right-clicking the share, mapping it to a drive letter and I check
>> the checkbox "Reconnect at logon". Then I start my app.
>> (I'm not using any user profiles.)
>>
>> -Pat
>>
>>> Jeffrey Harris
>>>
> 
> Pat,
> 
> I do not think that will work for a service account.  The drive mappings are stored in the user profile,
> and since I do not think service accounts access user profiles, the service account will not remap
> the drives when using the account to start a service (it will when you actually log in interactively with
> the account).  You can try setting some custom environment variables in the user profile (not the system profile)
> and see if they are accessible by the service account using the set command as a test to see if mapping
> might be accessible.
> 
> What you probably need to do is actually set the drive mappings using the Windows API dynamically when Tomcat starts,
> or use UNCs.  I know you want to display the drive mappings, but you could fake the display by doing a net use >myfilemappings.txt from the command line (when logged into the account), and just calling the file to display the mappings.  Obviously, if the mappings change, you would have to redo the file.
> 
> I think those are your only options.  You might want to do a Google search and see if there is a way for
> service accounts to use remembered mapped drives.
> 

I routinely use "net use \\hostname\share" from inside programs running as Windows 
Services (not in Java, though, but it should not matter). "Drive letters" don't work.
The exact form I use is :
net use \\hostname\sharename <password> /USER:<userid>
And then later I can open/read/write/close files as "\\hostname\sharename\filepath".

It works, but I have noticed one "quirk" in my programs : after doing the "net use", the 
very first access to the share doesn't work and returns an error. The second access and 
all subsequent ones work though.  I have no idea why this is, but I have just adapted my 
programs to work around this issue (by doing a first dummy access and ignoring the 
result), and never had any problem since. (**)

To be able to do this, the Service *cannot* run as the LocalSystem or LocalService user. 
By design in Windows, these special users do not have access to any "Windows network" 
functions or resources.  Any "normal" user (*) will do, depending on the environment (such 
as, if the current host is a member of a Windows Domain, and the Windows network resource 
is defined in that domain, then the user will need to be a Domain user; if the resource is 
a share on a Linux Samba host e.g., then any user will do, as long as it is known to Samba).
This all concerns only "Windows network" resources.  Anything accessed via standard TCP/IP 
protocols (HTTP, NFS, FTP, SSL..) works, even when running as one of these special users.

As a not very precise technical definition, "Windows network resources" are all the things 
  like "shares" (network directories), Windows network printers, anything that is accessed 
via the SMB or CIFS protocol, anything that requires the usage of a "workgroup" or 
"domain" name, etc.


(*) with one additional caveat : the user must be granted the "right to run services".

(**) Maybe this is a hint to the OP : what happens if you ignore the result of the first 
command call, and try the same command a second time ?
And I agree : there a bit of hocus-pocus here, but then many things are, in a Windows 
environment.

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


RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> Sent: Sunday, March 24, 2013 12:18 PM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
>
> On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:
>
> >
> >
> >> -----Original Message-----
> >> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> >> Sent: Sunday, March 24, 2013 10:20 AM
> >> To: Tomcat Users List
> >> Subject: Re: runtime.exec "cmd.exe /C net use"
> >>
> >>
> >> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
> >>
> >>> On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
> >>
> >> Hi,
> >>
> >> Thanks for all the input. I know about service logins being only
> able
> >> to use UNC paths (not drive letters) to access network shares. I
> know
> >> the service login & password have to have a matching account on the
> >> server with the shares in order for the tomcat app to use (access)
> >> those shares. We do all of this. Out tomcat app depends on network
> >> shares to function and it always has worked as long as the service
> >> login account matches an account on the server with the shares.
> >>
> >> What I'm trying to do in an html interface is make a pulldown menu
> >> list of my mapped drives as a location for our database backup. It's
> >> a preference setup to where an automated scheduled backup will write
> >> the backups. I'm using "net use" to produce what you would expect
> for
> >> output (all the mapped network drives) and parsing the output to
> >> produce the pulldown menu item containing the unc portion gleaned
> >> from the "net use" output. I need the unc portion as this is what a
> >> tomcat app needs. No matter what I do outside the app I cannot
> >> produce the effectively empty list that the app is producing. I'm
> >> logged into Windows as the same account as the service and I open a
> >> command prompt and see all my mapped drives via "net use". I have
> >> tried UAC on and off and it changes nothing. I added a simple "dir"
> >> to the app and I can get that output but not the "net use"
> >> output. I do know it has to do with the service as I said because
> >> when tomcat is started via the startup.bat it works great.
> >>
> >> Maybe it is a Windows question but thought someone may have had some
> >> similar experience.
> >>
> >> Thanks for eveyone's thoughts.
> >>
> >> -Pat
> >>
> >
> > You still have not answered how the mapping are being made in the
> > first place.  Is the service account dynamically setting the mapping
> > using net use, or through the Windows API?  Are you relying on static
> > mappings in the user account profile?
>
> Hi Jeffrey,
>
> The drive mapping are happening through the Windows Explorer interface.
> The file server is browsed and the shares on the file server are mapped
> by right-clicking the share, mapping it to a drive letter and I check
> the checkbox "Reconnect at logon". Then I start my app.
> (I'm not using any user profiles.)
>
> -Pat
>
> >
> > Jeffrey Harris
> >

Pat,

I do not think that will work for a service account.  The drive mappings are stored in the user profile,
and since I do not think service accounts access user profiles, the service account will not remap
the drives when using the account to start a service (it will when you actually log in interactively with
the account).  You can try setting some custom environment variables in the user profile (not the system profile)
and see if they are accessible by the service account using the set command as a test to see if mapping
might be accessible.

What you probably need to do is actually set the drive mappings using the Windows API dynamically when Tomcat starts,
or use UNCs.  I know you want to display the drive mappings, but you could fake the display by doing a net use >myfilemappings.txt from the command line (when logged into the account), and just calling the file to display the mappings.  Obviously, if the mappings change, you would have to redo the file.

I think those are your only options.  You might want to do a Google search and see if there is a way for
service accounts to use remembered mapped drives.

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 24, 2013, at 10:24 AM, Harris, Jeffrey E. wrote:

>
>
>> -----Original Message-----
>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
>> Sent: Sunday, March 24, 2013 10:20 AM
>> To: Tomcat Users List
>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>
>>
>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>
>>> On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>
>> Hi,
>>
>> Thanks for all the input. I know about service logins being only able
>> to use UNC paths (not drive letters) to access network shares. I know
>> the service login & password have to have a matching account on the
>> server with the shares in order for the tomcat app to use (access)
>> those shares. We do all of this. Out tomcat app depends on network
>> shares to function and it always has worked as long as the service
>> login account matches an account on the server with the shares.
>>
>> What I'm trying to do in an html interface is make a pulldown menu  
>> list
>> of my mapped drives as a location for our database backup. It's a
>> preference setup to where an automated scheduled backup will write  
>> the
>> backups. I'm using "net use" to produce what you would expect for
>> output (all the mapped network drives) and parsing the output to
>> produce the pulldown menu item containing the unc portion gleaned  
>> from
>> the "net use" output. I need the unc portion as this is what a tomcat
>> app needs. No matter what I do outside the app I cannot produce the
>> effectively empty list that the app is producing. I'm logged into
>> Windows as the same account as the service and I open a command  
>> prompt
>> and see all my mapped drives via "net use". I have tried UAC on and  
>> off
>> and it changes nothing. I added a simple "dir" to the app and I can  
>> get
>> that output but not the "net use"
>> output. I do know it has to do with the service as I said because  
>> when
>> tomcat is started via the startup.bat it works great.
>>
>> Maybe it is a Windows question but thought someone may have had some
>> similar experience.
>>
>> Thanks for eveyone's thoughts.
>>
>> -Pat
>>
>
> You still have not answered how the mapping are being made in the  
> first place.  Is the
> service account dynamically setting the mapping using net use, or  
> through the Windows
> API?  Are you relying on static mappings in the user account profile?

Hi Jeffrey,

The drive mapping are happening through the Windows Explorer  
interface. The file server is browsed
and the shares on the file server are mapped by right-clicking the  
share, mapping it to a drive letter
and I check the checkbox "Reconnect at logon". Then I start my app.  
(I'm not using any user profiles.)

-Pat

>
> Jeffrey Harris
>
> This e-mail and any attachments are intended only for the use of the  
> addressee(s) named herein and may contain proprietary information.  
> If you are not the intended recipient of this e-mail or believe that  
> you received this email in error, please take immediate action to  
> notify the sender of the apparent error by reply e-mail; permanently  
> delete the e-mail and any attachments from your computer; and do not  
> disseminate, distribute, use, or copy this message and any  
> attachments.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


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


RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@rampageinc.com]
> Sent: Sunday, March 24, 2013 10:20 AM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
>
> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>
> > On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>
> Hi,
>
> Thanks for all the input. I know about service logins being only able
> to use UNC paths (not drive letters) to access network shares. I know
> the service login & password have to have a matching account on the
> server with the shares in order for the tomcat app to use (access)
> those shares. We do all of this. Out tomcat app depends on network
> shares to function and it always has worked as long as the service
> login account matches an account on the server with the shares.
>
> What I'm trying to do in an html interface is make a pulldown menu list
> of my mapped drives as a location for our database backup. It's a
> preference setup to where an automated scheduled backup will write the
> backups. I'm using "net use" to produce what you would expect for
> output (all the mapped network drives) and parsing the output to
> produce the pulldown menu item containing the unc portion gleaned from
> the "net use" output. I need the unc portion as this is what a tomcat
> app needs. No matter what I do outside the app I cannot produce the
> effectively empty list that the app is producing. I'm logged into
> Windows as the same account as the service and I open a command prompt
> and see all my mapped drives via "net use". I have tried UAC on and off
> and it changes nothing. I added a simple "dir" to the app and I can get
> that output but not the "net use"
> output. I do know it has to do with the service as I said because when
> tomcat is started via the startup.bat it works great.
>
> Maybe it is a Windows question but thought someone may have had some
> similar experience.
>
> Thanks for eveyone's thoughts.
>
> -Pat
>

You still have not answered how the mapping are being made in the first place.  Is the
service account dynamically setting the mapping using net use, or through the Windows
API?  Are you relying on static mappings in the user account profile?

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by André Warnier <aw...@ice-sa.com>.
David kerber wrote:
> On 4/10/2013 2:47 PM, Bilal S wrote:
>> On Sun, Mar 24, 2013 at 10:20 AM, Patrick Flaherty
>> <pf...@rampageinc.com>wrote:
>>
>>>
>>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>>
>>>   On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>>>
>>>>>
>>>>>
>>>>>   -----Original Message-----
>>>>>> From: André Warnier [mailto:aw@ice-sa.com]
>>>>>> Sent: Saturday, March 23, 2013 8:10 PM
>>>>>> To: Tomcat Users List
>>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>>
>>>>>> Harris, Jeffrey E. wrote:
>>>>>>
>>>>>>>
>>>>>>>   -----Original Message-----
>>>>>>>> From: Patrick Flaherty 
>>>>>>>> [mailto:pflahrty@rampageinc.**com<pf...@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
>>>>>>>>
>>>>>>>
>>>>>> 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.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------**------------------------------**
>>>>>> ---------
>>>>>>
>>>>>
>>>>> I absolutely agree.  I would expect to see the same behavior with 
>>>>> Apache
>>>>> HTTPD, IIS, or
>>>>> any other service that accesses mapped drives.  It is a question of 
>>>>> how
>>>>> service accounts behave
>>>>> in the windows architecture, rather than something specific with 
>>>>> Tomcat.
>>>>>
>>>>> Jeffrey Harris
>>>>>
>>>>
>>>> It will depend on what user your TC service is running under.    If 
>>>> it's
>>>> running as the LocalSystem user,  it will not have access to any 
>>>> network
>>>> drives, or many other network resources.  It can hit some, such as
>>>> databases.
>>>>
>>>> If you want your TC to be able to see networked drives, you need to run
>>>> it under the logged-on user's ID.  Keep in mind, though, that if the 
>>>> user
>>>> logs off, the drives will be disconnected.  Your best bet in that 
>>>> case it
>>>> to not connect by drive letter, but rather by the UNC name (what you 
>>>> used
>>>> to map it when you were logged on).  That will work if the user TC is
>>>> running has has the appropriate permissions to the network resource.
>>>>
>>>> D
>>>>
>>>
>>> Hi,
>>>
>>> Thanks for all the input. I know about service logins being only able to
>>> use UNC paths (not drive letters) to access network shares. I know the
>>> service login&  password have to
>>> have a matching account on the server with the shares in order for the
>>> tomcat app to use (access) those shares. We do all of this. Out 
>>> tomcat app
>>> depends on
>>> network shares to function and it always has worked as long as the 
>>> service
>>> login account matches an account on the server with the shares.
>>>
>>> What I'm trying to do in an html interface is make a pulldown menu 
>>> list of
>>> my mapped drives as a location for our database backup. It's a 
>>> preference
>>> setup to
>>> where an automated scheduled backup will write the backups. I'm using 
>>> "net
>>> use" to produce what you would expect for output (all the mapped network
>>> drives)
>>> and parsing the output to produce the pulldown menu item containing the
>>> unc portion gleaned from the "net use" output. I need the unc portion as
>>> this is what
>>> a tomcat app needs. No matter what I do outside the app I cannot produce
>>> the effectively empty list that the app is producing. I'm logged into
>>> Windows as the same
>>> account as the service and I open a command prompt and see all my mapped
>>> drives via "net use". I have tried UAC on and off and it changes 
>>> nothing. I
>>> added a simple
>>> "dir" to the app and I can get that output but not the "net use" 
>>> output. I
>>> do know it has to do with the service as I said because when tomcat is
>>> started via the startup.bat
>>> it works great.
>>>
>>> Maybe it is a Windows question but thought someone may have had some
>>> similar experience.
>>>
>>> Thanks for eveyone's thoughts.
>>>
>>> -Pat
>>>
>>>
>>>
>>>
>> Pat,
>> I believe the Windows workstation service is required to map drives.
>> Background services in general run under a different context, thus, they
>> cannot map drives.
>> That being said you should be able to achieve this by allowing your 
>> Tomcat
>> service to "interact with desktop" then actually mapping your drives in
>> scripted fashion using a series of
>> net use F: \\target\one /PERSISTENT:YES
>> net use G: \\target\two /PERSISTENT:YES
>>
>> Now when you do a list using "net use" it should list drives for your
>> service.
>>
>> HTH
>> -Bilal
> 
> The last version of windows server that allowed "interact with desktop" 
> to work was Server 2003.  2008 and 2008R2 don't allow it any more.  And 
> if you log off, your drives will still be disconnected.
> 
+1

If you really need to access Windows network resources from within a webapp running in 
Tomcat, you should probably have a look at the JCIFS suite, @ jcifs.samba.org.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by David kerber <dc...@verizon.net>.
On 4/10/2013 2:47 PM, Bilal S wrote:
> On Sun, Mar 24, 2013 at 10:20 AM, Patrick Flaherty
> <pf...@rampageinc.com>wrote:
>
>>
>> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>>
>>   On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>>
>>>>
>>>>
>>>>   -----Original Message-----
>>>>> From: André Warnier [mailto:aw@ice-sa.com]
>>>>> Sent: Saturday, March 23, 2013 8:10 PM
>>>>> To: Tomcat Users List
>>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>>
>>>>> Harris, Jeffrey E. wrote:
>>>>>
>>>>>>
>>>>>>   -----Original Message-----
>>>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.**com<pf...@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
>>>>>>>
>>>>>>
>>>>> 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.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------**------------------------------**
>>>>> ---------
>>>>>
>>>>
>>>> I absolutely agree.  I would expect to see the same behavior with Apache
>>>> HTTPD, IIS, or
>>>> any other service that accesses mapped drives.  It is a question of how
>>>> service accounts behave
>>>> in the windows architecture, rather than something specific with Tomcat.
>>>>
>>>> Jeffrey Harris
>>>>
>>>
>>> It will depend on what user your TC service is running under.    If it's
>>> running as the LocalSystem user,  it will not have access to any network
>>> drives, or many other network resources.  It can hit some, such as
>>> databases.
>>>
>>> If you want your TC to be able to see networked drives, you need to run
>>> it under the logged-on user's ID.  Keep in mind, though, that if the user
>>> logs off, the drives will be disconnected.  Your best bet in that case it
>>> to not connect by drive letter, but rather by the UNC name (what you used
>>> to map it when you were logged on).  That will work if the user TC is
>>> running has has the appropriate permissions to the network resource.
>>>
>>> D
>>>
>>
>> Hi,
>>
>> Thanks for all the input. I know about service logins being only able to
>> use UNC paths (not drive letters) to access network shares. I know the
>> service login&  password have to
>> have a matching account on the server with the shares in order for the
>> tomcat app to use (access) those shares. We do all of this. Out tomcat app
>> depends on
>> network shares to function and it always has worked as long as the service
>> login account matches an account on the server with the shares.
>>
>> What I'm trying to do in an html interface is make a pulldown menu list of
>> my mapped drives as a location for our database backup. It's a preference
>> setup to
>> where an automated scheduled backup will write the backups. I'm using "net
>> use" to produce what you would expect for output (all the mapped network
>> drives)
>> and parsing the output to produce the pulldown menu item containing the
>> unc portion gleaned from the "net use" output. I need the unc portion as
>> this is what
>> a tomcat app needs. No matter what I do outside the app I cannot produce
>> the effectively empty list that the app is producing. I'm logged into
>> Windows as the same
>> account as the service and I open a command prompt and see all my mapped
>> drives via "net use". I have tried UAC on and off and it changes nothing. I
>> added a simple
>> "dir" to the app and I can get that output but not the "net use" output. I
>> do know it has to do with the service as I said because when tomcat is
>> started via the startup.bat
>> it works great.
>>
>> Maybe it is a Windows question but thought someone may have had some
>> similar experience.
>>
>> Thanks for eveyone's thoughts.
>>
>> -Pat
>>
>>
>>
>>
> Pat,
> I believe the Windows workstation service is required to map drives.
> Background services in general run under a different context, thus, they
> cannot map drives.
> That being said you should be able to achieve this by allowing your Tomcat
> service to "interact with desktop" then actually mapping your drives in
> scripted fashion using a series of
> net use F: \\target\one /PERSISTENT:YES
> net use G: \\target\two /PERSISTENT:YES
>
> Now when you do a list using "net use" it should list drives for your
> service.
>
> HTH
> -Bilal

The last version of windows server that allowed "interact with desktop" 
to work was Server 2003.  2008 and 2008R2 don't allow it any more.  And 
if you log off, your drives will still be disconnected.


>


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


Re: runtime.exec "cmd.exe /C net use"

Posted by Bilal S <bi...@gmail.com>.
On Sun, Mar 24, 2013 at 10:20 AM, Patrick Flaherty
<pf...@rampageinc.com>wrote:

>
> On Mar 23, 2013, at 10:00 PM, David Kerber wrote:
>
>  On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>
>>>
>>>
>>>  -----Original Message-----
>>>> From: André Warnier [mailto:aw@ice-sa.com]
>>>> Sent: Saturday, March 23, 2013 8:10 PM
>>>> To: Tomcat Users List
>>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>>
>>>> Harris, Jeffrey E. wrote:
>>>>
>>>>>
>>>>>  -----Original Message-----
>>>>>> From: Patrick Flaherty [mailto:pflahrty@rampageinc.**com<pf...@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
>>>>>>
>>>>>
>>>> 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.
>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------**------------------------------**
>>>> ---------
>>>>
>>>
>>> I absolutely agree.  I would expect to see the same behavior with Apache
>>> HTTPD, IIS, or
>>> any other service that accesses mapped drives.  It is a question of how
>>> service accounts behave
>>> in the windows architecture, rather than something specific with Tomcat.
>>>
>>> Jeffrey Harris
>>>
>>
>> It will depend on what user your TC service is running under.    If it's
>> running as the LocalSystem user,  it will not have access to any network
>> drives, or many other network resources.  It can hit some, such as
>> databases.
>>
>> If you want your TC to be able to see networked drives, you need to run
>> it under the logged-on user's ID.  Keep in mind, though, that if the user
>> logs off, the drives will be disconnected.  Your best bet in that case it
>> to not connect by drive letter, but rather by the UNC name (what you used
>> to map it when you were logged on).  That will work if the user TC is
>> running has has the appropriate permissions to the network resource.
>>
>> D
>>
>
> Hi,
>
> Thanks for all the input. I know about service logins being only able to
> use UNC paths (not drive letters) to access network shares. I know the
> service login & password have to
> have a matching account on the server with the shares in order for the
> tomcat app to use (access) those shares. We do all of this. Out tomcat app
> depends on
> network shares to function and it always has worked as long as the service
> login account matches an account on the server with the shares.
>
> What I'm trying to do in an html interface is make a pulldown menu list of
> my mapped drives as a location for our database backup. It's a preference
> setup to
> where an automated scheduled backup will write the backups. I'm using "net
> use" to produce what you would expect for output (all the mapped network
> drives)
> and parsing the output to produce the pulldown menu item containing the
> unc portion gleaned from the "net use" output. I need the unc portion as
> this is what
> a tomcat app needs. No matter what I do outside the app I cannot produce
> the effectively empty list that the app is producing. I'm logged into
> Windows as the same
> account as the service and I open a command prompt and see all my mapped
> drives via "net use". I have tried UAC on and off and it changes nothing. I
> added a simple
> "dir" to the app and I can get that output but not the "net use" output. I
> do know it has to do with the service as I said because when tomcat is
> started via the startup.bat
> it works great.
>
> Maybe it is a Windows question but thought someone may have had some
> similar experience.
>
> Thanks for eveyone's thoughts.
>
> -Pat
>
>
>
>
Pat,
I believe the Windows workstation service is required to map drives.
Background services in general run under a different context, thus, they
cannot map drives.
That being said you should be able to achieve this by allowing your Tomcat
service to "interact with desktop" then actually mapping your drives in
scripted fashion using a series of
net use F: \\target\one /PERSISTENT:YES
net use G: \\target\two /PERSISTENT:YES

Now when you do a list using "net use" it should list drives for your
service.

HTH
-Bilal

Re: runtime.exec "cmd.exe /C net use"

Posted by Patrick Flaherty <pf...@rampageinc.com>.
On Mar 23, 2013, at 10:00 PM, David Kerber wrote:

> On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>>
>>
>>> -----Original Message-----
>>> From: André Warnier [mailto:aw@ice-sa.com]
>>> Sent: Saturday, March 23, 2013 8:10 PM
>>> To: Tomcat Users List
>>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>>
>>> Harris, Jeffrey E. wrote:
>>>>
>>>>> -----Original Message-----
>>>>> From: Patrick Flaherty [mailto:pflahrty@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
>>>
>>> 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.
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>
>> I absolutely agree.  I would expect to see the same behavior with  
>> Apache HTTPD, IIS, or
>> any other service that accesses mapped drives.  It is a question of  
>> how service accounts behave
>> in the windows architecture, rather than something specific with  
>> Tomcat.
>>
>> Jeffrey Harris
>
> It will depend on what user your TC service is running under.    If  
> it's running as the LocalSystem user,  it will not have access to  
> any network drives, or many other network resources.  It can hit  
> some, such as databases.
>
> If you want your TC to be able to see networked drives, you need to  
> run it under the logged-on user's ID.  Keep in mind, though, that if  
> the user logs off, the drives will be disconnected.  Your best bet  
> in that case it to not connect by drive letter, but rather by the  
> UNC name (what you used to map it when you were logged on).  That  
> will work if the user TC is running has has the appropriate  
> permissions to the network resource.
>
> D

Hi,

Thanks for all the input. I know about service logins being only able  
to use UNC paths (not drive letters) to access network shares. I know  
the service login & password have to
have a matching account on the server with the shares in order for the  
tomcat app to use (access) those shares. We do all of this. Out tomcat  
app depends on
network shares to function and it always has worked as long as the  
service login account matches an account on the server with the shares.

What I'm trying to do in an html interface is make a pulldown menu  
list of my mapped drives as a location for our database backup. It's a  
preference setup to
where an automated scheduled backup will write the backups. I'm using  
"net use" to produce what you would expect for output (all the mapped  
network drives)
and parsing the output to produce the pulldown menu item containing  
the unc portion gleaned from the "net use" output. I need the unc  
portion as this is what
a tomcat app needs. No matter what I do outside the app I cannot  
produce the effectively empty list that the app is producing. I'm  
logged into Windows as the same
account as the service and I open a command prompt and see all my  
mapped drives via "net use". I have tried UAC on and off and it  
changes nothing. I added a simple
"dir" to the app and I can get that output but not the "net use"  
output. I do know it has to do with the service as I said because when  
tomcat is started via the startup.bat
it works great.

Maybe it is a Windows question but thought someone may have had some  
similar experience.

Thanks for eveyone's thoughts.

-Pat








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


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


Re: runtime.exec "cmd.exe /C net use"

Posted by David Kerber <dc...@verizon.net>.
On 3/23/2013 8:13 PM, Harris, Jeffrey E. wrote:
>
>
>> -----Original Message-----
>> From: André Warnier [mailto:aw@ice-sa.com]
>> Sent: Saturday, March 23, 2013 8:10 PM
>> To: Tomcat Users List
>> Subject: Re: runtime.exec "cmd.exe /C net use"
>>
>> Harris, Jeffrey E. wrote:
>>>
>>>> -----Original Message-----
>>>> From: Patrick Flaherty [mailto:pflahrty@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
>>
>> 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.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>
> I absolutely agree.  I would expect to see the same behavior with Apache HTTPD, IIS, or
> any other service that accesses mapped drives.  It is a question of how service accounts behave
> in the windows architecture, rather than something specific with Tomcat.
>
> Jeffrey Harris

It will depend on what user your TC service is running under.    If it's 
running as the LocalSystem user,  it will not have access to any network 
drives, or many other network resources.  It can hit some, such as 
databases.

If you want your TC to be able to see networked drives, you need to run 
it under the logged-on user's ID.  Keep in mind, though, that if the 
user logs off, the drives will be disconnected.  Your best bet in that 
case it to not connect by drive letter, but rather by the UNC name (what 
you used to map it when you were logged on).  That will work if the user 
TC is running has has the appropriate permissions to the network resource.

D


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


RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: André Warnier [mailto:aw@ice-sa.com]
> Sent: Saturday, March 23, 2013 8:10 PM
> To: Tomcat Users List
> Subject: Re: runtime.exec "cmd.exe /C net use"
>
> Harris, Jeffrey E. wrote:
> >
> >> -----Original Message-----
> >> From: Patrick Flaherty [mailto:pflahrty@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
>
> 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.
>
>
>
>
> ---------------------------------------------------------------------

I absolutely agree.  I would expect to see the same behavior with Apache HTTPD, IIS, or
any other service that accesses mapped drives.  It is a question of how service accounts behave
in the windows architecture, rather than something specific with Tomcat.

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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


Re: runtime.exec "cmd.exe /C net use"

Posted by André Warnier <aw...@ice-sa.com>.
Harris, Jeffrey E. wrote:
> 
>> -----Original Message-----
>> From: Patrick Flaherty [mailto:pflahrty@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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: runtime.exec "cmd.exe /C net use"

Posted by "Harris, Jeffrey E." <Je...@ManTech.com>.

> -----Original Message-----
> From: Patrick Flaherty [mailto:pflahrty@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.

Jeffrey Harris

This e-mail and any attachments are intended only for the use of the addressee(s) named herein and may contain proprietary information. If you are not the intended recipient of this e-mail or believe that you received this email in error, please take immediate action to notify the sender of the apparent error by reply e-mail; permanently delete the e-mail and any attachments from your computer; and do not disseminate, distribute, use, or copy this message and any attachments.

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