Update Windows Owner and Organization (VBScript)
- Details
- Category: Scripts and Code
- Published on Tuesday, 08 November 2011 09:35
- Written by Christian Dunn
This script updates the Windows Owner and Organisation information on Windows Vista or later.
After completion it will show the Windows registration information.
Option Explicit:Dim ws, t, p1, p2, n, g, cn, cg
Set ws = WScript.CreateObject("WScript.Shell")
t = "Change Owner and Organization Utility"
p1 = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\"
p2 = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\"
n = ws.RegRead(p1 & "RegisteredOwner")
g = ws.RegRead(p1 & "RegisteredOrganization")
cn = InputBox("Type new Owner and click OK", t, n)
If cn <> "" Then
ws.RegWrite p1 & "RegisteredOwner", cn
ws.RegWrite p2 & "DefName", cn
End If
cg = InputBox("Type new Organization and click OK.", t, g)
If cg <> "" Then
ws.RegWrite p1 & "RegisteredOrganization", cg
ws.RegWrite p2 & "DefCompany", cg
End IfFunction ExecuteShellProgram(ByVal sFileName)
Dim poShell
Dim poProcess
Dim iStatusSet poShell = CreateObject("WScript.Shell")
Set poProcess = poShell.Exec(sFileName)
'Check to see if we started the process without errorif ((poProcess.ProcessID=0) and (poProcess.Status=1)) then
Err.Raise vbObjectError,,"Failed executing processs"
end if'Now loop until the process has terminated, and pull out
'any console outputDo
'Get current state of the process
iStatus = poProcess.Status
'Forward console output from launched process
'to ours
WScript.StdOut.Write poProcess.StdOut.ReadAll()
WScript.StdErr.Write poProcess.StdErr.ReadAll()
'Did the process terminate?
if (iStatus <> 0) then
Exit Do
end if
Loop
'Return the exit code
ExecuteShellProgram = poProcess.ExitCodeend Function
ExecuteShellProgram "winver"