ice78991
Programmer
- Nov 20, 2006
- 216
The code below uses Java within a coldfusion template
I am trying to launch a process and then terminate it.
If I double click netstat.exe on the desktop in windows and check it
in the task manager, it is automatically removed from the system when it is complete
However, if I launch from java it remains in the task manager after it has finished processing
Is there any way to alter the code below to force windows to purge netstat.exe on completion. I thought about using destroy() but this terminates the process before it has finished
<cfscript>
function exec_cmd(cmd) {
var runtimeClass="";
var out="";
var r="";
var rsnstruct=structNew();
try{
// Initialize the Java class.
runtimeClass=CreateObject("java", "java.lang.Runtime");
// Execute command
r=runtimeClass.getRuntime();
r.exec(cmd);
r.runFinalization();
r.freeMemory();
rsnstruct.success=true;
}
catch(excpt any){
rsnstruct.message=excpt.message;
}
return rsnstruct;
}
command_output = exec_cmd('d:/netstat.exe');
</cfscript>
I am trying to launch a process and then terminate it.
If I double click netstat.exe on the desktop in windows and check it
in the task manager, it is automatically removed from the system when it is complete
However, if I launch from java it remains in the task manager after it has finished processing
Is there any way to alter the code below to force windows to purge netstat.exe on completion. I thought about using destroy() but this terminates the process before it has finished
<cfscript>
function exec_cmd(cmd) {
var runtimeClass="";
var out="";
var r="";
var rsnstruct=structNew();
try{
// Initialize the Java class.
runtimeClass=CreateObject("java", "java.lang.Runtime");
// Execute command
r=runtimeClass.getRuntime();
r.exec(cmd);
r.runFinalization();
r.freeMemory();
rsnstruct.success=true;
}
catch(excpt any){
rsnstruct.message=excpt.message;
}
return rsnstruct;
}
command_output = exec_cmd('d:/netstat.exe');
</cfscript>