Jump to content

Does not work with BETA?


Recommended Posts

I hope I am missing something, but when I execute this script through SCITE or with BETA Run Script, it produces a VERY different result. This is a problem because I am using this portion within another script that requires BETA. I know it is sloppy code, but it works as expected in the released version of AutoIT, and was thrown together haphazardly for troubleshooting.

The rest of the script (in BETA) creates a bunch of text files in a temp\accounts directory, then this part does a DIR command and manipulates the files so they can be used with a usrtogrp command. When run with the released version all works perfectly, but with BETA, the third ini get all messed up. The command is commented for debugging, since I don't want to make the changes until I know the script works.

Any suggestions?

FileDelete("C:\temp\dir.txt")

Run(@ComSpec & " /c " & 'dir c:\temp\accounts > c:\temp\dir.txt', "", @SW_HIDE)
Sleep(2000)
$Dfile = "c:\temp\dir.txt"
$DTxt = FileRead($Dfile, FileGetSize($Dfile))
$DTxt = StringReplace($DTxt, "               ", "= ")
FileDelete("C:\temp\dir2.ini")
FileWriteLine("C:\temp\dir2.ini", "[DIR]")
FileWriteLine("C:\temp\dir2.ini", $DTxt)
FileDelete("C:\temp\dir3.ini")
FileWriteLine("C:\temp\dir3.ini", "[DIR]")

$FArray = IniReadSection("C:\temp\dir2.ini", "DIR")
For $i = 1 To $FArray[0][0]
    $VTxt = $FArray[$i][1]
    $VTxt = StringTrimLeft($VTxt, 3)
    FileWriteLine("C:\temp\dir3.ini", "File = "& $VTxt)
Next

$HArray = IniReadSection("C:\temp\dir3.ini", "DIR")
$Dom = "Domain1"

For $h = 1 to $HArray[0][0]
$HFile =  "c:\temp\accounts\" & $HArray[$h][1]
$HTxt = FileRead($HFile, FileGetSize($HFile))
FileDelete($HFile)
$Group = $HArray[$h][1]
$Grp = StringTrimRight($Group, 4)
FileWriteLine($HFile, "Domain: " & $Dom & @CRLF & "GlobalGroup: " & $Grp & @CRLF & $HTxt)
Next    
    
