Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • Administrators
Posted

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

NET USE  \\\

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

NET USE /?

for a bit more help (like specifying a user / password when mapping)

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...