Share internet no problem its easy create with rust GUI hotspots windows 10

Creating a hotspot in Windows using a Rust GUI involves several steps, including setting up a GUI framework, leveraging system commands to manage the hotspot settings, and error handling. Below is a general approach to accomplish this task using Rust, specifically utilizing the tauri framework for the GUI and some WinAPI or Command Prompt commands for hotspot management.

Step 1: Set Up Your Rust Environment

  1. Install Rust - Follow the instructions at Rust's official site.
  2. Install Tauri - Tauri is a framework for building desktop applications powered by Rust. You can set it up by following the guide here.

Step 2: Create a New Tauri Project

Run the following commands to create a new Tauri project:

cargo new hotspot_gui --bin
cd hotspot_gui
cargo tauri init

Step 3: Implement Hotspot Functionality

You will be using system commands to create and manage the hotspot. Here is a simplified example of how to set up the GUI and call these commands.

  1. Add Dependencies: In Cargo.toml, make sure you have dependencies for Tauri.
[dependencies]
tauri = "1.0"
  1. Create a Basic GUI: Edit src-tauri/src/main.rs to set up the GUI for your hotspot. For example, you might add text fields for SSID and password, and a button to create the hotspot.
use tauri::command;

#[command]
fn create_hotspot(ssid: String, password: String) -> Result<String, String> {
    let command = format!("netsh wlan set hostednetwork mode=allow ssid={} key={}", ssid, password);
    
    // Execute the command (this part may require additional handling, e.g., checking command success)
    let output = std::process::Command::new("cmd")
        .args(&["/C", &command])
        .output()
        .map_err(|e| e.to_string())?;
    
    if output.status.success() {
        Ok("Hotspot created successfully.".into())
    } else {
        let error_message = String::from_utf8_lossy(&output.stderr);
        Err(error_message.into())
    }
}
  1. Handle the GUI Logic: Modify the src-tauri/src/main.rs to handle the Tauri commands and set up the app window.
fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![create_hotspot])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
  1. Update the Frontend: In your src-tauri/../src, create your HTML and JavaScript for the frontend. You should include inputs for the SSID and password and a button that invokes the create_hotspot command when clicked.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Hotspot GUI</title>
</head>
<body>
    <h1>Create Hotspot</h1>
    <input id="ssid" placeholder="SSID" />
    <input id="password" type="password" placeholder="Password" />
    <button id="create-hotspot">Create Hotspot</button>
    <div id="output"></div>

    <script>
        const { invoke } = window.__TAURI__.tauri;

        document.getElementById('create-hotspot').addEventListener('click', async () => {
            const ssid = document.getElementById('ssid').value;
            const password = document.getElementById('password').value;
            try {
                const result = await invoke('create_hotspot', { ssid, password });
                document.getElementById('output').innerText = result;
            } catch (error) {
                document.getElementById('output').innerText = `Error: ${error}`;
            }
        });
    </script>
</body>
</html>

Step 4: Build and Test

Run your application using:

cargo tauri dev

This will compile your Rust code and start the Tauri application. You can now enter an SSID and password to create a hotspot.

Additional Features and Error Handling

  • Start/Stop Hotspot: You can use additional commands to start (netsh wlan start hostednetwork) or stop (netsh wlan stop hostednetwork) the hotspot.
  • Error Handling: Check for errors in command executions and update your GUI accordingly to provide feedback to the user.
  • Permissions: The application may need admin privileges to execute the commands. Make sure to inform users accordingly.

This example provides a basic implementation. You can enhance it with better error handling, validation, styling, and additional features like viewing current connection status or client connections.

This tutorial, like your other topics, don’t see any interactions with other users, so this isn’t working out. This is a forum, after all – a forum is a place for discussion between people :wink:


To be honest, the tutorials you’re posting aren’t all that useful to other users in the first place; the commentary in the latest ones seems about as helpful as what the average LLM might generate nowadays.

We’ve also noticed the link you had posted in your post here https://tauri.studio/docs/getting-started/intro is actually pointing to a domain that is quite outdated for about 3 years (and replaced by a spam website nowadays), and the …/docs/getting-started/intro sub-page in particular seems non-existant even a bit longer than that.[1]

In case that your text here actually is written by an LLM, please note that we’re a forum for humans interacting with other humans, and AI-generated content, especially unmarked, is not welcome here.


So, I’ll need to come back to some points my previous feedback:

regarding “the frequency of opening new topics here”

You’ve opened this new topic and 2 others:

and

in less than 48 hours; that’s just too many topics. 1-2 weeks ago, you had also opened a somewhat large number of topics in a short time:

By default, visibility on this forum isn’t determined by any ranking/rating system, so we do need to use moderation actions to address the problem if someone opens too many separate topics; especially for posts of low quality and/or unable to result in useful discussions.

I’m thus unlisting some of your existing topics; if someone is still interested in reading them, they can still find them from the links above.

moving forward

I had previously suggested that

For example: You can collect the things you would want to post, and then choose the best, or combine / group things together in 1 thread.

but it doesn’t seem to be working, thus instead:

To minimize further moderation efforts, at this point I have to ask you to stop opening new tutorial topics here entirely.

If you have the desire to create tutorials that others want to read, I’d recommend you make them significantly higher quality, and more useful to people – something you would want to read yourself. Post them elsewhere, or host them on a dedicated website; I had already given some ideas before on you could start that:

For actual / more in-depth tutorial content, hosting the tutorial(s) on a different platform[4] could be an alternative to consider as well, and once you’re added some content and want readers to start looking into it, you can open a forum thread here with a link, to be able to get some feedback :wink:

If you do end up making a website, for now, please don’t open a new topic here on users.rust-lang.org for individual tutorials being published, either. But feel free to share your website one time, once you feel it’s ready and users might enjoy reading it.


Also, feel free to use the forum like most of our other users do. If you have questions or ideas you’d like to discuss as a Rust user – or answers to other people’s questions, don’t hesitate to leave a reply somewhere or even open a topic, if appropriate.


  1. This is rather negligent, you’re essentially promoting a spam website this way; also it raises the question how you found this URL, and relatedly, how you came up with your text in the first place. ↩︎

  2. and make them more readable, as mentioned above, by including text with actual explanations or other commentary; perhaps even also with questions you yourself would like answered? ↩︎

  3. I’m personally not sure I know any concrete platforms to suggest myself; many more in-depth tutorials people write are on their own websites; github pages could be an easy way to create one, e.g. I was able to find description (here) of how one could set up one with mdbook-powered content ↩︎

  4. I’m personally not sure I know any concrete platforms to suggest myself; many more in-depth tutorials people write are on their own websites; github pages could be an easy way to create one, e.g. I was able to find description (here) of how one could set up one with mdbook-powered content ↩︎

12 Likes

Even though the web server is only intended to be run locally, this is a text-book example of Remote Code Execution. Try putting "abc; notepad.exe" inside the key input. I would encourage you to try to find a better solution.

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.