Solved

creating a service that maps a network drive

Posted on 2002-05-22
8
296 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

930 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

16 Experts available now in Live!

Get 1:1 Help Now