#134222 - 2005-02-21 08:03 PM
Add reg entry
|
jmaclaurin
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
|
|
|
|
#134226 - 2005-02-21 08:50 PM
Re: Add reg entry
|
jmaclaurin
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
   
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
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
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
   
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1046 anonymous users online.
|
|
|