Page 1 of 1 1
Topic Options
#156448 - 2006-02-01 07:28 PM Running Kix's on Remote Machines
Dmartin05 Offline
Fresh Scripter

Registered: 2006-02-01
Posts: 49
Hi all, I am new to Kix and I seem to be having the following problem:

I am running the following kix script:

"If InGroup("MYDomain\MyGroup")
writevalue ("HKEY_USERS\S-1-5-21-3631833995-499989989-2000863303-488478\Software\Microsoft\Internet Explorer\Main\","Start Page","http://www.yahoo.com","REG_SZ")
EndIf

I put my machine in the group and my machine is the only one that gets the registry fix. I am running this cmd locally not as a login script.

Can someone please explain to me possible reasons why the other machines in the group are not getting the script?

Thanks in advance

Dmartin05

Top
#156449 - 2006-02-01 07:38 PM Re: Running Kix's on Remote Machines
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
InGroup() only works on @UserID, not on @WkSta. Likewise the SID is unique to a particular user.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156450 - 2006-02-01 08:00 PM Re: Running Kix's on Remote Machines
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
Give fnInGroupAD() a try for the computer group checking. You'll have to figure out the SID thing yourself.

Edited by Chris S. (2006-02-01 08:02 PM)

Top
#156451 - 2006-02-01 08:26 PM Re: Running Kix's on Remote Machines
Dmartin05 Offline
Fresh Scripter

Registered: 2006-02-01
Posts: 49
Les,
So If I wanted it to work by logins, I would just add "@UserId" at the end of the ingroup()command?

Chris S.
I'm not understanding SID thing, can you elaborate a little more on what you mean?

Thanks

Top
#156452 - 2006-02-01 08:30 PM Re: Running Kix's on Remote Machines
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Quote:

Les,
So If I wanted it to work by logins, I would just add "@UserId" at the end of the ingroup()command?
....





InGroup can only check on a users mebership of that group. Like this.
@userid is not needed in the ingroup query.

Code:

If InGroup("Some group")
?"User is a member"
;do stuff here
EndIf

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#156453 - 2006-02-01 08:44 PM Re: Running Kix's on Remote Machines
Dmartin05 Offline
Fresh Scripter

Registered: 2006-02-01
Posts: 49
Okay so how do i accomplish what i need, can I run a script that will look at a machines.txt file and push out the registry fix?
Top
#156454 - 2006-02-01 09:38 PM Re: Running Kix's on Remote Machines
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Why not just use a GPO to set the home page?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156455 - 2006-02-01 09:59 PM Re: Running Kix's on Remote Machines
Dmartin05 Offline
Fresh Scripter

Registered: 2006-02-01
Posts: 49
Ok, but I still want to know how to use Kix scripts. For example how to run a script that will for example look at a .txt file with pc names on it and run add a desktop icon to it or something. The problem is any script that I run on remote pcs does not seem to be working.
Top
#156456 - 2006-02-01 10:00 PM Re: Running Kix's on Remote Machines
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
lol.
he is running a script locally and wondering why the script doesn't scan a group for members and go automatically writing to those machines' registry.

because that's what the scripts are for.
you are supposed to tell kixtart to do that. and that's called scripting.
_________________________
!

download KiXnet

Top
#156457 - 2006-02-01 10:30 PM Re: Running Kix's on Remote Machines
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The problem is that you are not specifying the remote registry.
writevalue ("HKEY_USERS\S-1-5-21-3631833995-499989989-2000863303-488478\Software\Microsoft\Internet Explorer\Main\","Start Page","http://www.yahoo.com","REG_SZ")
The other problem is that you are hard coding the SID which is specific to one user.
Lastly, you can only modify tose user hives that are loaded at the moment your script runs, so users that are not logged on will not get their hive updated.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156458 - 2006-02-01 10:36 PM Re: Running Kix's on Remote Machines
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Here is some code that will pull a list from AD, ping verify the PC, enum the HKU hives and then read from the HKU hive. All the code has been *borrowed* from this board and credit may not have been given to the original author.
Code:
break on
$ = RedirectOutput('C:\UserNameReport.txt')
$objConnection = CreateObject("ADODB.Connection")
$objCommand = CreateObject("ADODB.Command")
$objConnection.Provider = "ADsDSOObject"
$objConnection.Open("Active Directory Provider")
$objCommand.ActiveConnection = $objConnection

$objCommand.CommandText =
"SELECT Name FROM "
+ "'LDAP://OU=Computers,OU=yada,OU=yada,dc=domain,dc=local'"
+ " WHERE objectCategory='computer'"
$objCommand.Properties("Page Size").Value = 100
$objCommand.Properties("Search Scope").Value = 2
$objCommand.Properties("Cache Results").Value = (not 1)

$objRecordSet = $objCommand.Execute()
$objRecordSet.MoveFirst
while not $objRecordSet.EOF
$curComputer = $objRecordSet.Fields("Name").Value
DoX($curComputer)
$objRecordSet.MoveNext
Loop
$ = RedirectOutput('')
"Done" ?

Function DoX($Computer)
If Ping($Computer)
Dim $BaseKey, $Key, $UserInfo
$BaseKey = '\\' + $Computer + '\HKEY_USERS'
For Each $Key In fEnumKey('',$BaseKey)
If Len($Key) = 44
Select
Case KeyExist($BaseKey + '\' + $Key + '\Software\Microsoft\Office\11.0\Common\UserInfo')
$UserInfo = ReadValue($BaseKey + '\' + $Key + '\Software\Microsoft\Office\11.0\Common\UserInfo', 'UserName')
Case KeyExist($BaseKey + '\' + $Key + '\Software\Microsoft\Office\10.0\Common\UserInfo')
$UserInfo = ReadValue($BaseKey + '\' + $Key + '\Software\Microsoft\Office\10.0\Common\UserInfo', 'UserName')
Case KeyExist($BaseKey + '\' + $Key + '\Software\Microsoft\Office\9.0\Common\UserInfo')
$UserInfo = ReadValue($BaseKey + '\' + $Key + '\Software\Microsoft\Office\9.0\Common\UserInfo', 'UserName')
Case 1
EndSelect
If Len($UserInfo) >4
$Computer + ' = [' + UserName($UserInfo) + ']' ?
EndIf
EndIf
Next
EndIf
EndFunction

;===================
Function UserName($UserInfo)
For $Pos = 1 to Len($UserInfo) step 4
$UserName = $UserName + Chr(Hex2Dec(SubStr($UserInfo,$pos,2)))
Next
EndFunction
;===================
;;FUNCTION Hex2Dec()
;;
;;ACTION Convert a Hex string to a decimal number
;;
;;AUTHOR Glenn Barnas / FRIT-EROC
;;
;;SYNTAX Hex2Dec(HexValue)
;;
;;PARAMETERS HexValue - REQUIRED - Hex value to be converted to Decimal
;;
;;REMARKS Converts hex strings to decimal values. Currently set to
;; use a max of 40 bits (10 hex digits), which is a maximum
;; decimal value of of 1,099,511,627,775 (that's 1 Trillion)
;;
;;RETURNS Decimal value
;;
;;DEPENDENCIES Kix 4.1+
;;
;;TESTED WITH WinNT, Win2K, WinXP, Win2K3
;;
;;EXAMPLES $DecVal = Hex2Dec('3f79cb00')
;
; Convert Hex-number to string representation of Decimal value
Function Hex2Dec($Hex)


; Define the limit
; 40 bits for max value of 549,755,813,888 (1023G or 1023 Billion!)
Dim $MaxBits
$MaxBits = 40


Dim $HexArr, $BinArr, $P, $Ch, $nb, $BinStr, $V, $D
Dim $DecArr[$MaxBits]


$HexArr = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
; Note that the bits in each element are BACKWARDS! - This allows easier L-R LSB->MSB processing
$BinArr = '0000','1000','0100','1100','0010','1010','0110','1110','0001','1001','0101','1101',
'0011','1011','0111','1111'


; Process check - can't handle more than MaxBits/4 hex digits
If Len($Hex) > ($MaxBits / 4)
$Hex2Dec = 0
Exit 87
EndIF


; Init the Decimal Array
$DecArr[1] = 1.0
For $P = 2 to $MaxBits
$DecArr[$P] = $DecArr[$P - 1] * 2
Next




; Convert Hex-number to binary string
$BinStr = ''


For $P = 1 To Len($Hex)
$Ch = SubStr($Hex, $P, 1)
$nb = AScan($HexArr, $Ch)
If $nb < 0 ; Error in hex-string, contains non-valid characters
'invalid hex-string' ?
$BinStr = '0'
Exit 87
EndIf
; Add the string value for the current hex digit
$BinStr = $BinArr[$nb] + $BinStr
Next


; Convert binary string to a decimal number
$Hex2Dec = 0.0
For $P = 1 to Len($BinStr)
$Ch = SubStr($BinStr, $P, 1)
If $Ch = 1
$Hex2Dec = 0.0 + $Hex2Dec + CDbl($DecArr[$P])
EndIf
Next


exit 0


EndFunction

;===================
Function Ping($PC)
Dim $PC
Shell'%comspec% /c ping -n 1 '+$PC+' >nul'
$Ping = NOT @error
EndFunction
;===================
;AUTHOR Howard A. Bullock (habullock@comcast.net)
;
;ACTION Enumerates registries keys on the specified computer.
;
;SYNTAX fEnumKey($Computer, $Key)
;
;PARAMETERS $Computer (Required) - String value
; $Key (Required) - String value
;
;REMARKS Do not prefix the computer name with "\\"'s. Can serve as a
; direct replacement for EnumKey().
;
;RETURNS Array of keys names.
;
;DEPENDENCIES KiXtart 4.02,
;
;EXAMPLES fEnumKey("", "HKEY_USERS")
; fEnumKey("Remote1", "HKEY_USERS")
;
Function fEnumKey($Server, $Key)
Dim $Index, $Error, $x
$Index = 0
Dim $KeyName[$Index]
If $Server <> ""
$Key = "\\" + $Server + "\" + $Key
Endif

If KeyExist($Key)
Do
$x = ENUMKEY($Key, $Index)
$Error = @Error
If NOT $Error and $Index > Ubound($KeyName)
ReDim PRESERVE $KeyName[$Index]
Endif
If NOT $Error
$KeyName[$Index] = $x
$Index = $Index + 1
Endif
Until $Error
Else
$KeyName[0] = ""
Exit 2
Endif
$fEnumKey = $KeyName
Exit 0
Endfunction

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

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
1 registered (Allen) and 1607 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.179 seconds in which 0.144 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