NOTE: Scripts are listed at the end (they are lengthy).I am having difficulties embedding special characters in variables. I have found that in the beta, the embedding of % no longer works. It used to be that by doubling up the %, @ and $ symbols, those symbols could be used in an embedded fashion (within quotes or variables). I have included my work so that if I am in error, the error can be seen:-)
I discovered this change while attempting to change passwords on a series of servers (several hundred) that we administer within our administration group. To that end, I have been testing password.exe and KIX scripting with lists in text files.
Our group is using a random password generator to create a list of passwords. My means of accomplishing the changes is via reading lists, a list containing the user names, a list containing the server/domain names, a list of the old passwords, and a list with the new passwords. Then the script changes the passwords in one fell swoop (with output to document results).
However, in testing, I have found several characters that are problematic (when embedded in a variable). I decided to test embedding each character that could be used in a variable. To do this, I wrote another script to test embedding.
My test script, variable list and password script are all at the end of the post.
The issue with the embedded characters in strings (variables) lies in that I can embed characters 33-255 with the exceptions being
34 ("), 38 (&), 39 ('), 60 (< ), 62 (> ), and 124 (|). Characters 1-32 are unimportant as they appear to be Control characters. Most of the characters after 126 are unimportant too (being non-standard keyboard characters).
If anyone has the patience to look through these, perhaps you might comment on better ways to perform these functions and perhaps workarounds or solutions to how to embed these 6 characters. I am still new to scripting and while aware that there are shorter ways to script some of these, have not yet aquired the technical knowledge to write these shortcuts. If you know how to shorten the scripts that feedback would be appreciated as well.
VARIABLETEST.KIX
$var1=""
$var2=4
$count=""
close(1)
REDIRECTOUTPUT ("d:\test\result.txt",0)
IF OPEN (1, "D:\test\vartest.txt",0) =0
$var1=READLINE(1)
$count=33
? "This is what embedded variable $count looks like: ($var1)"
? "These variables will now be tested in a password change."
WHILE @ERROR=0
shell '%comspec% /c password.exe -p new' + $var2 + ' new' + $var1 + ' -u user01 -d \\server01'
select
case @error = 0
? "The password was changed"
case @error = 86
? "Wrong current password"
case @error = 2245
? "Invalid new password"
case @error = 1327
? "You are unable to change this password at this time"
case @error = 5
? "You do not have permission to change your Password"
case 1
? 'An unknown Error "#@error:@serror" has occured'
endselect
sleep 2
$var2=$var1
$var1=READLINE(1)
$count=1+$count
? "This is what embedded variable $count looks like: ($var1)"
DIR ("D:\XFILE\NEWGEN")
IF $COUNT > 255
GOTO FINISH
ELSE
ENDIF
LOOP
:FINISH
ENDIF
CLOSE (1)
$var1=""
$var2=""
$count=""
EXIT
The text file which it reads is as follows:
VARTEST.TXT
'!'
'2quote'
'#'
'$$'
'%%'
'ampersand'
'quote'
'('
')'
'*'
'+'
','
'-'
'.'
'/'
'0'
'1'
'2'
'3'
'4'
'5'
'6'
'7'
'8'
'9'
':'
';'
'less'
'='
'greater'
'?'
'@@'
'A'
'B'
'C'
'D'
'E'
'F'
'G'
'H'
'I'
'J'
'K'
'L'
'M'
'N'
'O'
'P'
'Q'
'R'
'S'
'T'
'U'
'V'
'W'
'X'
'Y'
'Z'
'['
'\'
']'
'^'
'_'
'`'
'a'
'b'
'c'
'd'
'e'
'f'
'g'
'h'
'i'
'j'
'k'
'l'
'm'
'n'
'o'
'p'
'q'
'r'
's'
't'
'u'
'v'
'w'
'x'
'y'
'z'
'{'
'pipe'
'}'
'~'
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
''
Finally, the password change script is as follows:
CHANGEANYPASS.KIX
;Written by Sprint PCS Team
;Modified by Alex Baker
;5/18/2001
;Testing with Kixtart 4.00
;*******************************
;*** Instructions ***
;*******************************
;Run a random password generator
;to create a text list of
;passwords. Compile the list of
;known passwords for accounts
;for which to change passwords.
;Compile a list of servers or
;domains in which to change the
;passwords. Compile a list of
;user IDs that need changing.
;Place all four text lists in
;the Acctid folder.
;*******************************
;*******************************
;*** Change Userid Passwords ***
;*******************************
:Start
CLS
; *** Set some Variables ***
$ARCH="Archives"
$NTLIST="Acctid"
$YR="@STARTDIR\$ARCH\@YEAR"
$MTH="$YR\@Month"
$DAY="$MTH\@MdayNo"
$TIME=@Time
$TIME2=SUBSTR($TIME,1,2)+SUBSTR($TIME,4,2)+SUBSTR($TIME,7,2)
$LOG="$DAY\$TIME2"
$NTFILE="ACCTID.TXT"
$DOMSERVFILE="DOMSERV.TXT"
$CPASSFILE="CPASS.TXT"
$NPASSFILE="NPASS.TXT"
$UID=""
$DMSRV=""
$CPWD=""
$NPWD=""
IF EXIST ("@STARTDIR\$NTLIST\$NTFILE")
Else
CLS
BEEP BEEP BEEP
MESSAGEBOX ("$NTFILE was NOT found in $NTLIST Directory","NT Account File",16,0)
EXIT
ENDIF
IF EXIST ("@STARTDIR\$NTLIST\$DOMSERVFILE")
Else
CLS
BEEP BEEP BEEP
MESSAGEBOX ("$DOMSERVFILE was NOT found in $NTLIST Directory","Domain List File",18,0)
EXIT
ENDIF
IF EXIST ("@STARTDIR\$NTLIST\$CPASSFILE")
Else
CLS
BEEP BEEP BEEP
MESSAGEBOX ("$CPASSFILE was NOT found in $NTLIST Directory","NT Account File",20,0)
EXIT
ENDIF
IF EXIST ("@STARTDIR\$NTLIST\$NPASSFILE")
Else
CLS
BEEP BEEP BEEP
MESSAGEBOX ("$NPASSFILE was NOT found in $NTLIST Directory","NT Account File",22,0)
EXIT
ENDIF
Sleep 2
CLS
AT (15,5) "Have you entered the current passwords,"
AT (16,5) "userids, servers/domains, and new passwords? (Y/N)? "
GETS $1R
IF $1R="Y" GOTO GOOD
ELSE EXIT
ENDIF
:GOOD
CLS
; *** Create the Proper Audit Directories ***
MD "$YR"
MD "$MTH"
MD "$DAY"
MD "$LOG"
; *** Move Account list to Audit Directory ***
Copy "@STARTDIR\$NTLIST\$NTFILE" "$LOG\$NTFILE"
Copy "@STARTDIR\$NTLIST\$DOMSERVFILE" "$LOG\$DOMSERVFILE"
Copy "@STARTDIR\$NTLIST\$CPASSFILE" "$LOG\$CPASSFILE"
Copy "@STARTDIR\$NTLIST\$NPASSFILE" "$LOG\$NPASSFILE"
DEL "@STARTDIR\$NTLIST\$NTFILE"
DEL "@STARTDIR\$NTLIST\$DOMSERVFILE"
DEL "@STARTDIR\$NTLIST\$CPASSFILE"
DEL "@STARTDIR\$NTLIST\$NPASSFILE"
Shell '%Comspec% /c echo $LOG\RESULTS.TXT>"$LOG\RESULTS.TXT'
REDIRECTOUTPUT ("$LOG\RESULTS.TXT",0)
IF OPEN (1,"$LOG\$NTFILE",0) = 0
IF OPEN (2,"$LOG\$DOMSERVFILE",0) = 0
IF OPEN (3,"$LOG\$CPASSFILE",0) = 0
IF OPEN (4,"$LOG\$NPASSFILE",0) = 0
$UID=READLINE(1)
GLOBAL $UID
$DMSRV=READLINE(2)
GLOBAL $DMSRV
$CPWD=READLINE(3)
GLOBAL $CPWD
$NPWD=READLINE(4)
GLOBAL $NPWD
WHILE @ERROR = 0
? "NT Account ID: "+$UID
? "Domain or Server: "+$DMSRV
CALL CAP2.KIX
?
SLEEP 6
$UID=READLINE(1)
GLOBAL $UID
$DMSRV=READLINE(2)
GLOBAL $DMSRV
$CPWD=READLINE(3)
GLOBAL $CPWD
$NPWD=READLINE(4)
GLOBAL $NPWD
LOOP
ENDIF
ENDIF
ENDIF
ENDIF
CLOSE (1)
CLOSE (2)
CLOSE (3)
CLOSE (4)
CLS
MESSAGEBOX ("Completed!!!","Modified passwords",16,0)
; *** Clear variables ***
$ARCH=""
$NTLIST=""
$YR=""
$MTH=""
$DAY=""
$TIME=""
$TIME2=""
$LOG=""
$NTFILE=""
$DOMSERVFILE=""
$CPASSFILE=""
$NPASSFILE=""
$1R=""
$UID=""
GLOBAL $UID
$DMSRV=""
GLOBAL $DMSRV
$CPWD=""
GLOBAL $CPWD
$NPWD=""
GLOBAL $NPWD
SLEEP 2
EXIT
The called CAP2.KIX:
REDIRECTOUTPUT ("$LOG\RESULTS.TXT",0)
shell '%comspec% /c password -p $CPWD $NPWD -u $UID -d $DMSRV > nul'
select
case @error = 0
? "The password was changed"
case @error = 86
? "Wrong current password"
case @error = 2245
? "Invalid new password"
case @error = 1327
? "You are unable to change this password at this time"
case @error = 5
? "You do not have permission to change your Password"
case 1
? 'An unknown Error "#@error:@serror" has occured'
endselect
RETURN
EXIT
If you have read this far, wow! I appreciate your diligence. I hope this information helps you to see what I see.
Thanks,
Alex
abaker09@sprintspectrum.com