Announcement

Collapse
No announcement yet.

Change HomePage for user on remote pc in registry (VBS)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change HomePage for user on remote pc in registry (VBS)

    Been using this to reset users homepages (as they dont have rights) remotely - Sometimes they seem to end up with a random homepage like Symantec or MSN.com - anyway, it seems to work fine - just wondered if anyone could see any useless code or if they wanted to use it :P

    Code:
    On Error Resume Next
    '
    Function GetSIDFromUser(UserName)
      Dim DomainName, Result, WMIUser
    
      If InStr(UserName, "\") > 0 Then
        DomainName = Mid(UserName, 1, InStr(UserName, "\") - 1)
        UserName = Mid(UserName, InStr(UserName, "\") + 1)
      Else
        DomainName = CreateObject("WScript.Network").UserDomain
      End If
    
      On Error Resume Next
      Set WMIUser = GetObject("winmgmts:{impersonationlevel=impersonate}!" _
        & "/root/cimv2:Win32_UserAccount.Domain='" & DomainName & "'" _
        & ",Name='" & UserName & "'")
      If Err = 0 Then Result = WMIUser.SID Else Result = ""
      On Error GoTo 0
    
      GetSIDFromUser = Result
    End Function
    
    
    'Constants
    	Const HKEY_CURRENT_USER = &H80000001
    	Const HKEY_USERS        = &H80000003
    	strValue = "http://intranet"
    
    'Input
    	strComputer = InputBox("Please enter the Computer Name:", "Remote IE Home Page Fix")
    	strUser = InputBox("Please enter the User Name:", "Remote IE Home Page Fix")
    If (strcomputer <> vbnullstring) Then
    	If (strUser <> vbnullstring) Then
    		strSID = GetSIDFromUser(strUser)
    	
    		Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    		    strComputer & "\root\default:StdRegProv")
    
    	'Path
    		strKeyPath = strSID & "\Software\Microsoft\Internet Explorer\Main"
    
    	'Fix Value
    		strEntryName = "Start Page"
    		objReg.SetStringValue HKEY_USERS,strKeyPath,strEntryName,strValue
    
    	'Error reporting
    		If Err <> 0 Then
    		WScript.Echo "Error Number: " & Err.Number  & VBNewLine &  Err.Description
    			Err.Clear
    		Else
    			WScript.Echo "Success! " & VBNewLine & strUser & "'s home page on " & strComputer & " is set back to " & strValue
    		End If
    	End if
    End if
    This is my signature.
Working...
X