Ming
Ming

Reputation: 525

How to make a self-extracting package that can run a batch script as admin after the extracting?

I want to create a self-extracting package that contains following files and run the install.bat script as admin after extracting the files into c:\temp. And the package can be run silently.

I already tried the IExpress,but I have to run the package(exe) as admin for the install.bat to work.

I also like to use wix, but that will make package a installer and leave a application record in the system registry.

Is there any other tool I can use to create it?

files:

AmazonWorkSpaces.msi

certmgr.exe

install.bat

baltimore.cer

Script "install.bat":

@echo ON

REM The following is required in all INSTALL.CMD files
Call c:\system.sav\util\SetVariables.cmd
Set block=%~dp0
CD /D "%block%"

@ECHO OFF
SETLOCAL
Set block=%~dp0
CD /D "%block%"

CertMgr.exe -add baltimore.cer -c -s -r localMachine root

start /wait msiexec.exe /i AmazonWorkSpaces.msi /qn ALLUSERS="1"


REM add exclusions for UWF=====================================================

if exist c:\windows\system32\UWFMgr.exe (

UWFMgr.exe file add-exclusion "C:\Program Files\Amazon Web Services, Inc" 
UWFMgr.exe registry add-exclusion HKLM\SOFTWARE\Policies\Microsoft\SystemCertificates 
UWFMgr.exe registry add-exclusion HKLM\SOFTWARE\Microsoft\SystemCertificates 
UWFMgr.exe file add-exclusion "C:\Users\admin\AppData\Local\Amazon Web Services\Amazon WorkSpaces" 
UWFMgr.exe file add-exclusion "C:\Users\admin\AppData\Roaming\Amazon" 
UWFMgr.exe file add-exclusion "C:\Users\user\AppData\Local\Amazon Web Services\Amazon WorkSpaces" 
UWFMgr.exe file add-exclusion "C:\Users\user\AppData\Roaming\Amazon" 

)

rem ===============================================
rem remove TEMP folder after installation completed
rem rd c:\temp /S /Q
rem rd c:\temp\src /S /Q

del /F /Q C:\Users\Public\Desktop\Amazon WorkSpaces.lnk


ENDLOCAL

Upvotes: 0

Views: 232

Answers (1)

Ming
Ming

Reputation: 525

Here is the template xml to create a wix installer to extract the files to temp folder and run a script. https://gist.github.com/ivanyankulov/605fc5492bb09d2a197efdfe988afcb9

Upvotes: 0

Related Questions