View Full Version : Enable/Disable File and Printer Sharing


Jon
02-26-2004, 09:43 PM
I am looking for a way to enable and disable file and
printer sharing.

I can install and uninstall the service successfully.
This doesn't help me. Uninstalling file and print also
removes the server service.

With file and print services installed but disabled, the
server service is installed and running. I need this
specific configuration to be successful.

The problem is, I need to do it on hundreds of win2k sp2
(and greater) machines.

Anybody have anything at all which might be of even a bit
of help?

TIA!

Torgeir Bakken (MVP)
02-27-2004, 12:12 AM
Jon wrote:

> I am looking for a way to enable and disable file and
> printer sharing.

I have never seen a script resolution for this...


> I can install and uninstall the service successfully.
> This doesn't help me. Uninstalling file and print also
> removes the server service.
>
> With file and print services installed but disabled, the
> server service is installed and running. I need this
> specific configuration to be successful.

After you have removed F&PS e.g. with snetcfg.exe, you can
install the server service again, this works for me at least:

Export the registry key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer

from a machine where the server service is running as it should, to a registry
file with e.g. the name Lanmansvr.reg

Then, on a computer with no server service installed, run the following two
command lines from e.g. a batch file (note that the rundll32 line will wrap in
the newsreader!):

%SystemRoot%\system32\rundll32.exe setupapi.dll,InstallHinfSection Install.ndi
132 %SystemRoot%\Inf\netserv.inf

regedit.exe /s "Lanmansvr.reg"


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter

Torgeir Bakken (MVP)
02-27-2004, 12:12 AM
Jon wrote:

> I am looking for a way to enable and disable file and
> printer sharing.

I have never seen a script resolution for this...


> I can install and uninstall the service successfully.
> This doesn't help me. Uninstalling file and print also
> removes the server service.
>
> With file and print services installed but disabled, the
> server service is installed and running. I need this
> specific configuration to be successful.

After you have removed F&PS e.g. with snetcfg.exe, you can
install the server service again, this works for me at least:

Export the registry key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer

from a machine where the server service is running as it should, to a registry
file with e.g. the name Lanmansvr.reg

Then, on a computer with no server service installed, run the following two
command lines from e.g. a batch file (note that the rundll32 line will wrap in
the newsreader!):

%SystemRoot%\system32\rundll32.exe setupapi.dll,InstallHinfSection Install.ndi
132 %SystemRoot%\Inf\netserv.inf

regedit.exe /s "Lanmansvr.reg"


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter

Jon
02-27-2004, 01:38 AM
My concern is the 'transportability' of that .reg file.
In previous testing, some folks at our org ran into BSOD
issues following this path. I wasn't involved, so some
of the steps between thier effors and what you describe
below might be quite different. Still, I will certainly
test this out again first thing tomorrow morning.

I've never seen even any hint of a solution to do what
I'm looking for via a script in any of my searches. I've
been at it for quite some time now. Maybe it's just that
I'm lacking search skills, but nothing directly related
to the specific task before me. Does that mean it can't
be done via a script, though?



>-----Original Message-----
>Jon wrote:
>
>> I am looking for a way to enable and disable file and
>> printer sharing.
>
>I have never seen a script resolution for this...
>
>
>> I can install and uninstall the service successfully.
>> This doesn't help me. Uninstalling file and print also
>> removes the server service.
>>
>> With file and print services installed but disabled,
the
>> server service is installed and running. I need this
>> specific configuration to be successful.
>
>After you have removed F&PS e.g. with snetcfg.exe, you
can
>install the server service again, this works for me at
least:
>
>Export the registry key
>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Lanm
anServer
>
>from a machine where the server service is running as it
should, to a registry
>file with e.g. the name Lanmansvr.reg
>
>Then, on a computer with no server service installed,
run the following two
>command lines from e.g. a batch file (note that the
rundll32 line will wrap in
>the newsreader!):
>
>%SystemRoot%\system32\rundll32.exe
setupapi.dll,InstallHinfSection Install.ndi
>132 %SystemRoot%\Inf\netserv.inf
>
>regedit.exe /s "Lanmansvr.reg"
>
>
>--
>torgeir
>Microsoft MVP Scripting and WMI, Porsgrunn Norway
>Administration scripting examples and an ONLINE version
of the 1328 page
>Scripting Guide:
http://www.microsoft.com/technet/scriptcenter
>
>
>.
>

Jon
02-27-2004, 01:38 AM
My concern is the 'transportability' of that .reg file.
In previous testing, some folks at our org ran into BSOD
issues following this path. I wasn't involved, so some
of the steps between thier effors and what you describe
below might be quite different. Still, I will certainly
test this out again first thing tomorrow morning.

I've never seen even any hint of a solution to do what
I'm looking for via a script in any of my searches. I've
been at it for quite some time now. Maybe it's just that
I'm lacking search skills, but nothing directly related
to the specific task before me. Does that mean it can't
be done via a script, though?



