I want to start process with arguments but it throws me an error
no file in directory found
heres code:
Process.Start(@"inject.exe example.dll example_process")
This is a bit modified code just for "showcase"
first argument is a DLL and second one is process name
basically whole code "works" (I mean it doesn’t throw errors in visual studio) but also doesn’t work as it throws exception with message file not found
or something like that
2
Answers
Looks like
inject.exe
is not in the executable folder. If you are not providing the fully qualified path to the process that you want to execute, then the path is assumed to be relative to the working folder of the current executable.You can work around this by including the folder path that
inject.exe
is located in, in thePATH
environment variable.You can debug this by checking for the existence of the file first:
Parameterizing your process path will help debugging:
Replace
"inject.exe"
with theC:PathToinject.exe
.If the "C:PathToinject.exe" file is not located in the specified directory, you may encounter a "
file not found
" exception inex.Message
.Also, the arguments must have the correct format for
inject.exe
.