方法一:InstallShiel直接调用cmd命令来杀掉进程。    

     //更新或卸载时先关闭应用程序
sCmdLine=" /c taskkill /f /im \"Frs.exe\"";
nResult=LaunchAppAndWait("cmd",sCmdLine ,LAAW_OPTION_HIDDEN|LAAW_OPTION_NOWAIT);

备注:

  1、命令行前 ,记得加上   /c

  2、LaunchAppAndWait()函数第一个参数“cmd”,还有另外一种方式。并不是很好用。

 STRING scCmd;
STRING sCmdLine; scCmd=WINDIR ^ "system32" ^ "cmd.exe";
nResult=LaunchAppAndWait(scCmd,sCmdLine ,LAAW_OPTION_HIDDEN|LAAW_OPTION_NOWAIT);

方法二:来自网友写的一些代码。

 prototype POINTER ArrayToPointer(BYREF VARIANT);
prototype NUMBER ProcessEnd(STRING);
prototype BOOL ProcessRunning(STRING); // Kernel functions. prototype NUMBER Kernel32.OpenProcess(NUMBER, BOOL, NUMBER);
prototype NUMBER Kernel32.TerminateProcess(NUMBER, NUMBER); // Process information functions. prototype NUMBER PSAPI.EnumProcesses(POINTER, NUMBER, BYREF NUMBER);
prototype NUMBER PSAPI.EnumProcessModules(NUMBER, BYREF NUMBER, NUMBER,
BYREF NUMBER);
prototype NUMBER PSAPI.GetModuleFileNameExA(NUMBER, NUMBER, BYREF STRING,
NUMBER); /////////////////////////////////////////////////
// Structures.
///////////////////////////////////////////////// // Structure to mirror the C/C++ SAFEARRAY data structure. typedef _SAFEARRAY
begin
SHORT cDims;
SHORT fFeatures;
LONG cbElements;
LONG cLocks;
POINTER pvData;
// rgsaBound omitted
end; // Structure to mirror the C/C++ VARIANT data structure. typedef _VARIANT
begin
SHORT vt;
SHORT wReserver1;
SHORT wReserved2;
SHORT wReserved3;
NUMBER nData;
end; /////////////////////////////////////////////////
// Constants.
///////////////////////////////////////////////// #define PSAPI_FILE "psapi.dll" // Windows NT process DLL
#define PROCESSID_LENGTH 4 // 4 bytes (DWORD) for a process ID // Process information constants. #define PROCESS_QUERY_INFORMATION 0x400
#define PROCESS_ALL_ACCESS 0x1f0fff
#define PROCESS_VM_READ 0x10 //////////////////////////////////////////////////////////////////////////////
//
// Function: ArrayToPointer
//
// Description: Converts an InstallShield array into a C array.
//
// When an array is created in InstallScript, a VARIANT variable
// is created which holds an OLEAutomation SAFEARRAY. To pass
// such an array to a DLL function expecting a C-style array,
// this function explicitly typecasts the pointer to the array
// to a _VARIANT pointer so that the _SAFEARRAY pointer can be
// extracted. The pointer to the actual data is then extracted
// from the _SAFEARRAY pointer.
//
// Parameters: structArray - Array variable.
//
// Returns: POINTER - Pointer to array.
//
////////////////////////////////////////////////////////////////////////////// function POINTER ArrayToPointer(structArray)
_SAFEARRAY POINTER pstructArray; // _SAFEARRAY array pointer
_VARIANT POINTER pstructVariant; // _VARIANT array pointer
begin
// Typecast the pointer to the array to a _VARIANT pointer. pstructVariant = &structArray; // Extract the _SAFEARRAY pointer from the _VARIANT. pstructArray = pstructVariant->nData; // Return the pointer to the actual data from the _SAFEARRAY. return pstructArray->pvData;
end; //////////////////////////////////////////////////////////////////////////////
//
// Function: _Process_End
//
// Description: Terminates running processes for the specified application.
//
// Parameters: szAppName - Name of the application to terminate.
//
// Returns: >= 0 - Number of processes terminated.
// -1 - Failure.
//
////////////////////////////////////////////////////////////////////////////// function NUMBER ProcessEnd(szAppName)
NUMBER nvReturn; // Number of processes terminated
NUMBER nvProcessIDs(); // Array of process IDs
NUMBER nvBytesReturned; // Number of bytes returned in process ID array
NUMBER nvProcesses; // Number of processes running
NUMBER nvIndex; // Loop index
NUMBER nvProcessHandle; // Handle to a process
NUMBER nvModuleHandle; // Handle to a process module
NUMBER nvBytesRequired; // Number of bytes required to store values
POINTER pvProcessIDs; // Pointer to process ID array
STRING svModuleName; // Module name
STRING svFileName; // Module filename
begin
// The psapi.dll reads the Windows NT performance database. The DLL
// is part of the Win32 SDK. if UseDLL(WINSYSDIR ^ PSAPI_FILE) < then
// Could not load psapi.dll. MessageBox("ERROR: Could not load [" + WINSYSDIR ^ PSAPI_FILE +
"].", SEVERE); return -;
endif; // Get the PIDs of all currently running processes. pvProcessIDs = ArrayToPointer(nvProcessIDs); EnumProcesses(pvProcessIDs, , nvBytesReturned); // Determine the number of process IDs retrieved. Each process ID
// is PROCESSID_LENGTH bytes. nvProcesses = nvBytesReturned / PROCESSID_LENGTH; // Get the executable associated with each process, and check if
// its filename matches the one passed to the function. for nvIndex = to nvProcesses
// Get a handle to the process. The OpenProcess function
// must have full (all) access to be able to terminate
// processes. nvProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION |
PROCESS_ALL_ACCESS, , nvProcessIDs(nvIndex)); if nvProcessHandle != then
// Get a handle to the first module in the process, which
// should be the executable. if EnumProcessModules(nvProcessHandle, nvModuleHandle,
PROCESSID_LENGTH, nvBytesRequired) != then
// Get the path of the module. if GetModuleFileNameExA(nvProcessHandle, nvModuleHandle,
svModuleName, SizeOf(svModuleName)) != then
// Extract the filename (without an extension) from
// the path. ParsePath(svFileName, svModuleName, FILENAME_ONLY); if StrCompare(svFileName, szAppName) = then
// The process module matches the application
// name passed to the function. if TerminateProcess(nvProcessHandle, ) > then
nvReturn++;
endif;
endif;
endif;
endif;
endif;
endfor; if UnUseDLL(PSAPI_FILE) < then
MessageBox("ERROR: Could not unload [" + WINSYSDIR ^ PSAPI_FILE +
"].", SEVERE); return -;
endif; return nvReturn;
end; //////////////////////////////////////////////////////////////////////////////
//
// Function: _Process_Running
//
// Description: Determines if the specified process is running in memory.
//
// Parameters: szAppName - Name of the application to check.
//
// Returns: TRUE - The process is running.
// FALSE - The process is not running.
//
////////////////////////////////////////////////////////////////////////////// function BOOL ProcessRunning(szAppName)
BOOL bvRunning; // Process is running
NUMBER nvProcessIDs(); // Array of process IDs
NUMBER nvBytesReturned; // Number of bytes returned in process ID array
NUMBER nvProcesses; // Number of processes running
NUMBER nvIndex; // Loop index
NUMBER nvProcessHandle; // Handle to a process
NUMBER nvModuleHandle; // Handle to a process module
NUMBER nvBytesRequired; // Number of bytes required to store values
POINTER pvProcessIDs; // Pointer to process ID array
STRING svModuleName; // Module name
STRING svFileName; // Module filename
begin
// The psapi.dll reads the Windows NT performance database. The DLL
// is part of the Win32 SDK. if UseDLL(WINSYSDIR ^ PSAPI_FILE) < then
// Could not load psapi.dll. MessageBox("ERROR: Could not load [" + WINSYSDIR ^ PSAPI_FILE +
"].", SEVERE); return FALSE;
endif; // Get the PIDs of all currently running processes. pvProcessIDs = ArrayToPointer(nvProcessIDs); EnumProcesses(pvProcessIDs, , nvBytesReturned); // Determine the number of process IDs retrieved. Each process ID
// is PROCESSID_LENGTH bytes. nvProcesses = nvBytesReturned / PROCESSID_LENGTH; // Get the executable associated with each process, and check if
// its filename matches the one passed to the function. for nvIndex = to nvProcesses
// Get a handle to the process. nvProcessHandle = OpenProcess(PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ, , nvProcessIDs(nvIndex)); if nvProcessHandle != then
// Get a handle to the first module in the process, which
// should be the executable. if EnumProcessModules(nvProcessHandle, nvModuleHandle,
PROCESSID_LENGTH, nvBytesRequired) != then
// Get the path of the module. if GetModuleFileNameExA(nvProcessHandle, nvModuleHandle,
svModuleName, SizeOf(svModuleName)) != then
// Extract the filename (without an extension) from
// the path. ParsePath(svFileName, svModuleName, FILENAME_ONLY); if StrCompare(svFileName, szAppName) = then
// The process module matches the application
// name passed to the function. bvRunning = TRUE; goto ProcessRunningEnd;
endif;
endif;
endif;
endif;
endfor; ProcessRunningEnd: if UnUseDLL(PSAPI_FILE) < then
MessageBox("ERROR: Could not unload [" + WINSYSDIR ^ PSAPI_FILE +
"].", SEVERE); return FALSE;
endif; return bvRunning;
end;

