Skip to main content

Create process error=2

3 replies [Last post]
munees
Offline
Joined: 2008-09-24

I am on the way of doing antivirus sample project.I can have a problem of delete the exe file of virus.The Exception message is Java.io.exception:CreateProcess error=2.What is the reason for Create process error=2.Please help me.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tarbo
Offline
Joined: 2006-12-18

Win32's CreateProcess returns a 2 as error code when it cannot find the command you specify; more specifically, when the command does not refer to an executable file on its lookup path.

Without some actual code, this is about as far as we can help you.

munees
Offline
Joined: 2008-09-24

Hi friend,
Thank u for ur reply.
I attach my code here,
try
{
File f=new File("C:/WINZIP_TMP.exe");
String s1=f.getAbsolutePath();
System.out.println(""+s1);
Process p=Runtime.getRuntime().exec("C:/WINZIP_TMP.exe");
p.destroy();

System.out.println(""+s1);
f.delete();
System.out.println("Deleted");
}
catch(Exception e1)
{
System.out.println("Exception:"+e1.toString());
}
Go thru the code and give ur's Valuable suggestion.

tarbo
Offline
Joined: 2006-12-18

Try "C:\\WINZIP_TMP.exe" instead of "C:/WINZIP_TMP.exe". Windows uses backslashes as path separator, and while the File class may translate it, Runtime.exec won't.