Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Set Vista Network Location Category
 

Vbscript / Operating System / Set Vista Network Location Category

This script uses the registry to set the Vista network location category (Public, Home or Work) for a network profile matching the domain that the machine is joined to.

The following registry key contains the network profiles which can be identified by the value of ProfileName;

SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\profiles

The value of Category is set as follows;

Public = 0
Home = 1
Work = 2


Const HKEY_LOCAL_MACHINE = &H80000002

Set objRootLDAP = GetObject("LDAP://RootDSE")
strDomain = objRootLDAP.Get("DefaultNamingContext")

strDomain = Replace(strDomain, ",DC=",".")
strDomain = Replace(strDomain, "DC=","")

strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\profiles"

objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each Subkey in arrSubKeys

strProfKeyPath = strKeyPath & "\" & SubKey

objReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strProfKeyPath, "ProfileName", strProfName

If strProfName = strDomain Then

 objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strProfKeyPath, "Category", 2

End If

Next





Please note that a disclaimer applies to any code on this page.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
     - Exchange
     - Files And Folders
     - General
     - Ms Office
     - Operating System
          - Add Remove Windows Server 2003 Components
          - Add Remove Windows Vista Components
          - Add Remove Windows Xp Components
          - Autologon And Runonce
          - Change Display Resolution
          - Change Location I386 Setup Files
          - Change Offline Folder Cache Location
          - Dell Bios Set Boot Device Order
          - Dell Bios Set Configuration Settings
          - Dell Bios View Configuration Settings
          - Dell Bios View Device Boot Order
          - Disable Vista User Account Control
          - Enumerate Cd Drives
          - Enumerate Computer Drives
          - Enumerate Disk Volumes
          - Enumerate Registry Keys
          - Flush Remote Dns Cache
          - Get Domain Name
          - Get Machine Hardware Model
          - Read Registry Key
          - Rename Computer
          - Rename Dell Machine By Service Tag
          - Set Internet Explorer Homepage
          - Set Random Desktop Wallpaper On Startup
          - Set Vista Network Location Category
          - Start And Stop A Service
          - Vista Disable Ipv6
          - Windows Login Timer
     - Processes And Services
     - Text Processing
     - User Interaction
     - Web Servers