Regards,
federico
> Is is possible to enable File and Printer Sharing for Microsoft Networks via
> script?
Hi
You can use Snetcfg.exe for this as long as your clients are Win2k and WinXP.
Snetcfg is a sample tool in the DDK (...\src\network\config\netcfg) that must be
compiled into an exe from the source (C/C++?) before it can be used. It can
list, install and deinstall most network components.
Fortunately, for Win2k, you can download a compiled version at
http://www.jsiinc.com/reghack.htm, tip 4705. This version will not work on
WinXP, you need to compile the version that comes with the WinXP DDK to use it
on WinXP. To obtain the WinXP DDK, if you do not have a MSDN subscription, you
must order the Windows DDK CD (It is available at no charge, but there is a
shipping and handling fee)
http://www.microsoft.com/ddk/
Tip 4705 says "The executable included performes the same function on 2000, with
SP2 or greater". This is not correct, it works on pre-SP2 as well, as long as
you provide the path to the inf file. For SP2 and better this is not necessary.
If you want to use Snetcfg.exe to _enable_ File & Print Sharing (F&PS already
installed, but the checkbox is not checked), you will have to deinstall F&PS
first, and then install again. This will make the checkbox checked.
Win2k with SP >= 2:
snetcfg.exe -v -u MS_Server ' removes F&PS
snetcfg.exe -v -c s -i MS_Server ' adds and enables F&PS
All Win2k:
snetcfg.exe -v -u MS_Server
snetcfg.exe -v -l %windir%\Inf\NETSERV.INF -c s -i MS_Server
With a VBScript:
' Script that enables F&PS
'
' Author: Torgeir Bakken
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = oFSO.GetSpecialFolder(0)
sSnetcfgPath = "c:\snetcfg\snetcfg.exe"
sUninstCmd = Chr(34) & sSnetcfgPath & Chr(34) & " -u MS_Server"
oShell.Run sUninstCmd, 0, True
sInstCmd = Chr(34) & sSnetcfgPath & Chr(34) & " -l " _
& sWinDir & "\Inf\NETSERV.INF -c s -i MS_Server"
iRC = oShell.Run(sInstCmd, 0, True)
If iRC = 1 Then
MsgBox "Enabling of F&PS failed!", vbExclamation, "F&PS Enabling"
WScript.Quit
End If
MsgBox "F&PS enabled!",, "F&PS Enabling"
Here is the help output from snetcfg.exe:
C:\>snetcfg /?
snetcfg [-v] [-l <full-path-to-component-INF>] -c <p|s|c> -i <comp-id>
where,
-l provides the location of INF
-c provides the class of the component to be installed
p == Protocol, s == Service, c == Client
-i provides the component ID
The arguments must be passed in the order shown.
Examples:
snetcfg -l c:\oemdir\foo.inf -c p -i foo
...installs protocol 'foo' using c:\oemdir\foo.inf
snetcfg -c s -i MS_Server
...installs service 'MS_Server'
OR
snetcfg [-v] -q <comp-id>
Example:
snetcfg -q MS_IPX
...displays if component 'MS_IPX' is installed
OR
snetcfg [-v] -u <comp-id>
Example:
snetcfg -u MS_IPX
...uninstalls component 'MS_IPX'
OR
snetcfg [-v] -s <a|n>
where,
-s provides the type of components to show
a == adapters, n == net components
Examples:
snetcfg -s n
...shows all installed net components
OR
snetcfg [-v] -b <comp-id>
Examples:
snetcfg -b ms_tcpip
...shows binding paths containing 'ms_tcpip'
General Notes:
-v turns on the verbose mode
-? Displays this help
--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:3DF64A16...@hydro.com...