Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
- Added a new macro in `grant-users-access.nsh` to grant standard users read and execute access to the installation directory, enhancing accessibility for non-admin users. - Updated `installer.nsh` to include the new macro during installation, ensuring proper permissions are set. - Changed the output file from `deeplink.js` to `deeplink.exe` in the build process, improving the executable handling for the application. - Refactored the installer script to ensure the correct command is used for the farmcontrol URI handler, enhancing functionality. - Introduced a new script, `patch-windows-binaries.mjs`, to set the requested execution level for Windows binaries, improving security and compliance.
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { existsSync, readdirSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { rcedit } from 'rcedit'
|
|
|
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
|
|
export async function patchWindowsBinaries(appDir) {
|
|
if (process.platform !== 'win32') {
|
|
return
|
|
}
|
|
|
|
const binDir = path.join(appDir, 'bin')
|
|
if (!existsSync(binDir)) {
|
|
throw new Error(`patch-windows-binaries: bin directory not found at ${binDir}`)
|
|
}
|
|
|
|
const executables = readdirSync(binDir).filter((name) =>
|
|
name.toLowerCase().endsWith('.exe')
|
|
)
|
|
|
|
for (const executable of executables) {
|
|
const executablePath = path.join(binDir, executable)
|
|
await rcedit(executablePath, {
|
|
'requested-execution-level': 'asInvoker'
|
|
})
|
|
console.log(`patch-windows-binaries: set asInvoker on ${executablePath}`)
|
|
}
|
|
}
|
|
|
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
const appDirArg = process.argv[2]
|
|
if (!appDirArg) {
|
|
console.error('Usage: bun scripts/patch-windows-binaries.mjs <app-dir>')
|
|
process.exit(1)
|
|
}
|
|
|
|
await patchWindowsBinaries(path.resolve(appDirArg))
|
|
}
|