Solved

creating a service that maps a network drive

Posted on 2002-05-22
8
332 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 …
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month7 days, 8 hours left to enroll

632 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