|
|
|||||||
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 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="" :FINISH The text file which it reads is as follows: VARTEST.TXT '!' Finally, the password change script is as follows: CHANGEANYPASS.KIX ;Written by Sprint PCS Team
IF EXIST ("@STARTDIR\$NTLIST\$NTFILE") IF EXIST ("@STARTDIR\$NTLIST\$DOMSERVFILE") IF EXIST ("@STARTDIR\$NTLIST\$CPASSFILE") IF EXIST ("@STARTDIR\$NTLIST\$NPASSFILE") Sleep 2 CLS AT (15,5) "Have you entered the current passwords," :GOOD ; *** Create the Proper Audit Directories *** ; *** Move Account list to Audit Directory *** Shell '%Comspec% /c echo $LOG\RESULTS.TXT>"$LOG\RESULTS.TXT' REDIRECTOUTPUT ("$LOG\RESULTS.TXT",0) IF OPEN (1,"$LOG\$NTFILE",0) = 0 CLS ; *** Clear variables *** The called CAP2.KIX: REDIRECTOUTPUT ("$LOG\RESULTS.TXT",0)
Thanks, Alex |
||||||||
|
|
|||||||
Long reply... Hi and welcome to the board. I played around with your script a little and this is the top of the result.txt I made: code: As you can see, the ", ', $, &, % and @ are all ok as single entries in the text file. Here is the part of the vartest.txt: code: ok, let's talk about Special Characters: @ examples from my manual: $ % ' and " < and > < is DOS's reverse redirection. For example, there is a program in the NT4 Resource Kit called CLIP. It allows you to put the contents of a file onto the clipboard by doing this CLIP < yourfile.txt In KiX < and > are used to test if one value is less than or greater than another. ie IF 1<2 "the universe is at peace" else "cj says 'welcome to my world'" endif | & I hope I have covered them all. So, the effects of a ', ", @, $, %, &, <, > or | in KiX and DOS will depend on where they are used and how. In DOS surrounding commands in "" often makes DOS ignore them: ie DIR "*.txt>file.txt" will return "file not found" unless you have a filename with ".txt>file.txt". KiX, however, is not fooled so easily and "@date" is the same as @date. KiX needs to see "@@date" to print the @ as a @.
Rather than making a file full of characters, you can use the CHR() function to spit out the character of the number in (). eg CHR(65) is A and chr(97) is a. When you are making passwords, note that some characters may not be allowed... copy/paste this URL into ie: search.microsoft.com/us/SearchMS25.asp?so=RECCNT&qu=characters%2520password%2520%2521&qu=extended+characters+password&boolean=ALL&i=08&i=07&p=1&nq=NEW&fqu=PASSWORD%2526CHARACTERS Numbers in KiX. If you want to generate all the chars between 32 and 123 inclusive: KiXtart 3.6x code: or KiXtart 2001 beta code:
If you save this to a file called PassGen.UDF, you can access it from any script that has CALL "\\server\share\PassGen.UDF" in it. This is because KiX remembers all the UDFs it sees.
code: The exclusion of 0, 1, 5, o, l, s, O and S could reduce the number of "my password doesn't work" call to your help desk If you want to make the password case insensitive, ie a=A then just remove the line ending in ; A..Z from the UDF and change $x=rnd(2) to $x=rnd(1) If you want to add support for special characters, let me know and I can tell you what to put into the UDF. Well, that's enough outta me, anything I miss?
------------------ [This message has been edited by cj (edited 22 May 2001).] |
||||||||
|
|
|||||||
Thanks for the information about differences between DOS handling and Kix handling of special characters. I like the UDF too - short, sweet, efficient. I was reviewing the scripts with a buddy and I decided I had jumped a little soon. By commenting out the shell line and the select case lines in the test script I boiled down the test to just output of characters in Kix. They outputted (word?) just fine. The trouble I run into is outputting the characters generated or read in Kix to a Dos shell. The password.exe command takes all characters typed in on the command line and uses them to change existing passwords. However, when I try to pipe, for instance, existing password lists (so we can change them) we run into the Dos/Kix limitation of how Dos interprets the special characters. I'm not clear whether the limitation is how Kix runs the command shell or whether it lies in how Dos handles the special characters. Regardless, the end result is that I cannot modify existing passwords containing certain special characters. To further test the interoperability of Kix and Dos shells, I modified the script as follows: code variabletest2.kix $count=""
This is what embedded variable 33 looks like: embed!test. Note that characters 38 (&), 60 (< ), 62 (> ), and 124 (|) all fail to hand off in a behaved manner. Also, is it my imagination or did the output characters change from Kix 3.62 to Kix 4.00 (beta 2a). I see several characters that differ from my earlier output file... Thanks, |
||||||||
|
|
|||||||
>Note that characters 38 (&), 60 (< ), 62 (> ), and 124 (|) all fail to hand off in a behaved manner. As I said they would, on the command prompt line they are treated differently. Read this MSKB article: Q103746 It could be that PASSWORD.EXE suffers the same problems. Tell me what extended chars you would like to use and I will add them to the UDF. Try this: $char='"<>|@@$$&%'+"'" The KiX var $char contains "<>|@@$$&%', so KiX will print the @@ as @ and the $$ as $ when it sends this to the command line. What chars would you like to use in the password?
code:
------------------ |