Hello! There is a program that first unzips the bz2 archive, and then performs the necessary actions on it. Arkhir is placed in the folder_for_arhiv directory. Unzipped and renamed to .txt permission. In Windows XP, everything works well, and after unarchiving, Windows 7 renames all files in the folder, adding .txt, and does not enter the folder_for_arhiv folder and does not touch the file from the archive. A piece of code:

int f; AnsiString Path = "folder_for_arhiv\\*.bz2"; AnsiString zx; AnsiString zx2; TSearchRec sr; int done = FindFirst( Path, faAnyFile, sr ); while(!done) { s->Add(sr.Name); done = FindNext(sr); } FindClose(sr); for(int i=0;i<s->Count;i++) { //Проходимся циклом по всему списк zx = zx + "folder_for_arhiv\\" + s -> Strings[i] + " "; zx2 = zx2 + s -> Strings[i] + " "; } zx = "bunzip2.exe " + zx; s -> Clear(); zx2 = zx + "\ncd /folder_for_arhiv \nren *.* **.txt"; f = FileCreate("C:\\sss.bat"); FileWrite(f,zx2.c_str(),zx2.Length()); FileClose(f); WinExec("C:\\sss.bat",SW_SHOW); 

The problem is that it does not perceive this line when executing a BAT file:

  zx2 = zx + "\ncd /folder_for_arhiv \nren *.* **.txt"; 

In XP, everything works fine. After unpacking, a file is obtained without an extension, with the help of this line in XP it goes to the folder_for_arhiv directory and adds it to the end of the .txt file

How to remake to work in Windows 7?

    1 answer 1

    I think the fact is that without a super user it is impossible to execute programs from C: in win7. There are several solutions:

    1. executable baht file to move somewhere to a more adequate place (tempo, user folder, local program data)
    2. Run the program with superuser rights.
    • The program runs as Administrator. Starting on unzipping and renaming files will be executed normally, but the transition to the folder_for_arhiv directory does not want, this directory is in the same directory as the EXE file of the program - zesen
    • one
      Well, I think it makes sense to baht then register the full path and not relative - Chad
    • "salt" is that the program folder can be located anywhere ... - zesen
    • having received the full name of the program file, extract the path from there and substitute it in a baht. - Chad