Advertisement

09.01.2008 at 10:30PM PDT, ID: 23694998
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

VBS Help with registry script

Asked by snyderkv in VB Script

I'm having an issue with this script due to the fact that it actually goes through without poping up any errors. I have been troubleshooting it for a few hours now.

What it does is take th registry settings from ntuser.dat, loads it into my HKLM, then adds registry data and finally unloads the ntuser.dat back into the users profile.

The user is not logged on and I have been trying it with my account.

YOu can see all the script is doing is changing the command prompts color. I copied it from a CBTNuggets video but realized that I had to change one class object to singular instead of plural.

Hopefully one of you can point ot a spelling mistake because I think I'm really really close to doing this. Once complete if possible, I can use it for other things like background fixes or whatever.

Also, I'm passing in the comman line arguments when I put the path to the script in my CMD window. It looks like this
:C:\Computers.txt "software\microsoft\command processor" DefaultColor 2 REG_DWORD

The script is processing the command because I can see the black box pop up twice. I verified the path to the key exc. For some reason the Results file says "updated" when it's not. I do have full control to everything

One more thing, I  see numbers at the end of some strings like 13,50) AND I used """ between a lot of the variables and switches but don't know why the video used three.  I think one of these has something to do with the error.

Thanks aton everyoneStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
'On Error Resume Next
 
strComputers = WScript.Arguments.Item(0)
strKeyPath = WScript.Arguments.Item(1)
strValue = WScript.Arguments.Item(2)
strData = WScript.Arguments.Item(3)
strKeyType = WScript.Arguments.Item(4)
 
Const ForReading = 1
Const ForAppending = 2
 
set objShell = CreateObject("wscript.Shell")
Set fso = CreateObject("scripting.filesystemobject")
Set f = fso.OpenTextFile(strComputers, ForReading, True)
Set ObjTextFile = fso.OpenTextFile("results.csv", ForAppending, True)
 
	Do While f.AtEndOfLine <> True
		strComputer = f.ReadLine
		
		Set objScriptExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer)
		strPingResults = LCase(objScriptExec.StdOut.ReadAll)
		
		If InStr(strPingResults, "reply from") Then
			Set objWMIService = GetObject("winmgmts:" _
				& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Call CheckForLogin (IsLoggedIn)
		If IsloggedIn = True Then
			ObjTextFile.WriteLine(strComputer & ",Logged In")
		Else
			Call UpdateHKU (UpdateHKUResults)
			ObjTextFile.WriteLine(strComputer & ",Updated, " & UpdatedHKUResults)
		End If
Else
	objTextFile.WriteLine(strComputer & " -- NOT RESPONDING ")
		End If
	Loop
	
objShell.Run ("Reg unload HKLM\TempHive"), 0, True
 
Function CheckForLogin (results)
	Set colProcessor = objWMIService.ExecQuery _
		("SELECT * FROM Win32_Processor WHERE Name = 'explorer.exe'")
	If colProcessor.Count = 0 Then
		Results = False
	Else
		Results = True
	End If
End Function
 
Function UpdateHKU (Results)
	Set colSubFolders = objWMIService.ExecQuery _
		("ASSOCIATORS OF {Win32_Directory.Name='C:\docume~1'} " _
			& "WHERE AssocClass = Win32_Subdirectory " _
					& "ResultRole = PartComponent")
					
	For Each objFolder In colSubfolders
		If LCase(Mid(objFolder.Name,13,50)) = "default user" OR _
		LCase(Mid(objFolder.Name,13,50)) = "all users" Then
		Else
		objRemoteFile = "\\" & strComputer & "\c$\" & Mid(objFolder.Name,4,50) & "\ntuser.dat"
		objShell.Run ("reg unload HKLM\TempHive"), 0, True
		objShell.Run ("reg load HKLM\TempHive " & objRemoteFile), 0, True
		objShell.Run ("reg add ""HKLM\TempHive\" & strKeyPath & """ /v """ & strValue & """ /t " _
			& strKeyType & " /d ""' & strDate & '"" /f"), 0, True
		Results = Results & Mid(objFolder.Name,13,50) & ","
	End If
Next
End Function
[+][-]09.01.2008 at 11:20PM PDT, ID: 22364557

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: VB Script
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.03.2008 at 11:04AM PDT, ID: 22379962

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.03.2008 at 04:13PM PDT, ID: 22382934

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628