久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在電子應用程序中獲取持久權限?

How can I take persistent permissions in electron app?(如何在電子應用程序中獲取持久權限?)
本文介紹了如何在電子應用程序中獲取持久權限?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在創建一個電子應用程序,我需要在其中掃描和更新需要 root 權限的文件.我知道我可以以這種方式使用 sudo.exec() 運行此類命令:

I am creating an electron app where I need to scan and update files which need root permission. I know I can run such commands using sudo.exec() in that way:

sudo.exec ("rm /private/var/log/fsck_hfs.log", options, (e, stdout, stderr) => {});

甚至我可以在一個腳本中放入多個命令并使用單個 sudo.exec() 執行它們.就我而言,命令需要在不同的時間點執行,我無法使用單個腳本執行它們.用戶一次又一次地授予權限很煩人.

And even I can put multiple commands in a script and execute them with single sudo.exec(). In my case, commands needs to be executed at different point of time and I cannot execute them with a single script. It is annoying for user to grant permissions again and again.

我嘗試了另一種方式(運行一段代碼,可以執行所有需要 root 權限的內容).為此,我在這里發布了另一個問題.但似乎不可能.

I tried to do it another way (to run a piece of code where everything that require root permission can be executed). For that, I posted another question here. But it seems that it is not possible.

現在我想要一種在使用安裝應用程序時獲得許可的方法(就像大多數應用程序在用戶安裝它們之后所做的那樣)并且能夠在整個應用程序中使用 sudo.exec() 或其他一些方法來執行命令(最好還有需要root權限的代碼fs.readdir等).

Now I want a way to get permission once when use install app (as most of the apps does after user install them) and be able to use throughout the app sudo.exec() or some other method to execute commands (preferably also the code fs.readdir, etc) that require root permission.

推薦答案

您需要以管理員權限運行應用程序.如果您使用 electron builder 構建應用程序,請使用 requestedExecutionLevel 值作為requireAdministrator"

You need to run the applicaton with administrator privilege. If you are using electron builder to build the app, use the requestedExecutionLevel value as "requireAdministrator"

https://www.electron.build/configuration/win

這篇關于如何在電子應用程序中獲取持久權限?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 免费观看黄网站 | 欧美日韩综合 | 久久综合激情 | 日本高清视频网站 | 精品视频一区二区 | 日日夜夜天天久久 | 特一级毛片 | 99re在线视频免费观看 | 精品国产青草久久久久96 | 日本欧美在线 | 国产激情一区二区三区 | 青青久视频| 精品国产乱码久久久久久果冻传媒 | 中文字幕第十五页 | 欧美一区二区三区一在线观看 | 一级做受毛片免费大片 | 日韩在线一区二区三区 | 欧美黄色片在线观看 | 亚洲一区久久 | 99精品网站 | 日本精品网站 | 91精品国产91 | 红桃视频一区二区三区免费 | 全部免费毛片在线播放网站 | 人妖一区 | 精品国产精品 | 日韩在线91| 国产精品一区二区福利视频 | 97超碰在线免费 | 亚洲视频免费在线观看 | 精品视频99 | 国产精品一区一区三区 | 国产精品中文字幕在线 | 夜色www国产精品资源站 | 久久久久久国产 | 国产精品久久久久久久久久不蜜臀 | 羞羞的视频免费观看 | 免费看黄色国产 | 日本一区二区高清不卡 | 爱爱小视频| 精品久久久一区 |