Jump to content

Maybe a bug - but very interesting


Recommended Posts

Hello!

Here is the script

;не показывать иконку в системном трее
;#NoTrayIcon
;---------------------------объявление переменных---------------------------------------------
Dim $max_date ;объявление переменной, в которой будет храниться максимальная дата изменения файла
Dim $strdate ;переменная, в которой будет храниться строка текущей даты изменения файла
Dim $numdate ;переменная, в которой будет храниться числовое значение текущей даты изменения файла
Dim $str_srav_date ;переменная, в которую считывается дата из файла тип строка
Dim $num_srav_date ;переменная, в которую считывается дата из файла тип число
Dim $file_list ;список файлов, получаемый из папки
Dim $file_name ;текущее имя файла
Dim $file ;идентификатор текущего файла
Dim $saved_file_name ;сохраненное имя файла с максимальной датой изменения
Dim Const $const_path="\\10.30.5.2\Obmen\Автоматизация\Обновления\CheckXML\!update" ;path to an update folder
Dim Const $const_process="checkxml.exe" ;name of a process for killing
Dim Const $const_file_date="checkxml.txt" ;name of a log file with date of an last update file
Dim $long_file_name ;contains the full path+name of the update file
$max_date=20000101000000 ;инициализация максимальной даты изменения файла минимально возможной датой
;------------------поиск в папке файла с наибольшей датой изменения---------------------------
$file_list=FileFindFirstFile($const_path & "\*.exe") ;инициализирует поиск и вывод списка всех файлов с расширением exe
If $file_list=-1 Then ;если в папке ни одного файла, удовлетворяющего условию *.exe
    Exit ;закончить выполнение программы
EndIf
While true ;бесконечный цикл для организации перебора всех названий файлов
    $file_name=FileFindNextFile($file_list) ;в переменную присваивается имя файла
    If @error Then ExitLoop ;когда файлов в папке больше не осталось, выйти из цикла
    $long_file_name=$const_path & "\" & $file_name ;conacatenation of path and name of an update file
    $strdate=FileGetTime($long_file_name,0,1) ;получаем дату изменения текущего файла в строку
    $numdate=Number($strdate) ;конвертируем полученную строку в числовое значение
    If $max_date<$numdate Then ;если максимальная дата файла меньше полученной
        $max_date=$numdate ;присваиваем полученную дату максимальной
        $saved_file_name=$long_file_name ;получаем длинное имя файла
    EndIf
WEnd
FileClose($file_list) ;конец перебора файлов
;;----------------------считывание даты последнего обновления из файла------------------------------
$file=FileOpen("c:\windows\pfrupdate\" & $const_file_date) ;открытие файла для чтения
$str_srav_date=FileReadLine($file,-1) ;считать последнюю строку - в ней  хранится дата изменения файла, с которого последний раз производилось обновление
$num_srav_date=Number($str_srav_date) ;преобразование к типу число
FileClose($file) ;закрытие файла
;---------------------сравнение максимальной даты изменения файла в папке обновлений и даты, считанной из файла---------------------------------------------
If $max_date<>$num_srav_date Then
    ;FileChangeDir("\\10.30.5.2\Obmen\Автоматизация\Обновления\CheckXML\Rep") ;меняем текущую папку (необходимо для запуска файлов обновлений)
    ;-----------------------запуск файла обновлений---------------------------------
    If ProcessExists($const_process) Then ;If checkxml is running
        ProcessClose($const_process) ;killing the CheckXML process
    EndIf
    RunWait($saved_file_name) ;запуск файла обновлений
    ;-----------------------запись даты изменения в файл-------------------------------
    $file=FileOpen("c:\windows\pfrupdate\" & $const_file_date,2) ;открытие файла для записи при стирании прелыдущего содержимого
    FileWriteLine($file,$max_date) ;запись в файл даты изменения файла, из которого последним производилсь обновление
    FileClose($file) ;закрытие файла
EndIf

The Script file was named as Updater.au3. When I cimpiled it under name Updater.au3 (became an Updater.exe), it works. But... when I renamed it to CheckXML.au3, and compiled...it works only in SciTe editor's window, but doesn't works when compiled (CheckXML.exe not works).

When I renamed my working Updater.exe to CheckXML.exe, it also not works.

When I changed all "checkxml" words to "Is2002" words (inside the script), and compile the script under the name Is2002.exe, it also not works. But it works under the name 111.exe (for example). I can rename checkxml.exe to 111.exe, and script became working.

I debug the script checkxml.exe for the problems and found that script stops here

If $max_date<>$num_srav_date Then
    ;FileChangeDir("\\10.30.5.2\Obmen\Автоматизация\Обновления\CheckXML\Rep") ;меняем текущую папку (необходимо для запуска файлов обновлений)
    ;-----------------------запуск файла обновлений---------------------------------
    If ProcessExists($const_process) Then ;If checkxml is running
        ProcessClose($const_process) ;killing the CheckXML process
    EndIf
    RunWait($saved_file_name) ;запуск файла обновлений
    ;-----------------------запись даты изменения в файл-------------------------------
    $file=FileOpen("c:\windows\pfrupdate\" & $const_file_date,2) ;открытие файла для записи при стирании прелыдущего содержимого
    FileWriteLine($file,$max_date) ;запись в файл даты изменения файла, из которого последним производилсь обновление
    FileClose($file) ;закрытие файла
EndIf

I solved problem (by renaming the scripts), but it is very interesting. Maybe a bug? Possibly. But very inteseting. I killed 2 hours for finding a problem:)

I tried to compile scripts without UPX compression, but scripts not work again.

The script itself in attachment. Sorry for russian comments here.

updater.au3

Link to comment
Share on other sites

Just google the file name and you will get pages of results. Judging by the number of Russian pages involved it seems the Russians have a "thing" about using that file name and I have a hunch I should block it just on general principal. It won't be a bug in AutoIt but it could be something on your system that won't allow it to execute under that name.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

When I closed the door of my job cabinet, I thinking about this. And damn... I am stupid looser.

In $const_process I stored the name for process to killing. And there is a line in my script - If...ProcessExists...ProcessClose($const_process). So, when I named the executable file with name, stored in $const_process, script kills itself, when running. Damn...

Problem solved. Sorry for any wrongful concerns.

CheckXML is a program for check XML-reports made by the PensionFund report program SPU-ORB.

This script allows automatically update this program via LAN from repository.

Thanks to all.

Link to comment
Share on other sites

Killing the process will cause the app to fail every time.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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...