Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegUpdateAllUsers does not update HKCU Default when run on Windows 8.1 professional #1

Open
mjs6161970 opened this issue Oct 24, 2014 · 3 comments

Comments

@mjs6161970
Copy link

mjs6161970 commented Oct 24, 2014

This is probably the best script I have ever used. We are using Altiris as our software management platform and of course the Altiris agent uses a system account to install software, of course it only updates the HKCU for the system account.

By running this script we can completely replace Group policy (which is very confusing to use) and use this script to update registry keys for multiple users on 1 machine no matter who is running the script. We are running Windows 7 Professional SP 1. Now with this being said, I tried running on Windows 8.1 professional , still works perfectly but it won't update the Default user profile (getting an error message, *\* Unable to update the DEFAULT user profile, because it could not be found at: <blank> ).

I compared the Win7 and Win8 registries side by side and the keys and permissions are identical so there must be something else in Win8 preventing the change. If there is a tweak to your script to fix this, your script would work on everything from WinXP - Win8.1. That would be extremely robust! If you can fix, please let me know. I would be honored to test on my machines here for you.
Mike Shull
[email protected]

@mjs6161970
Copy link
Author

mjs6161970 commented Oct 31, 2014

[SOLVED] I Have a solution to run this in Windows 8.1. You can add the following lines and force the script to run as administrator (notice the extra s so that the other wshshell does not overwrite it) :

add this immediately after on error resume next :

Dim WshsShell, objsshell
Set WshsShell = WScript.CreateObject("WScript.Shell")
If WScript.Arguments.length = 0 Then
Set ObjsShell = CreateObject("Shell.Application")
ObjsShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" &_
" RunAsAdministrator", , "runas", 1
Else

add this AFTER Processing Complete but BEFORE wscript.quit(0) :

End if

@dubbiv
Copy link

dubbiv commented Feb 21, 2017

I am having the same issue when running this on Win07 and Win10, the afore mentioned script does not resolve the issue on either O.S. Member: dubbiv

@mjs6161970
Copy link
Author

mjs6161970 commented Feb 21, 2017

I actually have an update for this. I use the following code at the beginning of all of my VB Scripts. It checks to see if you already have admin rights, if not, it checks to see if the UAC is enabled or disabled, then invokes a prompt if needed, if all fails, the script will exit with a fail message. Works on Windows 7, 8, 8.1, 10, server 2008 r2, server 2012 r2. tested with UAC enabled, disabled, logged on user has admin rights and does not have admin rights.

Make sure, of course, that the variables in the code below are not used anywhere else in your actual script.

*** The space after whsl.run "runas /noprofile /env /user:domain\DomainUserWithAdminRights and before the " & chr(34) IS REQUIRED!!! ***

dim ojsl, whsl, rc

Set whsl = CreateObject("WScript.Shell")
Set ojsl = CreateObject("Shell.Application")
rc = whsl.Run("%comspec% /c net session >nul 2>&1", 0, True)

If not rc = 0 Then
If WScript.Arguments.Count = 0 Then
 ojsl.ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ uac", "", "runas" ,1
 wscript.quit()
end if
end if

If not rc = 0 Then
	whsl.run "runas /noprofile /env /user:domain\DomainUserWithAdminRights " & chr(34) & "%windir%\system32\wscript.exe \" & chr(34) & WScript.ScriptFullName & chr(34) &chr(34)
	wscript.sleep 1000
	whsl.Sendkeys "DomainUserWithAdminRightsPassword"  
	wscript.quit()
end if

If not rc = 0 Then
	msgbox "ERROR!" & chr(10) & chr(10) & "You do not have privileges." 

	WScript.Quit()
	End If

Set ojsl = Nothing
Set whsl = Nothing
Set rc = Nothing

-----begin your script here-----

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants