Skip to content

Commit 91f4746

Browse files
CopilotIEvangelist
andcommitted
Add Account attribute to ServiceInstall and fix directory structure
Co-authored-by: IEvangelist <[email protected]>
1 parent e113a06 commit 91f4746

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

docs/core/extensions/snippets/workers/windows-service-setup/App.WindowsService.Setup/Package.wxs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
DisplayName="$(Name)"
5353
Description="A joke service that periodically logs nerdy humor."
5454
Start="auto"
55+
Account="LocalService"
5556
ErrorControl="normal" />
5657

5758
<!-- Tell WiX to start the Service -->

docs/core/extensions/windows-service-with-installer.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,17 @@ After the project reference has been added, configure the _Package.wxs_ file. Op
186186
<MajorUpgrade DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
187187

188188
<!-- Define the directory structure -->
189-
<StandardDirectory Id="ProgramFiles64Folder">
189+
<Directory Id="TARGETDIR" Name="SourceDir">
190+
<Directory Id="ProgramFilesFolder">
190191

191-
<!-- Create a folder inside program files -->
192-
<Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
192+
<!-- Create a folder inside program files -->
193+
<Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
193194

194-
<!-- Create a folder within the parent folder given the name -->
195-
<Directory Id="INSTALLFOLDER" Name="$(Name)" />
195+
<!-- Create a folder within the parent folder given the name -->
196+
<Directory Id="INSTALLFOLDER" Name="$(Name)" />
197+
</Directory>
196198
</Directory>
197-
</StandardDirectory>
199+
</Directory>
198200

199201
<!-- The files inside this DirectoryRef are linked to
200202
the App.WindowsService directory via INSTALLFOLDER -->
@@ -219,6 +221,7 @@ After the project reference has been added, configure the _Package.wxs_ file. Op
219221
DisplayName="$(Name)"
220222
Description="A joke service that periodically logs nerdy humor."
221223
Start="auto"
224+
Account="LocalService"
222225
ErrorControl="normal" />
223226

224227
<!-- Tell WiX to start the Service -->
@@ -240,6 +243,12 @@ After the project reference has been added, configure the _Package.wxs_ file. Op
240243
</Wix>
241244
```
242245

246+
The `ServiceInstall` element's `Account` attribute specifies the account under which the service runs. The `LocalService` account is a built-in account with reduced privileges that's appropriate for most services. Other common values include:
247+
248+
- `LocalService`: A built-in account with reduced privileges and no network credentials.
249+
- `NetworkService`: Similar to LocalService but has network credentials.
250+
- `LocalSystem`: The highest privilege level (use with caution).
251+
243252
When you build the project, the output is an MSI file that can be used to install and uninstall the service.
244253

245254
# [Microsoft installer extension](#tab/ext)

0 commit comments

Comments
 (0)