Service

lothos12345

Junior Contributor
Joined
May 2, 2002
Messages
294
Location
Texas
We have an server that when it is restarted it looses its share. I need to write a service in Visual Basic.NET that will start when the server starts, look at those folders, and if the folders are not shared, share them. I have never written a service or changed the share of a folder from inside code. Any code examples or recommendations would be greatly appreiciated.
 
A service seems a bit of overkill for such a simple task - what OS is the server running and is it part of a windows domain? If so you could do this easily through a group policy and a startup script.
If not you could use a MS utility called srvany.exe and a batch file to acheive the same result.
 
It is Windows Server 2003 Enterprise Edition and my manager wants a service, though I do agree with you its not my call.
 
Odd choice, normally a service would be running constantly in the background, in this case it would effectively run once and then not really sure what it would be expected to do :confused: Does your manager actually have a reason for wanting a service?

Try this instead, start -> run and enter mmc
File -> Add remove snap-in -> add -> select Group Policy Object Editor and click Add, Finish, Close and then OK. Expand Local Computer Policy, Computer Configuration, Windows Settings and select scripts.
On the right double click startup and then select Add... then Browse...

In the window that appears right click and create a new text file and rename to something useful like mapdrive.cmd and open it in your editor of choice and in it enter something like
Code:
NET USE <drive letter> \\<server name>\<share name>
then save and exit that and keep accepting, okaying etc. till everything is done.

If you are not overly familiar with the NET USE command then drop to a command prompt and just type
Code:
NET USE /?
for a bit more help (like specifying a user / password when mapping)
 
I worked for a guy like that once

He didn't know what it was he really wanted, so once I knew that I created it and told him that that was it.

If your boss 'wants a service' and you don't think he has the brain wattage to check services but, instead, wants a program that will start whenever the PC starts, then write your program and make the appropriate registry entry for Hkey_Local Machine
 
Back
Top