Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ActiveXObject(Excel)将Excel.EXE*32保留在PROCES中<;Javascript>;_Javascript_Excel - Fatal编程技术网

ActiveXObject(Excel)将Excel.EXE*32保留在PROCES中<;Javascript>;

ActiveXObject(Excel)将Excel.EXE*32保留在PROCES中<;Javascript>;,javascript,excel,Javascript,Excel,我使用ActiveXObject在后台打开excel应用程序,执行我的函数(在别处定义和调用),然后关闭它。问题是,通过任务管理器,每次我运行程序时,它都会在流程部分创建一个新的EXCEL.EXE*32实例 此脚本位于网页上,它将在一天中经常运行。每次程序运行时创建不同的实例是不可行的 我试着像其他人推荐的那样使用未记录的“CollectGarbage”,但它仍然不能解决问题 有什么想法吗? 谢谢。您可以使用相同的activex对象在任务管理器中终止任务。试试下面的方法 var Excel =

我使用ActiveXObject在后台打开excel应用程序,执行我的函数(在别处定义和调用),然后关闭它。问题是,通过任务管理器,每次我运行程序时,它都会在流程部分创建一个新的EXCEL.EXE*32实例

此脚本位于网页上,它将在一天中经常运行。每次程序运行时创建不同的实例是不可行的

我试着像其他人推荐的那样使用未记录的“CollectGarbage”,但它仍然不能解决问题

有什么想法吗?
谢谢。

您可以使用相同的activex对象在任务管理器中终止任务。试试下面的方法

var Excel = new ActiveXObject('Excel.Application');

Excel.Visible = false;
var Excel_file = Excel.Workbooks.Open(Worksheet);
}

if(x == 2)
{
Excel_file.close(false);
Excel.Quit();
Excel.Application.Quit();
Excel = null;
Excel_file = null;

window.setTimeout(CollectGarbage, 10);
//Excel.DisplayAlerts = false;
}
任务杀手

结束一个或多个进程(按进程id或映像名称)

语法 TASKKILL[/S系统[/U用户名[/P[密码]]] {[/FI filter][/PID processid |/IM imagename]}[/F][/T]

选择权 /S system要连接到的远程系统

var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("taskkill /F /IM EXCEL.exe");
过滤器应用以下过滤器之一:

/U   [domain\]user    The user context under which
                      the command should execute.

/P   [password]       The password. Prompts for input if omitted.

/F                    Forcefully terminate the process(es).

/FI  filter           Display a set of tasks that match a
                      given criteria specified by the filter.

/PID process id       The PID of the process to be terminated.

/IM  image name       The image name of the process to be terminated.
                      Wildcard '*' can be used to specify all image names.

/T                     Tree kill: terminates the specified process
                       and any child processes which were started by it.

这完成了工作,只是有点太好了。是否可以仅限于最近的实例?换句话说,当程序运行时,用户可能会加载另一个excel文件,是否可以添加“taskkill-most-recent excel.exe”这样的子句。也非常感谢你的帮助是的,你可以。每次打开excel进程时,请保存进程id并使用该id将其关闭。我在下面发布了一些命令作为回答。根据需要构建自己的命令。
         Imagename   eq, ne                  String
         PID         eq, ne, gt, lt, ge, le  Positive integer.
         Session     eq, ne, gt, lt, ge, le  Any valid session number.
         Status      eq, ne                  RUNNING | NOT RESPONDING
         CPUTime     eq, ne, gt, lt, ge, le  Time hh:mm:ss
         MemUsage    eq, ne, gt, lt, ge, le  Any valid integer.
         Username    eq, ne                  User name ([Domain\]User).
         Services    eq, ne                  String The service name
         Windowtitle eq, ne                  String
         Modules     eq, ne                  String The DLL name