none
Creatins registry Keys in windows 10 RRS feed

  • Question

  • im creatin a series of vbscripts that are working great on windows xp and 7, this scripts create registry keys and set a screensaver default but im having troubles creatin this registry keys on windows 10, i need some help with the subject because i dont know how to proceed 

    Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set oss = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    
    OSVersion=""
    Const HKEY_CURRENT_USER = &H80000001
    Dim objRegistry, strComputer, strKeyPath1, strKeyPath2, strKeyPath3, strValueName, dwValue
    
    Set WSHShell = CreateObject("WScript.Shell")
    Set FSO = CreateObject("Scripting.FileSystemObject")
    
    
    For Each os in oss
    OSVersion= os.version
    Next
    
    Select Case Left(OSVersion,1)
    '----------------
    'Seleccion del SO
    '----------------
    Case"4" 'Windows 10 ******************************************************************************
    
    	bElevate = False
    	if WScript.Arguments.Count > 0 Then If WScript.Arguments(WScript.Arguments.Count-1) <> "|" then bElevate = True
    	if bElevate Or WScript.Arguments.Count = 0 Then ElevateUAC
    
    		'-----------------------------------------
    		SetAllUsersRegKey "Software\djmclean\HtmlScreenSaver\Config\URL","C:\MicroTec\ScrSaver2015\logo.htm#http://screensaver.cencosud.corp/Mesa_Ayuda.htm","REG_SZ"
    		SetAllUsersRegKey "Software\djmclean\HtmlScreenSaver\Config\URL1","C:\MicroTec\ScrSaver2015\logo.htm#http://screensaver.cencosud.corp/Mesa_Ayuda.htm","REG_SZ"
    		SetAllUsersRegKey "Software\djmclean\HtmlScreenSaver\Config\NoBorder","1","REG_SZ"
    		SetAllUsersRegKey "Software\djmclean\HtmlScreenSaver\Config\NoBorder1","1","REG_SZ"
    		SetAllUsersRegKey "Software\djmclean\HtmlScreenSaver\Config\NoContext","1","REG_SZ"
    		SetAllUsersRegKey "Software\djmclean\HtmlScreenSaver\Config\UseCapsLock","0","REG_SZ"
    
    		FSO.CopyFile "C:\MicroTec\ScrSaver2015\sshtml.scr","C:\Windows\System32\",True
    		'-----------------------------------------
    	'********************************* Rutinas*********************************
    	Sub ElevateUAC
    		sParms = " |"
    		If WScript.Arguments.Count > 0 Then
    				For i = WScript.Arguments.Count-1 To 0 Step -1
    				sParms = " " & WScript.Arguments(i) & sParms
    			Next
    		End If
    		Set oShell = CreateObject("Shell.Application")
    		oShell.ShellExecute "wscript.exe", Chr(34)& WScript.ScriptFullName &Chr(34) & sParms, , "runas", 1
    		WScript.Quit
    	End Sub
    	
    	
    	'********************************* Rutinas*********************************
    Sub SetAllUsersRegKey (sKeyName,sData,sType)
    	Dim oShell, sCommand, oUserRegDic, oSubFolder, sKey, oReg, sSubKey, aRegKeys, aDesktopKeys
    	Set oShell = CreateObject("Wscript.Shell")
    	Set oFSO = CreateObject("Scripting.FileSystemObject")
    	Const HKEY_USERS  = &H80000003 'HKEY_USERS
    
    	sCommand = "%comspec% /c " & oShell.ExpandEnvironmentStrings("%WINDIR%") & "\System32\Reg.exe "
    	oShell.RegWrite "HKCU\" & sKeyName,sData,sType
    	Set oUserRegDic = CreateObject("Scripting.Dictionary")
    	Temp = InStr(oShell.SpecialFolders("AllUsersDesktop"),"\Public")-1
    	'Wscript.Echo (Temp) 				'flag
    	sTemp = Left(oShell.SpecialFolders(AllUsersDesktop),Temp)
    		
    	
    	For Each oSubFolder In (oFSO.GetFolder(sTemp).Subfolders)
    		On Error Resume Next 
    		oUserRegDic.Add oSubFolder,oSubFolder.Name
    		On Error GoTo 0 
    	Next
    	
    	For Each sKey In oUserRegDic.Keys 
    		oShell.Run sCommand & "LOAD " & Chr(34) & "HKU\" & oUserRegDic.Item(sKey) & Chr(34) & " " & chr(34) & sKey & "\NTUser.dat" & Chr(34),0,True 
    	Next
    	Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    	oReg.EnumKey HKEY_USERS,"", aRegKeys
    	
    	For Each sSubkey In aRegKeys
    		oReg.EnumKey HKEY_USERS, sSubkey & "\Control Panel\Desktop", aDesktopKeys
    		If Not IsNull(aDesktopKeys) Then 
    			oShell.RegWrite "HKEY_USERS\" & sSubkey & "\" & sKeyName,sData,sType
    		End If
    	Next
    	For Each sKey In oUserRegDic.Keys 
    		oShell.Run sCommand & "UNLOAD " & Chr(34) & "HKU\" & oUserRegDic.Item(sKey) & Chr(34),0,True 
    	Next
    End Sub
    	
    
    
    
    End Select

    Thanks

    Tuesday, February 21, 2017 3:14 PM

