Page 1 of 1 1
Topic Options
#134222 - 2005-02-21 08:03 PM Add reg entry
jmaclaurin Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 8
Loc: Ottawa, Ontario, Canada
I have a hex reg entry that I need to add, but it is quite large in size. How do I add such a large hex value to a kix script?

This is the key.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009]
"Counter"


Edited by jmaclaurin (2005-02-21 08:46 PM)

Top
#134223 - 2005-02-21 08:05 PM Re: Add reg entry
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
And your point is?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#134224 - 2005-02-21 08:12 PM Re: Add reg entry
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
That is a statement not a question.

What sort of help are you looking for? How to write to the registry in general or how to do it remotely or what?

If you only need to do it this one time then it is probably easier / faster to logon and import the reg file.

Top
#134225 - 2005-02-21 08:16 PM Re: Add reg entry
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The "key" is "009". The "value" is "Counter".
I also question the data type. On my XP system at least, that value is of data type REG_MULTI_SZ.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#134226 - 2005-02-21 08:50 PM Re: Add reg entry
jmaclaurin Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 8
Loc: Ottawa, Ontario, Canada
I would like to add it to this script. It is to fix a problem on 120+/- machines.

Code:

GOSUB Setup
IF $ErrMessage = ""
$Machine = READLINE(1)
WHILE @ERROR = 0
? ? "Now Processing Machine: " + $Machine
; Change the following line according to what you need to do.
WRITEVALUE("\\$Machine\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance","Disable Performance Counters","00000000","REG_DWORD")
IF @ERROR = 0
$TestResults = "SMS Reg Fix change completed OK"
ELSE
$TestResults = "SMS Reg Fix change failed (@ERROR)"
ENDIF
; ? "Completed Current Workstation processing."
; $OutError = WRITELINE(2, $Machine + ", " + $TestResults + CHR(13) + CHR(10) )
; $Machine = READLINE(1)
LOOP
?
? "Target File List Completed."
?
CLOSE(1)
CLOSE(2)
ENDIF
; Main Section End
EXIT


:Setup

;
; This Subroutine Initializes the File I/O operations and sets up variables
;

SETCONSOLE("FOREGROUND")
BREAK ON
CLS
FLUSHKB
IF OPEN(1, "C:\LScript\Targets.txt", 2) <> 0
$ErrMessage = "Unable to open Targets.TXT file in current directory."
? $ErrMessage
ENDIF
IF OPEN(2, "Results.txt", 5) <> 0
$ErrMessage = "Unable to open/create Results.TXT file in current directory."
? $ErrMessage
ENDIF

RETURN



Edited by jmaclaurin (2005-02-21 09:35 PM)

Top
#134227 - 2005-02-21 09:07 PM Re: Add reg entry
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
So what is the issue? It isn't adding it, or it's not correcting your issue?

Please use the UBB Code Tags when posting code to keep the formatting. Makes it much easier to read.

Is this the sort of thing you're looking to do?

Disable Performance Counters

Or where is there an article explaining in detail what it is you're wanting to do?

Top
#134228 - 2005-02-21 09:16 PM Re: Add reg entry
jmaclaurin Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 8
Loc: Ottawa, Ontario, Canada
http://support.microsoft.com/default.aspx?scid=kb;en-us;828776

quoted from myitforum as a response to a post I made

http://myitforum.techtarget.com/forums/tm.asp?m=81947&p=16&tmode=1

We have also this problem on some w2k clients

We have found 2 different problems

1. If you look in the registry on one of the problem computers youīll probebly find following registry entry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance
Disable Performance Counters=1
If this is the case youīll have to change it to Disable Performance Counters=0

2. If you look in the registry on one of the problem computers at registry entry
HKEY_LOCAL_MACHINE\software\Microsoft\Windows NT\Currentversion\Perflib\009\Counter
Open the value and check the value after 6, if itīs blank this is the problem, there should be % Processor Time
Look on a computer where you donīt have this problem


The cause is when the program is to run "Only when a user is logged on" or "Only when no user is logged on"
The SMS checks if Launch32.exe process is running to verify if any user is logged on or not. If Disable Performance Counters is set to 1 or 009\counters value 6 is missing % Processor Time then SMS canīt se if launche32.exe is started.

Top
#134229 - 2005-02-21 09:18 PM Re: Add reg entry
jmaclaurin Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 8
Loc: Ottawa, Ontario, Canada
I don't know how to add the large amount of text into the script so that kix will accept it. I tried pasting it in with no luck.
Top
#134230 - 2005-02-21 10:17 PM Re: Add reg entry
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well I don't care to use GOTO and GOSUB myself as I think there are better coding methods.

Here is an example to modify the one registry entry. As for the other entry, without seeing or knowing what it is or should be I don't know how to help you out. Need more information.

Code:
Break On
Dim $SO,$Pause
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')

Dim $Key,$SubKey,$Value,$sComputer,$sComputers,$TestResults,$UpdateReg,$WL
$Key='HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PerfProc\Performance'
$SubKey='Disable Performance Counters'
$Value=0
$sComputers=ReadFile(@ScriptDir+'\systems.txt')
If @ERROR
? 'There was an error reading the systems file. ' + @ERROR
EndIf

For Each $sComputer In $sComputers
If $sComputer
?? 'Now Processing Machine: ' + $sComputer
$UpdateReg=WriteValue('\\'+$sComputer+'\'+$Key,$SubKey,$Value,REG_DWORD)
If @ERROR = 0
$TestResults = 'SMS Reg Fix change completed OK'
Else
$TestResults = 'SMS Reg Fix change failed ' + @ERROR
EndIf
? 'Completed Current Workstation processing on ' + $sComputer
If Open(2 , 'C:\Reports\SMSFIX.TXT' , 5 ) = 0
$WL = WriteLine(2 , $sComputer + ',' + $TestResults + ',' + @DATE + ',' + @TIME + @CRLF )
Else
? 'Failed to open file, error code : [' + @ERROR + ']'
EndIf
If Close(2)
? 'Failed to close file, error code : [' + @ERROR + ']'
EndIf
EndIf
Next
?? 'Target File List Completed.'

Function ReadFile($file)
Dim $lf, $f, $_, $t
$lf=Chr(10)
$f=FreeFileHandle
$_=Open($f,$file)
If @ERROR Exit @ERROR EndIf
Do $t=$t+$lf+ReadLine($f) Until @ERROR
$_=Close($f)
$ReadFile=Split(SubStr($t,2),$lf)
EndFunction


Top
#134231 - 2005-02-22 09:28 AM Re: Add reg entry
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
What is the source of the long string? Where are you copying it from?

I've just cut'n'pasted the string into a script with no problems at all.

As Les says, the field is REG_MULTI_SZ, not binary. A registry export may present it as a hex string, but there is no binary data.

(My) string is about 31kb, which is close to the string limit so you may need to chop it into smaller parts and catenate them. You will also need to remember to double up the "%" characters.

I won't post the string here as it is so large, but I can mail the file to you if you wish.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.061 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org