$GArray = IniReadSection("C:\temp\dir3.ini", "DIR")
For $g = 1 to $GArray[0][0]
;~  Run(@ComSpec & " /c " & 'c:\temp\usrtogrp c:\temp\accounts\' & $GArray[$g][1], "", @SW_HIDE)
MsgBox(0,"debug", "Running the command with the following file: " & @LF & $GArray[$g][1])
Next

Thanks for the help.

KilRoy

Link to comment
Share on other sites

What does c:\temp\dir.txt look like after the command?

Run(@ComSpec & " /c " & 'dir c:\temp\accounts > c:\temp\dir.txt', "", @SW_HIDE)

On my sytem this, obviously, failes as I don't have a c:\temp\accounts folder. :D

Link to comment
Share on other sites

What does c:\temp\dir.txt look like after the command?

Run(@ComSpec & " /c " & 'dir c:\temp\accounts > c:\temp\dir.txt', "", @SW_HIDE)

On my sytem this, obviously, failes as I don't have a c:\temp\accounts folder. :D

It is just a simple DIR command with the output redirected to a file named dir.txt.

Volume in drive C has no label.
 Volume Serial Number is 10C3-D165

 Directory of C:\TEMP\accounts

06/09/2006  10:59 AM    <DIR>         .
06/09/2006  10:59 AM    <DIR>         ..
06/09/2006  10:58 AM                 6 group1.txt
06/09/2006  10:58 AM                37 group2.txt
06/09/2006  10:58 AM                 6 group3.txt
06/09/2006  10:58 AM                37 group4.txt
06/09/2006  10:58 AM                37 group5.txt
               6 File(s)            123 bytes
               2 Dir(s)   6,463,381,504 bytes free

The rest of the script is to write specific headers to the txt files in the accounts directory. One of the finished files should look like this:

Domain: Domain1
GlobalGroup: group1
user1
user2
user3

Interesting, to say the least. It's not a showstopper for me, since I can just copile this part with the production autoit and do a file install and run from the main script. I just wanted to see if anyone had any ideas to what may be going on with this.

Thanks for looking at it, and if I can help any, let me know.

KilRoy

Link to comment
Share on other sites

Given that information I don't think this line will work wery well.

$DTxt = StringReplace($DTxt, "                 ", "= ")oÝ÷ Ù8b²+0«r¢ì"X¶éåzË«Þ+.׫²Ú(vÊ&¶§«­¢+ØÀÌØíQáÐôÅÕ½ÐíY½±Õµ¥¸É¥Ù¡Ì¹¼±°¸ÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐíY½±ÕµMÉ¥°9յȥÌÄÁ̵ÄØÔÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½Ðí¥ÉѽÉä½èÀäÈíQ5@ÀäÈí½Õ¹ÑÌÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÀؼÀä¼ÈÀÀØÄÀèÔä4±Ðí%HÐì¸ÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÀؼÀä¼ÈÀÀØÄÀèÔä4±Ðí%HÐ츸ÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÀؼÀä¼ÈÀÀØÄÀèÔà4ØɽÕÀĹÑáÐÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÀؼÀä¼ÈÀÀØÄÀèÔà4ÌÜɽÕÀȹÑáÐÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÀؼÀä¼ÈÀÀØÄÀèÔà4ØɽÕÀ̹ÑáÐÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÀؼÀä¼ÈÀÀØÄÀèÔà4ÌÜɽÕÀйÑáÐÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìÀؼÀä¼ÈÀÀØÄÀèÔà4ÌÜɽÕÀÔ¹ÑáÐÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½ÐìØ¥±¡Ì¤ÄÈÌåÑÌÅÕ½ÐìµÀì
I1µÀì|(ÅÕ½Ðìȥȡ̤ذÐØÌ°ÌàÄ°ÔÀÐåÑÌÉÅÕ½Ðì($$$(ÀÌØíQáÐôMÑÉ¥¹IÁ± ÀÌØíQáаÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìôÅÕ½Ðì¤(µÍ½à À°ÅÕ½ÐíÑÍÐÅÕ½Ðì°ÀÌØíQáФ

Why it works in prod and not the beta is a beyond me (I dont have prod installed, so I did not test against it).

Link to comment
Share on other sites

after testing... i find a problem with the dir3.ini, i thi8nk its this line

$HTxt = FileRead($HFile, FileGetSize($HFile)) ; this reads the entire file

then........

FileWriteLine($HFile, "Domain: " & $Dom & @CRLF & "GlobalGroup: " & $Grp & @CRLF & $HTxt) ; this writes the entire file and... is in a loop

I am not sure of the EXACT problem

ANYWAY, it seems you are going the long way about this with writing to a file several times

maybe this direction would be easier ... and faster

#Include <File.au3>


FileDelete("C:\temp\dir.txt")

Run(@ComSpec & " /c " & 'dir c:\temp\accounts /a :h /b /s > c:\temp\dir.txt', "", @SW_HIDE)
Sleep(2000)

$Dfile = "c:\temp\dir.txt"
$FileList = ""

_FileReadToArray($Dfile, $FileList)
If (Not IsArray($FileList)) Or (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf

For $g = 1 to $FileList[0]
;~   Run(@ComSpec & " /c " & 'c:\temp\usrtogrp c:\temp\accounts\' & $GArray[$g][1], "", @SW_HIDE)
MsgBox(0,"debug", "Running the command with the following file: " & @LF & $FileList[$g])
Next

8)

NEWHeader1.png

Link to comment
Share on other sites

$DTxt = StringReplace($DTxt, "                 ", "= ")
That line replaces the blank string with "=" to make a readable INI. I don't really care what the key name is, just the data after the "=", since I am doing an IniReadSection.

So, what I end up with is this:

[DIR]
 Volume in drive C has no label.
 Volume Serial Number is 10C3-D165

 Directory of C:\TEMP\accounts

06/09/2006  10:59 AM    <DIR>         .
06/09/2006  10:59 AM    <DIR>         ..
06/09/2006  10:58 AM=  6 group1.txt
06/09/2006  10:58 AM= 37 group2.txt
06/09/2006  10:58 AM=  6 group3.txt
06/09/2006  10:58 AM= 37 group4.txt
06/09/2006  10:58 AM= 37 group5.txt
    6 File(s)           123 bytes
=2 Dir(s)   6,463,381,504 bytes free

Maybe this is just one of those things that makes us scratch our heads!!

Thanks.

KilRoy

Link to comment
Share on other sites

maybe even better

#Include <File.au3>

$Dfile = "c:\temp\accounts"
$FileList = ""

$FileList=_FileListToArray($Dfile, "*.exe", 1 )
If (Not IsArray($FileList)) Or  (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf

For $g = 1 to $FileList[0]
;~   Run(@ComSpec & " /c " & 'c:\temp\usrtogrp c:\temp\accounts\' & $GArray[$g][1], "", @SW_HIDE)
MsgBox(0,"debug", "Running the command with the following file: " & @LF & $FileList[$g])
Next

Notie this line

$FileList=_FileListToArray($Dfile, "*.exe", 1 ) it could be "*.txt" for text only and the number "1" is for files only

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Worked like a charm!! I missed the /b on the DIR command, which would have saved a bunch of the edits. Thanks for teaching me a few more commands!!

I'll try out the second one as well.

Thanks for all the help.

KilRoy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...