rustdesk 2021-06-14 17:51:45 +08:00
parent a2890fa548
commit 673986d045
4 changed files with 55 additions and 14 deletions

View File

@ -1037,3 +1037,33 @@ pub fn get_installed_version() -> String {
}
"".to_owned()
}
pub fn create_shortcut(id: &str) -> ResultType<()> {
let exe = std::env::current_exe()?.to_str().unwrap_or("").to_owned();
let shortcut = write_cmds(
format!(
"
Set oWS = WScript.CreateObject(\"WScript.Shell\")
strDesktop = oWS.SpecialFolders(\"Desktop\")
Set objFSO = CreateObject(\"Scripting.FileSystemObject\")
sLinkFile = objFSO.BuildPath(strDesktop, \"{id}.lnk\")
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = \"{exe}\"
oLink.Arguments = \"--connect {id}\"
oLink.Save
",
exe = exe,
id = id,
),
"vbs",
)?
.to_str()
.unwrap_or("")
.to_owned();
std::process::Command::new("cscript")
.arg(&shortcut)
.output()?;
allow_err!(std::fs::remove_file(shortcut));
Ok(())
}

View File

@ -486,6 +486,11 @@ impl UI {
format!("{}.{}", p.to_string_lossy(), self.get_software_ext())
}
fn create_shortcut(&self, id: String) {
#[cfg(windows)]
crate::platform::windows::create_shortcut(&id).ok();
}
fn open_url(&self, url: String) {
#[cfg(windows)]
let p = "explorer";
@ -541,6 +546,7 @@ impl sciter::EventHandler for UI {
fn get_software_store_path();
fn get_software_ext();
fn open_url(String);
fn create_shortcut(String);
}
}

View File

@ -9,22 +9,9 @@
include "common.tis";
include "index.tis";
</script>
<popup>
<menu.context #remote-context>
<li #connect>Connect</li>
<li #transfer>Transfer File</li>
<li #tunnel>TCP Tunneling</li>
<li #rdp>RDP</li>
<li #remove>Remove</li>
</menu>
</popup>
<popup><menu.context #edit-password-context>
<li #refresh-password>Refresh random password</li>
<li #set-password>Set your own password</li>
</menu></popup>
</head>
<body>
</body>
</html>
</html>

View File

@ -103,6 +103,8 @@ event click $(menu#remote-context li) (evt, me) {
} else if (action == "remove") {
handler.remove_peer(id);
app.recent_sessions.update();
} else if (action == "shortcut") {
handler.create_shortcut(id);
} else if (action == "rdp") {
createNewConnect(id, "rdp");
} else if (action == "tunnel") {
@ -310,6 +312,22 @@ class App: Reactor.Component
var is_can_screen_recording = handler.is_can_screen_recording(false);
return
<div .app>
<popup>
<menu.context #remote-context>
<li #connect>Connect</li>
<li #transfer>Transfer File</li>
<li #tunnel>TCP Tunneling</li>
<li #rdp>RDP</li>
<li #remove>Remove</li>
{is_win && <li #shortcut>Create Desktop Shortcut</li>}
</menu>
</popup>
<popup>
<menu.context #edit-password-context>
<li #refresh-password>Refresh random password</li>
<li #set-password>Set your own password</li>
</menu>
</popup>
<div .left-pane>
<div>
<div .title>Your Desktop</div>