Click here to Skip to main content
15,943,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to run powershell script through this installer I have inserted this one in wxs file powershell get open but command not get executed installer terminates after this

<CustomAction Id="ExecPortOpen" Directory="INSTALLFOLDER" Execute="commit" Impersonate="no" ExeCommand="cmd.exe /c "wsl --install "" Return="check" />
		<InstallExecuteSequence>
	    <Custom Action="ExecPortOpen" After="InstallInitialize" />
		</InstallExecuteSequence>


What I have tried:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"><?define MywpfApplication_TargetDir=$(var.MywpfApplication.TargetDir)?>
	<Product Id="3b53f344-8e08-45bf-a9a2-d04c5ee8bd77" Name="My wpf Application" Language="1033" Version="1.0.0.0" Manufacturer="ncircleTech" UpgradeCode="54d02ebf-3526-41ec-bd29-932bd6a21c59">
		<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
		

		

		<Icon Id="icon.ico" SourceFile="$(var.ProjectDir)Icon.ico" />
		<Property Id="ARPPRODUCTICON" Value="icon.ico" />

		<WixVariable Id="WixUIBannerBmp" Value="Images\installer_top-banner.bmp" />
		<WixVariable Id="WixUIDialogBmp" Value="Images\installer_background.bmp" />
		<WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\License.rtf" />
		
		<CustomAction Id="ExecPortOpen" Directory="INSTALLFOLDER" Execute="commit" Impersonate="no" ExeCommand="cmd.exe /c "wsl --install "" Return="check" />
		<InstallExecuteSequence>
	    <Custom Action="ExecPortOpen" After="InstallInitialize" />
		</InstallExecuteSequence>
		
	

		<UIRef Id="WixUI_Minimal"/>
		
		

		<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
		<MediaTemplate EmbedCab="yes"/>

		<Feature Id="ProductFeature" Title="My wpf Application" Level="1">
			<ComponentGroupRef Id="ProductComponents" />
			<ComponentRef Id="ApplicationShortcut" />
			<ComponentRef Id="ApplicationShortcutDesktop" />

		</Feature>
	</Product>

	<Fragment>
		<Directory Id="TARGETDIR" Name="SourceDir">
			<Directory Id="ProgramFilesFolder">
				<Directory Id="INSTALLFOLDER" Name="My wpf Application" />
			</Directory>
			<Directory Id="ProgramMenuFolder">
				<Directory Id="ApplicationProgramsFolder" Name="MyWpfApplication" />
			</Directory>
			<Directory Id="DesktopFolder" Name="Desktop" />
		</Directory>
	</Fragment>
	<Fragment>
		<DirectoryRef Id="ApplicationProgramsFolder">
			<Component Id="ApplicationShortcut" Guid="9bd13330-6540-406f-a3a8-d7f7c69ae7f9">
				<Shortcut Id="ApplicationStartMenuShortcut" Name="MyWpfApplication" Description="MyWpfApplication" Target="[INSTALLFOLDER]MyWpfApplication.exe" WorkingDirectory="INSTALLFOLDER" />
				<RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
				<RegistryValue Root="HKCU" Key="Software\MyWpfApplication" Name="installed" Type="integer" Value="1" KeyPath="yes" />
			</Component>
		</DirectoryRef>
		<DirectoryRef Id="DesktopFolder">
			<Component Id="ApplicationShortcutDesktop" Guid="cde1e030-eb64-49a5-b7b8-400b379c2d1a">
				<Shortcut Id="ApplicationDesktopShortcut" Name="MyWpfApplication" Description="MyWpfApplication" Target="[INSTALLFOLDER]MyWpfApplication.exe" WorkingDirectory="INSTALLFOLDER" />
				<RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
				<RegistryValue Root="HKCU" Key="Software\MyWpfApplication" Name="installed" Type="integer" Value="1" KeyPath="yes" />
			</Component>
		</DirectoryRef>
	</Fragment>
	

	<Fragment>
		<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
			
			<Component Id="MywpfApplication.runtimeconfig.json" Guid="9ea3f616-466a-4671-8ea9-086a9136e26f">
			  <File Id="MywpfApplication.runtimeconfig.json" Name="MywpfApplication.runtimeconfig.json" Source="$(var.MywpfApplication_TargetDir)MywpfApplication.runtimeconfig.json" />
			</Component>
			<Component Id="MywpfApplication.dll" Guid="213e1d12-4cce-4b8f-a1b6-6ba77615df76">
			  <File Id="MywpfApplication.dll" Name="MywpfApplication.dll" Source="$(var.MywpfApplication_TargetDir)MywpfApplication.dll" />
			</Component>
		</ComponentGroup>
	</Fragment>

</Wix>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900