调用方式如下:

    if ProcessRunning("Frs") then
MessageBox("Application \"Frs\" is running,will been killed ", INFORMATION);
ProcessEnd("Frs");
endif;

InstallShield2015制作安装包----------卸载前结束执行中的进程的更多相关文章

  1. InstallShield2015制作安装包----------卸载后删除安装目录和文件

    卸载程序后,一般是需要将安装目录清除干净.但是,如果程序运行中有文件生成,这时InstallShield自带的卸载程序,不会卸载这些运行时生成的文件. 卸载不干净,可能会对下次程序的安装,和安装后的运 ...

  2. InstallShield2015制作安装包----------安装后实现电脑开机自启动

    开机自启动有两个方法: 一 .把程序的快捷方式放在”开始---启动“目录下. 二.把程序的安装目录放在注册表”“. 实现方法一: 1.编写bat脚本.执行bat启动exe. a)核心:cmd命令  : ...

  3. [Winform]setupfactory制作安装包卸载输入密码进行验证

    摘要 项目有这样一个需求,在体验机上安装了一个软件,如果有用户卸载的时候,给与输入密码验证的提示,当然强制删除软件所在目录除外.那么这个有办法实现吗? 解决办法 在卸载的时候,用户单击下一步的时候进行 ...

  4. InstallShield2015制作安装包----------安装过程中修改文件内容

    //修改安装目录下autostart.vbs里的路径 //打开文件 OpenFileMode(FILE_MODE_NORMAL); strPath=INSTALLDIR+"centerAut ...

  5. InstallShield2015制作安装包----------安装后实现自动运行

    安装向导完成后,自动运行. 实现的手段是:InstallScript脚本OnEnd()函数里面,调用可执行程序. 备注:INSTALLDIR预定义变量存放着程序的安装目录. //安装后运行dispat ...

  6. installshield制作的安装包卸载时提示重启动的原因以及解决办法

    原文:installshield制作的安装包卸载时提示重启动的原因以及解决办法 有时候卸载installshield制作的安装包程序,卸载完会提示是否重启电脑以完成所有卸载,产生这个提示的常见原因有如 ...

  7. 使用VS2015制作安装包( 含相关的下载链接)

    补充: 在看下面的教程过程中,如果在下面的步聚1中没有 " Visual Studio Installer", 则需要通过下面的链接进行安装 Visual Studio Insta ...

  8. 20 Inno Setup制作安装包的几个问题

    系统开发好之后,通常需要制作成安装包,才能卖给用户.利用Inno Setup的向导可以制作简单的安装包,但是如果要做个好的安装包的话可能会遇到一些麻烦,今日终于抽空解决了,Inno Setup打包的一 ...

  9. 为自己编写的windows应用程序制作安装包

    1 写好了一个windows程序之后如何制作安装包 这个在vs中就可以直接发布了,可以制作msi的安装包和exe的安装包. 2 window应用程序安装包做了哪些事情 rpm安装包的话,只是把相应的文 ...