>-----Original Message-----
>Jon wrote:
>
>> I am looking for a way to enable and disable file and
>> printer sharing.
>
>I have never seen a script resolution for this...
>
>
>> I can install and uninstall the service successfully.
>> This doesn't help me. Uninstalling file and print also
>> removes the server service.
>>
>> With file and print services installed but disabled,
the
>> server service is installed and running. I need this
>> specific configuration to be successful.
>
>After you have removed F&PS e.g. with snetcfg.exe, you
can
>install the server service again, this works for me at
least:
>
>Export the registry key
>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Lanm
anServer
>
>from a machine where the server service is running as it
should, to a registry
>file with e.g. the name Lanmansvr.reg
>
>Then, on a computer with no server service installed,
run the following two
>command lines from e.g. a batch file (note that the
rundll32 line will wrap in
>the newsreader!):
>
>%SystemRoot%\system32\rundll32.exe
setupapi.dll,InstallHinfSection Install.ndi
>132 %SystemRoot%\Inf\netserv.inf
>
>regedit.exe /s "Lanmansvr.reg"
>
>
>--
>torgeir
>Microsoft MVP Scripting and WMI, Porsgrunn Norway
>Administration scripting examples and an ONLINE version
of the 1328 page
>Scripting Guide:
http://www.microsoft.com/technet/scriptcenter
>
>
>.
>

Torgeir Bakken (MVP)
02-27-2004, 02:15 AM
Jon wrote:

> My concern is the 'transportability' of that .reg file.
> In previous testing, some folks at our org ran into BSOD
> issues following this path. I wasn't involved, so some
> of the steps between thier effors and what you describe
> below might be quite different. Still, I will certainly
> test this out again first thing tomorrow morning.
>
> I've never seen even any hint of a solution to do what
> I'm looking for via a script in any of my searches. I've
> been at it for quite some time now. Maybe it's just that
> I'm lacking search skills, but nothing directly related
> to the specific task before me. Does that mean it can't
> be done via a script, though?

Hi

Same experince for me, I have searched high and low for this several
times both on the Web and with Google newsgroup search (and I am pretty
experienced at searching), and have not even seen a small hint that it
is possible to do from a script. I would think this is an API thing,
so you would need to create an exe file for this.


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter

Torgeir Bakken (MVP)
02-27-2004, 02:15 AM
Jon wrote:

> My concern is the 'transportability' of that .reg file.
> In previous testing, some folks at our org ran into BSOD
> issues following this path. I wasn't involved, so some
> of the steps between thier effors and what you describe
> below might be quite different. Still, I will certainly
> test this out again first thing tomorrow morning.
>
> I've never seen even any hint of a solution to do what
> I'm looking for via a script in any of my searches. I've
> been at it for quite some time now. Maybe it's just that
> I'm lacking search skills, but nothing directly related
> to the specific task before me. Does that mean it can't
> be done via a script, though?

Hi

Same experince for me, I have searched high and low for this several
times both on the Web and with Google newsgroup search (and I am pretty
experienced at searching), and have not even seen a small hint that it
is possible to do from a script. I would think this is an API thing,
so you would need to create an exe file for this.


--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter

Rainer Dachtler
02-28-2004, 12:11 PM
Hi Jon,

if you can live with that:
net stop spooler
That disables also local printing...
On the other hand, why not disable the server service, if you don't need it?

I can imagine, if you disable local logins (per GPO), as a side effect
accessing that specific machines shouldn't be possible too...
That's not tested, just an idea.

Good luck
Rainer

"Jon" <jgarlock@jhcohn.com> schrieb im Newsbeitrag
news:2c2d01c3fcb1$9163beb0$a301280a@phx.gbl...
>
> I am looking for a way to enable and disable file and
> printer sharing.
>
> I can install and uninstall the service successfully.
> This doesn't help me. Uninstalling file and print also
> removes the server service.
>
> With file and print services installed but disabled, the
> server service is installed and running. I need this
> specific configuration to be successful.
>
> The problem is, I need to do it on hundreds of win2k sp2
> (and greater) machines.
>
> Anybody have anything at all which might be of even a bit
> of help?
>
> TIA!

Rainer Dachtler
02-28-2004, 12:11 PM
Hi Jon,

if you can live with that:
net stop spooler
That disables also local printing...
On the other hand, why not disable the server service, if you don't need it?

I can imagine, if you disable local logins (per GPO), as a side effect
accessing that specific machines shouldn't be possible too...
That's not tested, just an idea.

Good luck
Rainer

"Jon" <jgarlock@jhcohn.com> schrieb im Newsbeitrag
news:2c2d01c3fcb1$9163beb0$a301280a@phx.gbl...
>
> I am looking for a way to enable and disable file and
> printer sharing.
>
> I can install and uninstall the service successfully.
> This doesn't help me. Uninstalling file and print also
> removes the server service.
>
> With file and print services installed but disabled, the
> server service is installed and running. I need this
> specific configuration to be successful.
>
> The problem is, I need to do it on hundreds of win2k sp2
> (and greater) machines.
>
> Anybody have anything at all which might be of even a bit
> of help?
>
> TIA!