Our logon script is providing a local machine and selected services password change and then moves on to look at the computer workstation name. The name is checked against a MS Access Database. If the name is an old name, it gets changed to the new name using a shell command with NetDom.
No problems at the moment as it is working fine...

We found out that we have to alter our naming convention for a selected group of computers. This brings 2 problems. First is the prefix and secondly is the number. We have to use a 5 digit number. In the code below, hopefuly you will be able to see that we parse the machine name, change the number string to an integer, do a counter loop to increment the workstation number then piece it back together with the prefix for a total name:
Code:


; set connection string
$objConn = DBConnOpen('DRIVER={Microsoft Access Driver (*.mdb)}; UID=; PWD=; DBQ=$DBpath')
$recordset = DBGetRecordset($objConn,"SELECT ws_oldName FROM ws WHERE ws_oldName = '@wksta'")
$recordset1 = DBGetRecordset($objConn,"SELECT ws_newName FROM ws ORDER BY ws_newName")
$recordset2 = DBGetRecordset($objConn,"SELECT ws_newName FROM ws WHERE ws_oldName = '@WKSTA'")
If $recordset[0] = @WKSTA
? 'Record for @WKSTA is listed as an old name! Proceed to change machine name'
$ws_rename = $recordset2[0]
Else
? 'No Record Found for @WKSTA! Proceed to Add New Record'
; got to get the last machine name number to increment
$highNum = 0
For Each $record1 In $recordset1
;$recordsetfields=Split($record,Chr(10))
$parseName = Left('$record1',6)
; ? '$parseName' ;for debuging
If $parseName = "NSJNPW"
$parseNum = Right('$record1',5)
; ? '$highNum' ;for debuging
If '$parseNum' >= '$highNum'
$highNum = '$parseNum'
EndIf
EndIf
Next
$wsNewName = CInt($highNum)
$wsNewName = $wsNewName + 1
If $wsNewName < '9999'
? 'Verifying process with naming convention: $parseName @CRLF'
$parseName = '$parseName'+'0'
$wsNewName = '$parseName$wsNewName'
Else
$wsNewName = '$parseName$wsNewName'
EndIf
? 'Process complete. New machine name number is: $wsNewName @CRLF'
? 'The new machine name will be: $wsNewName @CRLF



We now need to add NSSFNW to the naming convetion. I am thinking a switch will do the job for that. However, when we go to NSSFNW, the workstation count needs to start at 00001 and increment from there. I am not sure how to get the number to hold 5 places.
I did cheat when I did the NSNCPW. We arleady have over 1000 workstations so I added a 0 to the name and then just used the counter to add one.
Can anyone provide some suggestions?

Thanks!
_________________________
John
LM Contractor
One of the 2 dads