Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

creating a service that maps a network drive

Posted on 2002-05-22
8
Medium Priority
?
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 400 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
Suggested Courses

670 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