# Enable File Sharing via the Command Line???



## HorseloverFat (Apr 3, 2006)

Hello all, just a quick question...

I'm trying to automate a large portion of my Windows XP installation... So far I've used a combination of an answer file, OEM drivers, and auto-run batch files to get rid of a large portion of the process. I'm down to just ONE thing that I can't figure out how to do...

I'm trying to add some commands to a batch file that will automatically share a couple of folders on my computer on the local network. So far I'm using:

*net share DS11=D:*

and

*netsh firewall set service type = FILEANDPRINT mode = ENABLE*

and that results in a check box next to File and Print Sharing in the Firewall Exceptions and the hand icon being displayed under my D: drive, but remote computers can't access the shared folder (or browse the computer at all for that matter).

When I right click on D: and choose Sharing and Security I still see the warning "If you understand the security risks but want to share files without running the wizard, click here" like I see the first time I share a folder manually on a new installation of XP, and when I click it I'm given the options to run the wizard or "Just Enable File Sharing". Once I choose "Just Enable File Sharing" everything works fine - there's no need to re-share D: or anything... sooo...

*Basically, all I need is a command that I can add to my batch file that does exactly the same thing as clicking "Just Enable File Sharing."*

I've been searching for a couple of days without a whole lot of luck, so I hope someone here can shed some light on this. 

Thanks in advance for any help you can offer.


----------



## Kalim (Nov 24, 2006)

Hi

Have you started the installation yet or are you in the developmental stages of it? It seems this isn't an installation but a post installation setup your concerned with.

The security advisory link is by design as root folder access is the most dangerous and susceptible to malicious remote users. Microsoft advises against it and thus you are faced with a caution beforehand. I'm not aware of a command that can automatically bypass it yet although I'll look around when I get more time.

BTW, there is no need for any of the this to be in capitals. :grin:

```
netsh firewall set service type = fileandprint mode = mode
```


----------



## HorseloverFat (Apr 3, 2006)

Yeah, I guess it's a post-installation setup... Basically it's a batch file that's going to be run as part of the [guirunonce] section of my answer file, to do all the configuration stuff that can't be done by an answer file alone.

The "net share DS11=D:" command in the batch file bypasses the warning about sharing the root of the drive already. Without doing that I'd have to click okay to that first, and then still click okay to enabling sharing without running the wizard. So I don't need a command for bypassing the root folder warning, just a command to enable file sharing in general. Basically I've got the drive shared already, I just need to enable sharing for the computer in order for it to be accessible.

The drive I'm sharing is purely a storage drive (no system files or installed apps), so I don't think there's any more security risk than just sharing a folder.

And, thanks for the tip on the capitals, that's just how I saw the command line on some other site when I looked it up and I copied and pasted. :chgrin:


----------



## HorseloverFat (Apr 3, 2006)

/bump


----------



## HorseloverFat (Apr 3, 2006)

Okay, I have a little update - I found a command line to open the Network Setup Wizard, which can then be used to enable file and print sharing... Still requires interaction though. This is the command, anyway:

*RunDll32.exe hnetwiz.dll,HomeNetWizardRunDll*

Does anyone know anything about this? Is there a way to run it with some switches to make it do the process itself?


----------



## jethomas (Jan 12, 2007)

*Try this*

Change this in the registry:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\forceguest=dword:0

then you can use net share all you want.


----------

