Create process код ошибки 193

The code below fails to start documents. I get error 193 (%1 is not a valid Win32 app). Starting executables work fine.
The files are properly associated, they start the corresponding app when double clicked.
I have searched SO and elsewhere for the error message, createprocess stuff etc. (E.g. Why is CreateProcess failing in Windows Server 2003 64-bit?
I know about quoting the command line.

  • This is a Delphi XE2 (Update 4) Win32 app in a Win7 64bit VMWare VM.

  • The code also fails on the host machine (Win7 64 bit) and in a Virtual PC VM with 32bit XP.

  • The apps that should start in the Win7 VM (Excel 2003 and Crimson Editor) are 32 bit.

  • The failure occurs both when starting from the IDE or when running the test app standalone

  • It used to be Delphi2007 code, the compiled D2007 app where this code comes from works fine everywhere.

What’s wrong with the code?

procedure StartProcess(WorkDir, Filename: string; Arguments : string = '');
var
  StartupInfo  : TStartupInfo;
  ProcessInfo  : TProcessInformation;
  lCmd         : string;
  lOK          : Boolean;
  LastErrorCode: Integer;
begin
  FillChar( StartupInfo, SizeOf( TStartupInfo ), 0 );
  StartupInfo.cb := SizeOf( TStartupInfo );
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := sw_Normal;

  FillChar( ProcessInfo, SizeOf( TProcessInformation ), 0 );

  lCmd := '"' +  WorkDir + FileName + '"';     // Quotes are needed https://stackoverflow.com/questions/265650/paths-and-createprocess
  if Arguments <> '' then lCmd := lCmd + ' ' + Arguments;

  lOk := CreateProcess(nil,
                       PChar(lCmd),
                       nil,
                       nil,
                       FALSE,  // TRUE makes no difference
                       0,      // e.g. CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS makes no difference
                       nil,
                       nil,    // PChar(WorkDir) makes no difference
                       StartupInfo,
                       ProcessInfo);

  if lOk then
  begin
    try
      WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
    finally
      CloseHandle( ProcessInfo.hThread );
      CloseHandle( ProcessInfo.hProcess );
    end;
  end
  else
  begin
    LastErrorCode := GetLastError;
    ShowMessage(IntToStr(LastErrorCode) + ': ' + SysErrorMessage(LastErrorCode));
  end;
end;

procedure TFrmStartProcess.Button1Click(Sender: TObject);
begin
   StartProcess('c:program files (x86)axe3','axe.exe');    // Works
end;

procedure TFrmStartProcess.Button2Click(Sender: TObject);
begin
   StartProcess('d:','klad.xls');                            // Fails
end;

procedure TFrmStartProcess.Button3Click(Sender: TObject);
begin
   StartProcess('d:','smimime.txt');                         // Fails
end;

  • Remove From My Forums
  • Question

  • Hello!

    I tried to run java.exe with CreateProcess on a computer with 32 bit Windows XP SP3 , but it has failed with error code 193 (ERROR_BAD_EXE_FORMAT). On an other computer with the same OS it worked without problem. What can cause this error
    193?

    • Edited by

      Monday, September 26, 2011 10:07 AM

Answers

  • You could try to seperate the application call commandline part from the parameter part.

    i.e. You call your app in this way «c:yourDirYourApp.exe Param1 Param2 Param3=1»

    STARTUPINFO si = {0} ;
    PROCESS_INFORMATION pi = {0};
    CreateProcess( «c:yourDirYourApp.exe», «Param1 Param2 Param3=1», NULL, NULL, TRUE, HIGH_PRIORITY_CLASS, NULL, NULL, &si, &pi);

    I know sometimes there is a strange behaviour if the complete application path with paramters is passed to the CreateProcess function. You can do it of course with varialbes, it is not necessary to set the values directly like I did in the example.

    • Marked as answer by
      Rob Pan
      Tuesday, October 4, 2011 7:56 AM

I am new in C++ and I am using CLion as IDE. I am running the typical program to start with:

    #include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

And I am having the error:

Error running Build All: Cannot run program "C:UsersUserDesktopC++main.cpp" (in directory   "C:UsersUserDesktopC++"): CreateProcess error=193, %1 is not a valid win 32 application.

Can someone give me some insight to the problem?

asked Jul 24, 2016 at 10:02

DimKoim's user avatar

2

This error usually arises when the build files get corrupted or, are not processed properly for any number of reasons.

If you CMakeLists.txt file is correct, delete the folder in cmake-build-debug named as your project name.

If your project name is TEST, cmake-build-debug will have a folder TEST. Delete it and try building and running again.

answered Dec 16, 2021 at 17:34

Nabeegh Ahmed's user avatar

edit configurations:
«Executable:» has to be set to , instead of e.g. the path to your main.cpp file.

answered Dec 11, 2022 at 20:47

Johann Wiengold's user avatar

Having this issue on 2.3.1 and 2.4.0 as well as 2.5.0. This is possibly because of another package?
OS: Windows 10
Yarn: 1.12.3
NodeJs: 10.13.0 LTS

"dependencies": {
    "mobx": "^5.6.0",
    "mobx-react": "^5.3.6",
    "react": "^16.6.3",
    "react-dom": "^16.6.3",
    "react-router-dom": "^4.3.1",
    "source-map-support": "^0.5.9"
  },
  "devDependencies": {
    "@babel/preset-react": "^7.0.0",
    "@types/enzyme": "^3.1.15",
    "@types/enzyme-adapter-react-16": "^1.0.3",
    "@types/jest": "^23.3.9",
    "@types/react": "^16.7.6",
    "@types/react-dom": "^16.0.9",
    "@types/react-router-dom": "^4.3.1",
    "electron": "^3.0.9",
    "electron-builder": "^20.34.0",
    "electron-react-devtools": "^0.5.3",
    "electron-webpack": "^2.5.0",
    "electron-webpack-eslint": "^4.0.0",
    "electron-webpack-ts": "^3.0.0",
    "enzyme": "^3.7.0",
    "enzyme-adapter-react-16": "^1.7.0",
    "eslint": "^5.9.0",
    "eslint-config-prettier": "^3.3.0",
    "eslint-loader": "^2.1.1",
    "eslint-plugin-jest": "^22.0.0",
    "eslint-plugin-prettier": "^3.0.0",
    "eslint-plugin-react": "^7.11.1",
    "eslint-plugin-typescript": "^0.13.0",
    "jest": "^23.6.0",
    "jest-enzyme": "^7.0.1",
    "jest-junit": "^5.2.0",
    "less": "^3.8.1",
    "less-loader": "^4.1.0",
    "prettier": "^1.15.2",
    "react-hot-loader": "^4.3.11",
    "rimraf": "^2.6.2",
    "ts-jest": "^23.10.4",
    "typescript": "^3.1.6",
    "typescript-eslint-parser": "^21.0.0",
    "webpack": "^4.25.1"
  },

Edit: I also tried reverting back to 2.2.1 which also didn’t work. I think there is a third party lib or software conflicting with this.

Уведомления

  • Начало
  • » Центр помощи
  • » PyCharm Community Edition 2021.1.3 x64 CreateProcess error=193, %1 не является приложением Win32

#1 Июль 6, 2021 18:43:32

PyCharm Community Edition 2021.1.3 x64 CreateProcess error=193, %1 не является приложением Win32

Добрый всем ! Помогите с проблемой, сынуля выразил желание изучить python. Скачал ему курс, сидит изучает. Но возникла трудность, выскакивает ошибка при выполнение. Компьютер 64-разрядная операционная система, процессор x64.
Установили Python 3.9.6 и PyCharm Community Edition 2021.1.3 x64
Error running ‘a’: Cannot run program “C:Users79166PycharmProjectspythonProjectvenvScriptspython.exe” (in directory “C:Users79166PycharmProjectspythonProject”): CreateProcess error=193, %1 не является приложением Win32

Помогите решить. Спасибо !

Офлайн

  • Пожаловаться

#2 Июль 6, 2021 20:45:35

PyCharm Community Edition 2021.1.3 x64 CreateProcess error=193, %1 не является приложением Win32

Dmitry_32323
проверьте, где у вас лежит на компе python.exe и совпадает ли путь с тем, где PyСharm пытается его найти

если путь неправильный C:Users79166PycharmProjectspythonProjectvenvScriptspython.exe, то в настройках его измените на правильный

Офлайн

  • Пожаловаться

  • Начало
  • » Центр помощи
  • » PyCharm Community Edition 2021.1.3 x64 CreateProcess error=193, %1 не является приложением Win32

  • Create partition primary ошибка службы виртуальных дисков истекло время выполнения операции
  • Create package xml ошибка прекращена работа программы
  • Create object async ошибка
  • Create 2d texture ошибка call of duty advanced warfare
  • Crc32 не совпадает starline ошибка