Answers

All replies

  • Your script uses third party software.  Contact the vendor for assistance with the third party settings on W10.


    \_(ツ)_/

    Tuesday, February 21, 2017 3:45 PM
  • We don't use scripts any more to set registry values. Use Group Policy.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, February 21, 2017 5:00 PM
    Moderator
  • yes it use a third party because we need to deploy it in all the enterprise around 60k computers

    we use altiris to do so

    Tuesday, February 21, 2017 5:13 PM
  • yes it use a third party because we need to deploy it in all the enterprise around 60k computers

    we use altiris to do so

    We cannot support or help with third party software.  Contact the vendor for assistance.


    \_(ツ)_/

    Tuesday, February 21, 2017 5:18 PM
  • but for a massive deploy via a third party software like altiris, i need and exe to do so 
    Tuesday, February 21, 2017 5:27 PM
  • but for a massive deploy via a third party software like altiris, i need and exe to do so 

    Your question is too vague.

    As Bill has noted - GPP can set any registry key.  The issue you face is that the vendor has changed the location for Windows 10 due to differences in W10.  Only the vendor can help you with this.


    \_(ツ)_/

    Tuesday, February 21, 2017 5:30 PM
  • sorry but, if i run the script in windows 7 without the third party software(executing it as administrator or double clicking it) it works in the computers its set the screensaver and create all the registry keys, thats the problem. even so it uses a third party software in a standalone run it doesnt work i dont know if i explained it clearly

    the third party software is just for deploy has nothing to do with the registry keys

    Tuesday, February 21, 2017 5:52 PM
  • Reread my answer. Do not try to use a script to set needed registry values on client computers. Use Group Policy. Your question is not a scripting issue.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, February 21, 2017 6:30 PM
    Moderator
  • i dont want to be harsh but ur answer isnt helpful, i need help with the script not to you told me that my way is not right maybe it isnt but i need help with the script not the group policy i need to do all i can to make it work with the script 

    or maybe u can answer this, is just NOT posible to do so in windows 10? but it is in 7 and XP?

    Tuesday, February 21, 2017 6:51 PM
  • You need to familiarize yourself with Group Policy.

    In English we might say what you are trying to do is "fit a square peg into a round hole." In other words, if it is that difficult, you are probably doing something wrong.

    I will repeat the answer I have already provided: Do not use a script. Use Group Policy.

    Group Policy can configure registry settings for users, screen saver preferences, and a lot more.

    This is not a scripting issue. You need to learn the correct tool (in this case, Group Policy) and use instead of trying to script it.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, February 21, 2017 7:02 PM
    Moderator
  • i dont want to be harsh but ur answer isnt helpful, i need help with the script not to you told me that my way is not right maybe it isnt but i need help with the script not the group policy i need to do all i can to make it work with the script 

    or maybe u can answer this, is just NOT posible to do so in windows 10? but it is in 7 and XP?

    You are asking for someone to fix your script.  You have supplied no error messages and no information other than a script and a statement that you need help.  There is no way anyone can be of any help with a vague question about a third party product that is being used in a non-standard way.

    If you do not understand why this is a problem then you will need to contact a consultant who is trained in Windows and scripting.

    Also review this from the top of the forum: This forum is for scripting questions rather than script requests

    We cannot fix you script nor can we contact the vendor for you.


    \_(ツ)_/

    Tuesday, February 21, 2017 7:08 PM
  • it doesnt send any errors, thats why i cant understand why isnt working and for the ntime is not a third party software its created  to work with it but its not it 

    i though u guys knew something about scripting in windows 10 just sayin

    sorry for wasting your time i cant contact my "vendor" 

    Tuesday, February 21, 2017 7:15 PM
  • You are asking, "please help me do something in my script that is a waste of time because there are GPO settings that do this already." What would be the point of reinventing the wheel? Use the correct tool in the first place and you don't need a script.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, February 21, 2017 7:24 PM
    Moderator
  • I assure you we both have many years of experience scripting in Windows and VBScript including all major versions of Windows.

    Start by placing trace statements in your script to see what is being executed and what is being skipped.

    First thing - the following line is wrong:

    Select Case Left(OSVersion,1)

    10 is greater than 1 in length.

    A better method is to split the string then parse it.

    majorVersion = OSVersion.Split(".")(0)


    \_(ツ)_/

    Tuesday, February 21, 2017 7:32 PM