bat脚本实例实现只允许运行一个实例(安装程序、创建快捷方式脚本)
;我的第一个安装脚本
!include "mui2.nsh"
!define dir "d:\workspace\nsis\files"
name "安装程序"
icon "${dir}\setup128.ico"
outfile "setup.exe"
installdir "$programfiles\kaserv"
requestexecutionlevel admin
!insertmacro mui_page_directory
!insertmacro mui_page_instfiles
!insertmacro mui_language "simpchinese"
function .oninit
system::call 'kernel32::createmutexa(i 0,i 0,t "smaple_mutex") i .r1 ?e'
pop $r0
strcmp $r0 0 +3
messagebox mb_ok|mb_iconstop "只允许运行一个实例"
abort
functionend
;安装程序段
section
setoutpath $instdir
file "${dir}\新建文本文档 (2).txt"
file "${dir}\新建文本文档.txt"
setoutpath "$instdir\office"
file "${dir}\office\*"
;快捷方式
createshortcut "$desktop\test.lnk" "$instdir\unsetup.exe"
createshortcut "$smprograms\test.lnk" "$instdir\unsetup.exe"
writeuninstaller "$instdir\unsetup.exe"
sectionend
;卸载程序段
section "uninstall"
rmdir /r "$instdir"
delete "$desktop\test.lnk"
delete "$smprograms\test.lnk"
sectionend
上一篇: dos 文件删除 del命令