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

Home Forums Scripting General Scripting Change HomePage for user on remote pc in registry (VBS)

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    Lan
    Member
    #126317

    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

    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 & “rootdefault:StdRegProv”)

    ‘Path
    strKeyPath = strSID & “SoftwareMicrosoftInternet ExplorerMain”

    ‘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[/CODE][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&#8221;

    ‘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 & “rootdefault:StdRegProv”)

    ‘Path
    strKeyPath = strSID & “SoftwareMicrosoftInternet ExplorerMain”

    ‘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[/CODE]

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.