随机推荐

  1. [No0000115]打开Excel2016提示内存或磁盘空间不足的解决方法

    症状: 法一:右键文件,并 解除锁定: 法二: 在系统的服务中查看Windows Firewall服务 和Windows Update服务是否开启,如果没有开启就把他们启动一下. 1.在桌面的[计算机 ...

  2. 进制转换 map

    a_z = [i for i in map(chr, range(ord('a'), ord('z') + 1))]'''Address of var1 variable: 240ff24Addres ...

  3. Microsoft .NET Framework

    Microsoft .NET Framework是用于Windows的新托管代码编程模型.它将强大的功能与新技术结合起来,用于构建具有视觉上引人注目的用户体验的应用程序,实现跨技术边界的无缝通信,并且 ...

  4. PHP之引用

    php数字月份转换为英语缩写 实现数字月份到英文月份缩写的转换 英语 1 => 'Jan', January 2 => 'Feb', February 3 => 'Mar', Mar ...

  5. php之print_r

    stdClass类是PHP的一个内部保留类,初始时没有成员变量也没有成员方法,所有的魔术方法都被 设置为null,可以使用其传递变量参数,但是没有可以调用的方法.stdClass类可以被继承. 只是这 ...

  6. [daily][qemu][libvirt] 使用libvirt管理qemu

    别人创建的虚拟机.用libvirt做的配置. 我一直是手写qemu脚本的,不会用virtsh,所以,学一下. ------------------ 先来个arch的文档: https://wiki.a ...

  7. Python生成器表达式

    https://www.cnblogs.com/liu-shuai/p/6098218.html 简介: 生成器表达式并不真正的创建数字列表,而是返回一个生成器对象,此对象在每次计算出一个条目后,把这 ...

  8. WordCount 的实现与测试

    一.开头 (1)合作者:201631062627,201631062427 (2)代码地址:https://gitee.com/catchcatcat/WordCount.git 二.正文 (1)基本 ...

  9. LeetCode 867 Transpose Matrix 解题报告

    题目要求 Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped ov ...

  10. 20165336 2017-2018-2 《Java程序设计》第1周学习总结

    20165336 2017-2018-2 <Java程序设计>第1周学习总结 教材学习内容总结 Java地位.特点:Java具有面向对象.与平台无关.安全.稳定和多线程等优良特性.Java ...