Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable or enable File sharing for XP though regedit

Status
Not open for further replies.

Sugada

IS-IT--Management
Aug 1, 2001
33
0
0
US
Windows 9x had this registry trick. Is there one for XP?

Appearently the following doesn't work for XP.

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Network]
"NoFileSharing"=dword:00000000
"NoPrintSharing"=dword:00000000

Thanks, John
 
Here is a vbscript to do what you want to do


Turn on sharing and firewall

Option Explicit

Dim objShell
Dim fwMgr
Dim profile
Set objShell = CreateObject("Shell.Application")
If objShell.IsServiceRunning("SharedAccess") = False Then
'SharedAccess is not running so turn it on
objShell.ServiceStart "SharedAccess", True
wscript.sleep 1000
End If

Set fwMgr = CreateObject("HNetCfg.FwMgr")
Set profile = fwMgr.LocalPolicy.CurrentProfile

If profile.FirewallEnabled = False Then
'Firewall disabled so enable it
profile.FirewallEnabled = True
End If


Turn off sharing and firewall

Option Explicit

Dim objShell
Dim fwMgr
Dim profile
Set objShell = CreateObject("Shell.Application")
If objShell.IsServiceRunning("SharedAccess") = True Then
'SharedAccess is running so turn it off
objShell.ServiceStart "SharedAccess", False
wscript.sleep 1000
End If

Set fwMgr = CreateObject("HNetCfg.FwMgr")
Set profile = fwMgr.LocalPolicy.CurrentProfile

If profile.FirewallEnabled = True Then
'Firewall enabled so disable it
profile.FirewallEnabled = False
End If

Note that this works only when user is administrator
so if the user isn't an admin then you will have to utilize
RunAs functionality.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top