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
-
Edited by
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:\yourDir\YourApp.exe Param1 Param2 Param3=1»
STARTUPINFO si = {0} ;
PROCESS_INFORMATION pi = {0};
CreateProcess( «c:\yourDir\YourApp.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
-
Marked as answer by
The «1 is Not a Valid Win32 Application» error, also known as CreateProcess Error 193, is a common issue faced by Windows users. This error typically occurs when a user tries to run an application that is not compatible with their system or has been corrupted. In this guide, we will walk you through the steps required to resolve this issue and get your application up and running again.
Table of Contents
- Understanding the Error
- Solutions to Fix the Error
- Solution 1: Checking the File Extension
- Solution 2: Run a System File Check
- Solution 3: Reinstall the Application
- Solution 4: Run a Virus Scan
- Solution 5: Update Windows
- FAQ
- Related Links
Understanding the Error
CreateProcess Error 193, or the ‘1 is Not a Valid Win32 Application’ error, can occur due to various reasons, such as:
- The application is not compatible with your system
- The file has been corrupted
- The file has an incorrect extension
- The registry key for the application is damaged
- The system is infected with malware
Knowing the root cause of the problem will help you choose the right solution to fix the issue.
Solutions to Fix the Error
There are multiple solutions to fix the CreateProcess Error 193. We recommend following these solutions in the order they are presented below.
Solution 1: Checking the File Extension
An incorrect file extension may cause the CreateProcess Error 193. To resolve this issue, follow these steps:
- Locate the application’s executable file (the file with a .exe extension).
- Right-click on the file and choose ‘Properties’ from the context menu.
- In the ‘Properties’ window, check the file extension under the ‘General’ tab.
- If the file extension is not .exe, change it to .exe and click ‘OK.’
- Try running the application again.
If the error persists, proceed to the next solution.
Solution 2: Run a System File Check
Running a System File Check (SFC) helps identify and fix any corrupted system files that may be causing the error. To run an SFC, follow these steps:
- Press
Windows + X
keys and select ‘Command Prompt (Admin)’ or ‘Windows PowerShell (Admin)’ from the list. - In the command prompt or PowerShell, type
sfc /scannow
and pressEnter
. - The system will scan for and attempt to fix any corrupted files. Wait for the process to complete.
- Once the scan is complete, restart your computer and try running the application again.
If the error still occurs, move on to the next solution.
Solution 3: Reinstall the Application
Reinstalling the application can fix any corrupted files or registry keys associated with the application. To reinstall the application, follow these steps:
- Press
Windows + R
keys to open the Run dialog box. - Type
appwiz.cpl
and pressEnter
to open the ‘Programs and Features’ window. - Locate the application causing the error, right-click on it, and select ‘Uninstall.’
- Follow the on-screen instructions to uninstall the application.
- Download the latest version of the application from its official website or a trusted source.
- Install the application and try running it again.
If the problem persists, proceed to the next solution.
Solution 4: Run a Virus Scan
Malware infections can cause the CreateProcess Error 193. To check for and remove any malware from your system, follow these steps:
- Update your antivirus software to the latest version.
- Run a full system scan using your antivirus software.
- If any malware is detected, follow the on-screen instructions to remove it.
- Restart your computer and try running the application again.
If the error still occurs, try the final solution.
Solution 5: Update Windows
Updating Windows can resolve compatibility issues and fix any system bugs that may be causing the error. To update Windows, follow these steps:
- Press
Windows + I
keys to open the Settings app. - Click on ‘Update & Security.’
- In the ‘Windows Update’ tab, click on ‘Check for updates.’
- If any updates are available, follow the on-screen instructions to install them.
- Restart your computer and try running the application again.
If none of the above solutions work, the application may be incompatible with your system or has other issues. Contact the application’s support team for further assistance.
FAQ
1. What does ‘1 is Not a Valid Win32 Application’ mean?
This error message indicates that the application you are trying to run is not compatible with your system or has been corrupted. It can also occur due to incorrect file extensions, damaged registry keys, or malware infections.
2. Can I fix the ‘1 is Not a Valid Win32 Application’ error by running the application in compatibility mode?
Running the application in compatibility mode can sometimes fix the error. To do this, right-click on the application’s executable file, select ‘Properties,’ click on the ‘Compatibility’ tab, check the ‘Run this program in compatibility mode for’ box, and choose the appropriate Windows version from the dropdown menu.
3. Do I need to reinstall my operating system to fix the CreateProcess Error 193?
Reinstalling the operating system is a last resort and should only be considered if all other solutions fail. Before taking this step, try the solutions provided in this guide and contact the application’s support team for assistance.
4. Can faulty hardware cause the ‘1 is Not a Valid Win32 Application’ error?
While it’s less common, faulty hardware, such as a damaged hard drive, can cause the error. If none of the solutions provided in this guide work, consider checking your hardware or consulting a professional.
5. Can I prevent the CreateProcess Error 193 from occurring in the future?
To minimize the chances of encountering this error in the future, ensure that you:
- Always download and install applications from trusted sources
- Keep your Windows operating system and applications updated
- Regularly run system file checks and virus scans
- Maintain a clean and organized registry
- How to perform a System File Check (SFC)
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
BobbeYo1983 opened this issue
Oct 3, 2022
· 10 comments
Assignees
Labels
bug
Something isn’t working
p0
Top priority
Comments
Is there an existing issue for this?
- I have searched the existing issues
Is there a StackOverflow question about this issue?
- I have searched StackOverflow
What happened?
Previously, the project was going. Recently updated and not going.
Relevant logcat output
CreateProcess error=193, %1 не является приложением Win32 A problem occurred starting process 'command 'tools/setup.sh'' > Could not start 'tools/setup.sh' * Try: > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Exception is: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'tools/setup.sh'' at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:241) at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:218) at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:370) at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:87) at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'tools/setup.sh' at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27) at net.rubygrapefruit.platform.internal.WindowsProcessLauncher.start(WindowsProcessLauncher.java:22) at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36) at org.gradle.process.internal.ExecHandleRunner.startProcess(ExecHandleRunner.java:98) at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:71) ... 3 more Caused by: java.io.IOException: Cannot run program "tools/setup.sh" (in directory "C:\DATA\Develop\AS\example\nowinandroid"): CreateProcess error=193, %1 �� �������� ����������� Win32 at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25) ... 7 more Caused by: java.io.IOException: CreateProcess error=193, %1 �� �������� ����������� Win32 ... 8 more
Code of Conduct
- I agree to follow this project’s Code of Conduct
This looks like the shell you’re using is incompatible with the setup bash script. Please try again with a bash-compatible shell.
To be honest, I don’t understand what it is about and what a bash-compatible shell is. I superficially read that this is probably related to Linux. But earlier I collected on Windows and now I’m going to Windows.
Having the same issue on windows.
Same issue in «Android Studio Flamingo | 2022.2.1 Canary 2» on windows
I think we recently added running tools/setup.sh
automatically as part of syncing, which shouldn’t be necessary for just cloning and running the project.
We should probably run it instead inside a Gradle task that can be invoked manually if desired?
CreateProcess error=193, %1 is not a valid Win32 application
A problem occurred starting process ‘command ‘tools/setup.sh»
Could not start ‘tools/setup.sh’
Any solution ?
lelelongwang
referenced
this issue
Oct 10, 2022
Also adds automatic git hooks installation Change-Id: I18debbee43af27db7b95a4202f824fa87e186713
Thanks for reporting this. It should have been fixed in #335
Labels
bug
Something isn’t working
p0
Top priority
Обновил AndroidStudio до 2.2, теперь он при билде проекта выдает мне такую ошибку:
Gradle 'rcp_as' project refresh failed
Error:CreateProcess error=193, %1 не является приложением Win32
Читал по ошибке на микрософтовском сайте, не то, читал на оверфлов, там сетуют изменить методы вызова .exe
на .sh
. Как это исправить?
Вот строка из лога:
2016-09-30 11:15:43,546 [ 391968] WARN - radle.project.ProjectSetUpTask -
2016-09-30 11:15:43,546 [ 391968] INFO - radle.project.ProjectSetUpTask - CreateProcess error=193, %1 не является приложением Win32
Consult IDE log for more details (Help | Show Log)
2016-09-30 11:15:43,546 [ 391968] INFO - ls.idea.gradle.GradleSyncState - Sync with Gradle for project 'rcp_as' failed: CreateProcess error=193, %1 не является приложением Win32
Consult IDE log for more details (Help | Show Log)
2016-09-30 11:15:43,796 [ 392218] INFO - #com.jetbrains.cidr.lang - Clearing symbols finished in 0 s.
2016-09-30 11:15:43,796 [ 392218] INFO - #com.jetbrains.cidr.lang - Loading symbols finished in 0 s.
2016-09-30 11:15:43,796 [ 392218] INFO - #com.jetbrains.cidr.lang - Building symbols finished in 0 s.
2016-09-30 11:15:43,796 [ 392218] INFO - #com.jetbrains.cidr.lang - Saving symbols finished in 0 s.