Link to home
Start Free TrialLog in
Avatar of arichee
arichee

asked on

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
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

I would suspect that if you are running this as a service, you are not logged on, hence the error.

Anthony
Avatar of arichee
arichee

ASKER

The error occurs when I attempt to start the service manually from the Computer Manager in Win2000.
Than I have no clue.  Perhaps someone else will chime in.

Anthont
How did you install the service with instsrv ? there are a few more steps than just running instsrv ProgramName.exe
Why would you want to run this as a service.After it maps the drive what is it supposed to do,just keep running?
Avatar of arichee

ASKER

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
Avatar of arichee

ASKER

I want it as a service, so the z: drive will be mapped whether you're logged in or not.
ASKER CERTIFIED SOLUTION
Avatar of hes
hes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial