I write a flutter windows app, I want to launch a golang service when flutter app start on windows, and how run flutter app on windows with admininstrator rights?
CodePudding user response:
I set the trustInfo security in runner.exe.mainifest file to get administator rights,
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</windowsSettings>
</application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
there are same errors when link;
Launching lib\main.dart on Windows in debug mode...
Building Windows application...
LINK : fatal error LNK1327: 运行 mt.exe 期间出错 [D:\hosec\IPSec VPN Client\Windows\ipsec-windows-client-front\build\windows\runner\ipsec_windows_client_front.vcxproj]
Exception: Build process failed.
I think there are two way to get administrator rights, one is setting in manifest like above description, the other is setting in CmakeLists.txt,
SET_TARGET_PROPERTIES(PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")
but second way not get the administrator rights when launch flutter windows app.
CodePudding user response:
setting CmakeLists.txt in runner directory with below:
SET_TARGET_PROPERTIES(${BINARY_NAME} PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\" /SUBSYSTEM:WINDOWS")