mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Merge e3dbe294f2 into 4d0abeb37c
This commit is contained in:
commit
3644b8a234
6 changed files with 87 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -38,4 +38,7 @@ v2/cmd/wails/internal/commands/initialise/templates/testtemplates/
|
|||
/v3/examples/plugins/bin/testapp
|
||||
|
||||
# Temporary called mkdocs, should be renamed to more standard -website or similar
|
||||
/docs/site
|
||||
.aider*
|
||||
/.claude/
|
||||
/mkdocs-website/site
|
||||
|
|
|
|||
|
|
@ -230,6 +230,11 @@ type Info struct {
|
|||
Comments *string `json:"comments"`
|
||||
FileAssociations []FileAssociation `json:"fileAssociations"`
|
||||
Protocols []Protocol `json:"protocols"`
|
||||
Windows *WindowsInfo `json:"windows,omitempty"`
|
||||
}
|
||||
|
||||
type WindowsInfo struct {
|
||||
ExecutionLevel string `json:"executionLevel,omitempty"`
|
||||
}
|
||||
|
||||
type FileAssociation struct {
|
||||
|
|
|
|||
|
|
@ -12,4 +12,13 @@
|
|||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
{{- if .ExecutionLevel}}
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="{{.ExecutionLevel}}" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
{{- end}}
|
||||
</assembly>
|
||||
|
|
@ -105,6 +105,7 @@ type assetData struct {
|
|||
Name string
|
||||
Info project.Info
|
||||
OutputFilename string
|
||||
ExecutionLevel string
|
||||
}
|
||||
|
||||
func resolveProjectData(content []byte, projectData *project.Project) ([]byte, error) {
|
||||
|
|
@ -113,10 +114,17 @@ func resolveProjectData(content []byte, projectData *project.Project) ([]byte, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Extract Windows execution level if specified
|
||||
executionLevel := ""
|
||||
if projectData.Info.Windows != nil && projectData.Info.Windows.ExecutionLevel != "" {
|
||||
executionLevel = projectData.Info.Windows.ExecutionLevel
|
||||
}
|
||||
|
||||
data := &assetData{
|
||||
Name: projectData.Name,
|
||||
Info: projectData.Info,
|
||||
OutputFilename: projectData.OutputFilename,
|
||||
ExecutionLevel: executionLevel,
|
||||
}
|
||||
|
||||
var out bytes.Buffer
|
||||
|
|
|
|||
|
|
@ -75,3 +75,59 @@ cmd.Start()
|
|||
|
||||
Solution provided by [sithembiso](https://github.com/sithembiso) on the
|
||||
[discussions board](https://github.com/wailsapp/wails/discussions/1734#discussioncomment-3386172).
|
||||
|
||||
## UAC Execution Level
|
||||
|
||||
Windows applications can request specific User Account Control (UAC) execution levels through the application manifest. Wails supports configuring UAC execution levels that will persist when your application is distributed to other machines.
|
||||
|
||||
### Configuring Execution Level
|
||||
|
||||
You can configure the UAC execution level in your `wails.json` project configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"info": {
|
||||
"companyName": "My Company",
|
||||
"productName": "My App",
|
||||
"productVersion": "1.0.0",
|
||||
"windows": {
|
||||
"executionLevel": "requireAdministrator"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Supported Execution Levels
|
||||
|
||||
| Level | Description |
|
||||
|-------|-------------|
|
||||
| `requireAdministrator` | The application requires administrator privileges and will prompt for elevation |
|
||||
| `highestAvailable` | The application runs with the highest privileges available to the user |
|
||||
| `asInvoker` | The application runs with the same privileges as the calling process (default behavior) |
|
||||
|
||||
### Example: Admin-Required Application
|
||||
|
||||
For applications that need administrator privileges (e.g., system utilities, installers):
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "SystemTool",
|
||||
"info": {
|
||||
"companyName": "My Company",
|
||||
"productName": "System Administration Tool",
|
||||
"productVersion": "1.0.0",
|
||||
"windows": {
|
||||
"executionLevel": "requireAdministrator"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When built, this application will:
|
||||
- Display a UAC prompt when launched on Windows
|
||||
- Request administrator privileges before starting
|
||||
- Persist this behavior when copied to other machines
|
||||
|
||||
### Backward Compatibility
|
||||
|
||||
If no `executionLevel` is specified, no UAC requirements are added to the manifest, maintaining the default Windows behavior where applications run with the same privileges as the launching process.
|
||||
|
|
|
|||
|
|
@ -103,7 +103,12 @@ The project config resides in the `wails.json` file in the project directory. Th
|
|||
// macOS-only. The app’s role with respect to the type. Corresponds to CFBundleTypeRole.
|
||||
"role": "Editor"
|
||||
}
|
||||
]
|
||||
],
|
||||
// Windows-specific configuration
|
||||
"windows": {
|
||||
// UAC execution level for Windows applications. Valid values: "requireAdministrator", "highestAvailable", "asInvoker"
|
||||
"executionLevel": ""
|
||||
}
|
||||
},
|
||||
// 'multiple': One installer per architecture. 'single': Single universal installer for all architectures being built. Default: 'multiple'
|
||||
"nsisType": "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue