Blog Posts by talonsprem87

Ask a question

How to Create Powershell Based Custom Action in MSI/MST

Powershell Script which does the task you want to achieve
machine should have powershell installed on it. Hence these type of custom actions will fail on windows XP

Now Installshield doesnt offer adding a new powershell custom action atleast in the MSI / MST. though this feature is present in the ISM and the same is true for KillProcess custom which comes shipped with Installshield 2013(still working on the turnaround for this custom action and will be covered up in the next blog).

So as one of my friend on this forum suggested , if we wish to execute powershell based custom action we'll have to go via using an EXE based custom action. Hence implementing the same , following are the steps to be followed to add a powershell custom action in your package, then be it MSI/MST

1. Create a directory structure which mimics the location of powershell.exe present on our system which is C:\Windows\System32\WindowsPowerShell\v1.0. (creating directory structure shouldnt be much of a pain for you all)
2. Next Add the PS1 file in your package in a suitable location, preferrably INSTALLDIR (I find it adding in that location more convinient than any other location due to ease of accessing it but the choice of location solely depends on the user.)
3. Next Add custom action of the type 3106 which is EXE stored in a directory table. so the custom action table will now look as follows

Action:StopService(Name of my custom action)


Source:v10(The directory structure i created to mimic the location of pwoershell.exe present on my location)

Target:powershell.exe -file "[INSTALLDIR]ServiceTest.ps1"

Now next step is faily simple which is scheduling the custom action and defining its in script execution .
Cheers you're done. Test the application.

Hope this little tutorial helps you'll. Let me know in case of any issues

View comments (2)

Check process and install

Hello Guys,
from the last few days I have been creating a script to check if a particular process is running and then proceed for installation. Based on some feed back from other mods of ITNINJA, i finally came up with a script



set oshell=createobject("wscript.shell")
strMessage="Close the notepad"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

oreturn=oshell.popup("Do you want to start the installation",0,"Information",&H0 + &H40)

    Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'notepad.exe'")
    If colProcessList.Count>0 Then
    ortn=oshell.popup(strMessage,0,strTitle,&H0 + &H40)
    End If
Loop While colProcessList.Count>0





feel free to play with it as modify as per your needs.
Hope this helps

View comments (1)

Remove From Services

Was in search of a vbscript which would remove line from services file located under C:\windows\system32\drivers\etc and came up with the following script by Tom Riddle


Option Explicit
'On Error Resume Next
Dim strFile, strKey,LineNumber, CheckCase,objshell,winFolder
set objshell=createobject("Wscript.Shell")
strFile=winFolder & "\System32\Drivers\etc\services"

DeleteLine winFolder & "\System32\Drivers\etc\services","<strkey>","0","0"
DeleteLine winFolder & "\System32\Drivers\etc\services","<strkey>","0","0"

Function DeleteLine(strFile, strKey, LineNumber, CheckCase)
 'DeleteLine Function by TomRiddle 2008
 'Remove line(s) containing text (strKey) from text file (strFile)
 'Remove line number from text file (strFile)
 'Remove line number if containing text (strKey) from text file (strFile)
 'Use strFile = "c:\file.txt"   (Full path to text file)
 'Use strKey = "John Doe"       (Lines containing this text string to be deleted)
 'Use strKey = ""               (To not use keyword search)
 'Use LineNumber = "1"          (Enter specific line number to delete)
 'Use LineNumber = "0"          (To ignore line numbers)
 'Use CheckCase = "1"           (For case sensitive search )
 'Use CheckCase = "0"           (To ignore upper/lower case characters)
    Const ForReading=1:Const ForWriting=2
    Dim objFSO,objFile,Count,strLine,strLineCase,strNewFile
    Set objFSO=CreateObject("Scripting.FileSystemObject")
    Set objFile=objFSO.OpenTextFile(strFile,ForReading)
    Do Until objFile.AtEndOfStream
       If CheckCase=0 then strLineCase=ucase(strLine):strKey=ucase(strKey)
       If LineNumber=objFile.Line-1 or LineNumber=0 then
          If instr(strLine,strKey) or instr(strLineCase,strkey) or strKey="" then
          End If
       End If
    Set objFSO=CreateObject("Scripting.FileSystemObject")
    Set objFile=objFSO.OpenTextFile(strFile,ForWriting)
    objFile.Write strNewFile
 End Function




Hope this helps the users

Be the first to comment

Setting Permissions using SetACL

My last post for using cacls for providing permissions seems to be not working well for applying permissions on folders under program files, so i have modified the script a bit and used SetACL to give permissions . Following is the script to give permissions. I m also adding script to apply permissions on registry. Do let me know if you face any issues.


Option Explicit
'On Error Resume Next
Dim Objshell,ObjFSO,Setpath,DestPath,SetExe1,SetExe2,ProFiles
set objshell=createobject("Wscript.shell")
set objFSO=createobject("Scripting.FileSystemObject")
setpath=proFiles & "\Test\SetACL.exe"
DestPath=proFiles & "\<Enter the folder name to give permission to >"
setexe1=chr(34) & setPath & chr(34) & " -on " & chr(34) & DestPath & chr(34) & " -ot file -actn ace -ace " & chr(34) & "n:domain1\user1;p:full" & chr(34)
setexe2=chr(34) & setPath & chr(34) & " -on " & chr(34) & "hklm\software\microsoft\policies" & chr(34) & " -ot reg -actn ace -ace " & chr(34) & "n:domain1\user1;p:full" & chr(34)
objshell.run setexe1

Be the first to comment

Adding/removing entry to/from IIS Manager

Hello Folks,

Today i would share with you script to convert a virtual application to web application in IIS manager. This was a bit headache, since i had to try hell lot of things before narrowing down to script. Anyways, following are the two scripts

For Adding entry to IIS

Option Explicit

On Error Resume Next

dim objshell,win, AppCMD, strc

set Objshell=CreateObject("Wscript.Shell")

win = Objshell.ExpandEnvironmentStrings("%WINDIR%")

AppCMD=Win & "\system32\inetsrv\appcmd.exe"   'appcmd converts your virtual apps to web in IIS manager


'======================register the app in IIS==============================================


strc = chr(34) & appcmd & chr(34) & " add app /site.name:" & chr(34) & "Default Web Site" & chr(34) & " /path:" & chr(34) & "/<Name of the application>" &chr(34) & " /physicalPath:" & chr(34) & "C:\inetpub\wwwroot\<Name of application>" & chr(34)

objshell.Run StrC,0,TRUE

Set ObjShell=Nothing


For removing entry from IIS manager

Option Explicit

On Error Resume Next

dim objshell,win, AppCMD, strc

set Objshell=CreateObject("Wscript.Shell")

win = Objshell.ExpandEnvironmentStrings("%WINDIR%")

AppCMD=Win & "\system32\inetsrv\appcmd.exe"


'======================remove the app in IIS==============================================


strc = chr(34) & appcmd & chr(34) & " delete app /app.name:" & chr(34) & "Default Web Site" & "/<Name of application>" & chr(34)

objshell.Run StrC,0,TRUE


Set objshell=Nothing

Hop you guys find it useful. Cheers

Be the first to comment
Showing 1 - 5 of 15 results

Top Contributors

Talk About Windows Installer (MSI) Custom Actions