Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2005, 07:22 AM
Registered User
 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use of NTSVC.OCX

I have recently made use of the NT-Service facility provided by NTSVC.OCX which is also up and running. However I wish to be able to access a network resource of which I have the servername and sharename. Using WMI Functionality I am able to convert these values to a network location "Folder U:\Users\Homes", but I am unable to access this folder as it is not local but exists on another server.
Does anyone know how I can access this folder whilst still running as service?

 
Old June 5th, 2005, 03:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry I do not understand your question.
You have a service A running on computer B. Now what do you want to do again? A server cannot locate folders in another computer, one of the reasons of a server is to expose resources in the local computer to other computers.
Marco
 
Old June 6th, 2005, 10:10 AM
Registered User
 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am running an application as service. Within this application I wish to be able to access a folder which is not local (C:, D:). How can I map a drive while running as a service?

 
Old June 6th, 2005, 12:58 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

To make that work, change two things:

1. Don't use a drive letter but a UNC path like \\SomeServer\SomeShare

2. Configure your server to run under a network account in the Services control panel. A Service often runs under the local System account which doesn't have access to the network.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 6th, 2005, 01:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I repeat myself here. the mean of a NT 'service' is to use resources in the 'local' computer, where the server is running, and to make available to the outside world. For example, I use the computer A and I want to use files (or whatever, printers, login information, remote access, time information etc. In other words, any kind of 'centralized' information) in the computer B. Thus I create a service that runs in the computer B (and not A!). From A, I connect to that server, that gives me back the information I want. A "service' that open files mapped in a network drive does not make any sense!

Marco
 
Old June 6th, 2005, 02:01 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Marco,

Does this always have to be the case in your opinion?

For instance, the service that inserts my "While typing this post ..." at the end of my post is a Windows service running on the local machine. It drops a text file with the track name on a local disk. That file is then picked by another Windows service that drops it on the Web Server's disk over the network.

Would you consider that a bad design? Ideas for improving this?

And how about a Service that polls some kind of incoming folder on the network? E.g. files are FTP'ed to one server and processed by another. Bad design?

I'd appreciate your ideas on this....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Qui Sème le Vent Récolte le Tempo by MC Solaar (Track 2 from the album: Qui Sème le Vent Récolte le Tempo) What's This?
 
Old June 6th, 2005, 03:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes, that is my opinion, but I am not perfect... :-)

for example, we have a FTP service that runs in the "server" machine (that is the computer where the data is centralized) When we need to download a file from another computer, we do not connect to a mapped network, but to that service, and we ask it for that file. The service is responsable to open that file, and to return the content to me. Same for the registry, instead to open the registry of another computer we use a service.

As you specified in your previous post, a service runs by default as a local System account, threfore some trick needs to be used in order to access some resources (for example, a System account cannot have printers...)

As far as judging a design, good or bad, it depends on the application. I am here, just like you, to share my ideas...

Marco

While typing this post I was listeinig to Livestock by BrandX
 
Old June 6th, 2005, 04:15 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Interesting. So you're suggesting that one service passes the file to another service as some binary blob instead of saving the file remotely / opening it remotely?

I agree it depends on the application and there might not be "good or bad". I was just wondering about what's bad about sharing files through services. I think I see your point though.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 6th, 2005, 05:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes, you got my point correctly.
Maybe sharing files was not the best example, there is already FTP to do that, and besides what's the point of creating mapped network drives? But sharing files means that a computer must 'share' one or more folders. If for security reason that is not allowed, that it where a service can help.
Marco
"There are only 10 types of people in the world: Those who understand binary, and those who don't"
 
Old June 7th, 2005, 04:33 AM
Registered User
 
Join Date: Jun 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Imar & Marcostraf,
Although I find your experience interesting, I still don't have a solution to my problem. It may not have be obvious to either of you but there are other reasons why running an application on a particular server is not preferrable or even advisable. E.g. Visual Baisc 6.0 is known for memory leaks whilst running as service, which is not advisable if the server where the application normally should run contains critical information for the daily use by your company, and that having this server always up-and-running can be more important than where the service is running (on a server which is less critical if stopped). Additionally, the server where this application, according to you, should have run, is part of a cluster which presents other problems if the application was to run on it.
Back to the issue: My service is running under a security-account with Admistrator rights. The aim of this application is in fact to set the security rights to user folders (U:\Users\Homes\Username). I derive this location using WMI functionality after which I use "objFileSys.FolderExists(U:\Users\Homes\Userna me)" to determine its presents. I do have a "Servername" and "Sharename".Furthermore I need the mapped location to perform "Takeownership" and "ChangeSecurityPermissions" to the folder.
If you know what I'm talking about, does either of you have a solution besides an opinion.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Including an .ocx dartcoach VB How-To 9 November 13th, 2006 01:37 PM
NTSVC.OCX app and Windows 2000 felixs Pro VB 6 10 November 10th, 2004 05:08 AM
Use Ocx saulodet ADO.NET 0 January 5th, 2004 01:32 PM
NTSVC.OCX and Error = 91 skhan22 Pro VB 6 3 October 24th, 2003 01:18 AM
MSFLXGRD.OCX and MSDATGRD.OCX Clive Astley Access 1 July 25th, 2003 08:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.