方法一: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. Linux svn服务器搭建

    一.安装 yum -y install subversion 二.建立版本库目录 mkdir /var/svn/svnrepos 三.创建svn版本库 svnadmin create /var/svn ...

  2. 洛谷P1966 火柴排队 贪心+离散化+逆序对(待补充QAQ

    正解: 贪心+离散化+逆序对 解题报告: 链接在这儿呢quq 这题其实主要难在想方法吧我觉得?学长提点了下说用贪心之后就大概明白了,感觉没有很难 但是离散化这里还是挺有趣的,因为并不是能很熟练地掌握离 ...

  3. Java体系基本概念

    JVM:Java虚拟机 JRE:(Java Runtime Environment)Java程序允许,测试,传输应用程序的环境和平台 包括 jvm ,java 核心类库和支持的文件,但不包含开发工具J ...

  4. NOIP国王游戏

    #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #inc ...

  5. Log4j与Logback

    一.Log4j简介: 1.Log4j(log for java) 01.是apache的一个开源项目 02.是使用java语言编写的一个日志框架 03.用于记录程序中的日志信息 04.可以将日志信息输 ...

  6. Verilog如何从外部更改模块内参数

    例如有一个模块 module x(a,b,c); input a,b; output c; 'd0, h=9'd3; ...... endmodule 两种解决方法: 1.使用带有参数值的模块实例语句 ...

  7. Linux ethtool 命令

    ethtool 是用于查询及设置网卡参数的命令,常见用法如下: 注意:该命令只是临时设置,如果网卡重启就失效了,如果想要永久保存应该配置 /etc/sysconfig/network-scripts/ ...

  8. linux 查看磁盘读写:iotop

    iotop命令用来动态地查看磁盘IO情况,用法如下: 安装iotop命令 [root@mysql ~]# yum install iotop -y [root@mysql ~]# iotop Tota ...

  9. python 合并列表 从大到小排序

    #!/usr/bin/env python # -*- coding: utf-8 -*- a = [1,2,3,4,5] b = [6,7,8,9,10] a.extend(b) a.reverse ...

  10. Linux下高并发socket最大连接数各种限制的调优

    1.修改用户进程可打开文件数限制 在Linux平台上,无论编写客户端程序还是服务端程序,在进行高并发TCP连接处理时,最高的并发数量都要受到系统对用户单一进程同时可打开文件数量的限制(这是因为系统为每 ...