creating a service that maps a network drive

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
aricheeAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
hesConnect With a Mentor Commented:
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
 
Anthony PerkinsCommented:
I would suspect that if you are running this as a service, you are not logged on, hence the error.

Anthony
0
 
aricheeAuthor Commented:
The error occurs when I attempt to start the service manually from the Computer Manager in Win2000.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Anthony PerkinsCommented:
Than I have no clue.  Perhaps someone else will chime in.

Anthont
0
 
hesCommented:
How did you install the service with instsrv ? there are a few more steps than just running instsrv ProgramName.exe
0
 
vinnyd79Commented:
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
 
aricheeAuthor Commented:
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
 
aricheeAuthor Commented:
I want it as a service, so the z: drive will be mapped whether you're logged in or not.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.