Solved

creating a service that maps a network drive

Posted on 2002-05-22
8
286 Views
Last Modified: 2010-05-02
I wrote and compiled the below module that maps the z: drive to a remote server, then added the executable as a service via INSTSRV.  But when I attempt to start the service, it errors saying it can't start the service.  What could be causing this?

Sub Main()
  Set WshShell = CreateObject("WScript.Shell")
  WshShell.Run ("net use z: \\server\c$ /persistent:yes")
End Sub
0
Comment
Question by:arichee
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7028373
I would suspect that if you are running this as a service, you are not logged on, hence the error.

Anthony
0
 

Author Comment

by:arichee
ID: 7028377
The error occurs when I attempt to start the service manually from the Computer Manager in Win2000.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7028402
Than I have no clue.  Perhaps someone else will chime in.

Anthont
0
 
LVL 20

Expert Comment

by:hes
ID: 7028472
How did you install the service with instsrv ? there are a few more steps than just running instsrv ProgramName.exe
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 28

Expert Comment

by:vinnyd79
ID: 7028475
Why would you want to run this as a service.After it maps the drive what is it supposed to do,just keep running?
0
 

Author Comment

by:arichee
ID: 7028480
From the command line, I typed "instsrv MAPZDRIVE c:\mapzdrive.exe," where mapzdrive.exe is the VB module below:

Sub Main()
 Set WshShell = CreateObject("WScript.Shell")
 WshShell.Run ("net use z: \\server\c$ /persistent:yes")
End Sub
0
 

Author Comment

by:arichee
ID: 7028482
I want it as a service, so the z: drive will be mapped whether you're logged in or not.
0
 
LVL 20

Accepted Solution

by:
hes earned 100 total points
ID: 7028512
VB Programs cannot be installed as a service without the help of 2 intermediate programs. There is ntsvr.ocx available from MS in C source or compiled here http://www.geocities.com/SiliconValley/Pines/3991/ntsvcocx.html

The other for simple programs is to use srvany.exe
(available from here or MS) http://www.geocities.com/SiliconValley/Pines/3991/nthowto.htm

To use the servany method you need to
1)instsrv MAPZDRIVE c:\YourFolder\srvany.exe
2) run regedit32
   go to HKLM (hkey_local_machine)
   System
   CurrentControlSet
   Services
3) Go down until you find MAPZDRIVE
4) edit, new, key
5) Enter Parameters
6) Hightlight Parameters then select [Edit], [New],[String Value]
7) Enter Application
8) Double click Application and type in C:\YourFolder\MAPZDRIVE.exe for the value data.  
Exit regedit32 and start the service
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

18 Experts available now in Live!

Get 1:1 Help Now