1. 如何把EXE嵌入到網頁中運行
讓EXE嵌入網頁中運行,參考代碼如下:
<script>
function exec (command) {
window.oldOnError = window.onerror;
window._command = command;
window.onerror = function (err) {
if (err.indexOf('utomation') != -1) {
alert('請更改你的IE的安全級別:開始->設置->控制面板->Internet選項->安全->自定義級別->對沒有標記為安全的ActiveX控制項進行初始化和腳本運行->啟用');
return true;
}
else return false;
};
var wsh = new ActiveXObject('WScript.Shell');
if (wsh)
wsh.Run(command);
window.onerror = window.oldOnError;
}
</script>
<input type="button" value="Click" onClick="exec('explorer.exe')">
wenjian(文件名稱) :
<html>
<body>
<SCRIPT language="JavaScript">
function Run(strPath) {
exe.value=strPath;
try {
var objShell = new ActiveXObject("wscript.shell");
objShell.Run(strPath);
objShell = null;
}
catch (e){alert('找不到文件"'+strPath+'"(或它的組件之一)。請確定路徑和文件名是否正確,而且所需的庫文件均可用。')
}
}
</SCRIPT>
請輸入要運行的程序:<br/><input name=exe type=text size=20
value="regedit"><BUTTON class=button
onclick="Run(exe.value)">確定</BUTTON><BUTTON class=button
onclick=exe.value="";>重新輸入</BUTTON><br/>
<BUTTON class=button onclick="Run('notepad')">網站上任意連接</BUTTON><br/>
<BUTTON class=button onclick="Run('cmd')">cmd</BUTTON><br/>
<BUTTON class=button onclick="Run('Regedit')">Regedit</BUTTON><br/>
<BUTTON class=button onclick="Run('Msconfig')">Msconfig</BUTTON><br/>
<BUTTON class=button onclick="Run('file:///這里放上EXE文件路徑/文件名稱.EXE')">文件名稱</BUTTON><br/>
<BUTTON class=button onclick="Run('IEXPLORE.EXE')">IE</BUTTON><br/>
<BUTTON class=button onclick="Run('..')">..</BUTTON><br/>
<BUTTON class=button onclick="Run('%windir%')">%windir%</BUTTON><br/>
<BUTTON class=button onclick="Run('%temp%')">%temp%</BUTTON><br/>
</body>
</html>
2. 怎麼把整個java web 程序打包成一個exe文件,包括tomcat和mysql也一同安裝怎麼做或者用什麼工具,謝了
你封裝成exe又怎樣?
安裝完tomcat你還是需要配置的。
3. 如何將WEB頁面放入EXE文件中
你要是用.NET 做的winform的話
可以用 webbrowser 控制項
在窗體上放一個webbrowser控制項 然後設置該控制項的url是你的網站的地址
4. 如何將自己寫好的exe程序部署到自己的網站上,並通過網路調用它
1. 你這方法完全是不正確的,安全性很差;
2. 通過JS調用EXE是可以的,這要降低瀏覽器的安全等級(ACTIVE),不建議;
3. 你完全可以寫一程序監控一個資料庫表裡面一個數值,例如RUNID=1,運行EXE,RUNID=0關閉EXE,當然也可以運行一次自動退出。
4. 這樣,你的WEB頁面就好寫了,操作資料庫嘛,容易,加密傳送即可,還多點隱藏ID。
5. 簡單吧。
5. 如何實現web前端頁面生成exe可執行文件
1、你已經安裝並配置好了 node.js (全局安裝)
2、你已經用 npm 安裝了 electron (全局安裝)
3、你已經寫好了前端網頁(html、css、javascript 這些,或者基於這些的前端框架寫好的網頁)
4、以上三點看不懂的,趕緊去網路。。。
你如果具備了以上的假設,請繼續往下看:
1、找到你的前端網頁項目文件夾,新建 package.json、main.js、index.html 三個文件(註:其中的 index.html 是你的網頁首頁)
你的項目目錄/
├── package.json ├── main.js └── index.html
2、在 package.json 中添加如下內容
{ "name" : "app-name", "version" : "0.1.0", "main" : "main.js" }
3、在 main.js 中添加下面的內容,這個 main.js 文件就是上面 package.json 中的 "main"鍵 的值,所以可根據需要修改
const {app, BrowserWindow} = require('electron') const path = require('path') const url = require('url') // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let win function createWindow () { // Create the browser window. win = new BrowserWindow({width: 800, height: 600}) // and load the index.html of the app. win.loadURL(url.format({ pathname: path.join(__dirname, 'index.html'), protocol: 'file:', slashes: true })) // Open the DevTools. // win.webContents.openDevTools() // Emitted when the window is closed. win.on('closed', () => { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. win = null }) } // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.on('ready', createWindow) // Quit when all windows are closed. app.on('window-all-closed', () => { // On macOS it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform !== 'darwin') { app.quit() } }) app.on('activate', () => { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (win === null) { createWindow() } }) // In this file you can include the rest of your app's specific main process // code. You can also put them in separate files and require them here.
4、如果你的網頁首頁的文件名不是 「index.html」,那麼請在 main.js 中將其中的 'index.html' 修改為你的網頁首頁名
5、打開 DOS,cd 到你的項目目錄(或直接在你的項目目錄下空白的地方 shift+滑鼠右鍵,然後點擊在此處打開命令窗口,這里看不懂的,唉,網路吧少年)
6、在上一步的 DOS 下,輸入 npm install electron-packager -g全局安裝我們的打包神器
npm install electron-packager -g
7、安裝好打包神器後,還是在上一步的 DOS 下,輸入 electron-packager . app --win --out presenterTool --arch=x64 --version 1.4.14 --overwrite --ignore=node_moles 即可開始打包
electron-packager . app --win --out presenterTool --arch=x64 --version 1.4.14 --overwrite --ignore=node_moles
這個命令什麼意思?藍色部分可自行修改:
electron-packager . 可執行文件的文件名 --win --out 打包成的文件夾名 --arch=x64位還是32位 --version版本號 --overwrite --ignore=node_moles
8、打包成功後,會生成一個新的文件夾,點進去,找到 exe 文件,雙擊就可以看到網頁變成了一個桌面應用啦!
以上是最簡單的打包方式,至於怎麼修改窗口大小、菜單欄怎麼加、怎麼調用系統API這些,就給你慢慢去研究Electron了。
6. 前後端分離的web項目怎麼導成.exe文件
exe是windows可執行程序,前後端分離的前端項目如果想做成桌面程序,可以考慮使用Electron.js框架做成PC端,後端一般不會生成exe代碼,如果要一鍵部署可以使DOS腳本或者使用編程語言封裝DOS腳本生成exe文件