Windows Service Vs Normal Exe

Posted on 2009-02-19
Last Modified: 2013-11-25

I am struggling to get a service application written in VB6 work..

this is a simple app that deletes some files over  a mapped network drive..

This app is written to run under services.. The app cant cant find the files to delete if it runs under service.. We doubted that it is do with the account under which the service runs.. i even made the service to log on under a domain account (admin) that has access to the mapped network drive..

But interestingly when i run the app just by double clicking the exe it does the deletion without any issues..

I looked the code (bas files)... It doesnt use any specific username in it...

The code simple uses FileSystemObject's FileExists method to look if the file exists before trying to delete.. it cant even find the file...

i dont really understand what is going on...

Any ideas?
Question by:justin_smith
    LVL 44

    Accepted Solution

    Hello justin_smith,

    Do you actually create the drive mapping within the service when running under the domain account? Have you tried using it with straight UNC pathing to the relevant files.



    Author Comment

    nope.. drive mapping is already there in my computer already...
    i am unable to change any code in the program in concern..
    it isnt using UNC though..

    What i tried is a simple vbs to delete a few test files in the same mapping .. but i ran it with with csript and not under  a service..

    i believe that it is the service factor that is stuffing it up...

    i tried a search on google and found this
    something to do with NTLM or stuff..

    I dont have any understand about this stuff though..

    any light?
    LVL 5

    Expert Comment

    grant the domain  user account that you run the service the security right : login as a service"

    Author Comment

    how and where do i need to do this?
    LVL 14

    Expert Comment


    Actual if You wan't to run someting VB 6.0 made as service/prosess (not register to services that's completly different) but only make the form visible=False then it run's there and appears to taskmanager as prosess. Not running app's.

    LVL 24

    Expert Comment

    When you say it deletes files, is the idea that it constantly monitors and deletes files?  Or just does it once, say per logon?

    How are the drives mapped?  It may well be that the mapped drives aren't mapped when the program starts as a service.  Also, how are you running it as a service?  Was it written as a service (not easy in VB6) or are you using srvany?

    Without access to the source of the program, it may be difficult to track down the problem.

    Author Comment

    It does appear in the task manager.. The configuration is also found in Registry for the instance i see in services.msc

    It doesnt work even if I restart the service after making sure the mapped drive is there...

    The question though is why this application is work when i invoke in cmd and not in the service.

    I am trying find answers to the same question from different perspectives
    in the following threads too

    May be info that is shared there is helpful for you
    LVL 24

    Expert Comment

    When you start a service, it starts in the context of the user account specified.  The mapped drives may not be present in that user profile.  Is this a service installed using srvany?

    Author Comment

    hi guys,

    we got this working by using unc paths instead of mapped drives..

    This is only a workaround at the moment...

    Is there a way to solve this..

    it is so strange that MS has restricted Mapped drives for Services

    LVL 24

    Expert Comment

    I would suggest that it isn't a workaround, but a solution.  It makes sense that mapped drives aren't available to a service due to the context services run in.  Simply use the UNC paths instead.  The knowledgebase article specifically states that a service should not try to access mapped drives or use api calls to create one.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now