Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support --restart flag on Windows #1

Open
walfie opened this issue Sep 9, 2021 · 1 comment
Open

Support --restart flag on Windows #1

walfie opened this issue Sep 9, 2021 · 1 comment

Comments

@walfie
Copy link
Owner

walfie commented Sep 9, 2021

I originally tried to implement this on Windows but wasn't able to get it working well. Closing the Stream Deck application works fine with Command::new("taskkill").args(&["/f", "/im", "StreamDeck.exe"]).status(), but reopening it had issues.


Doing it this way causes the CLI command to hang since it waits for StreamDeck.exe to return:

Command::new(r#"C:\Program Files\Elgato\StreamDeck\StreamDeck.exe"#).status()

Doing it this way causes the error Windows cannot find 'C:\Program':

Command::new("start")
.args(&["", r#"C:\Program Files\Elgato\StreamDeck\StreamDeck.exe"#])
.status()

Adding quotes around it doesn't work either (I guess it includes the quotes as part of the path?)

Command::new("start")
.args(&["", r#""C:\Program Files\Elgato\StreamDeck\StreamDeck.exe""#])
.status()

Looks like it's related to a longstanding issue regarding escaping in Windows commands:
rust-lang/rust#29494 (The fix is only available on nightly)

A proposed workaround (that works on stable rust) is to use some Windows-specific functions, but I don't have a Windows device to test on, and this flag is just a "nice to have" (the user can just close and reopen the application themselves) so I'll leave this one to someone else who wants to send a PR for it.

@walfie
Copy link
Owner Author

walfie commented Sep 9, 2021

Another workaround is to have the CLI tool write a batch script that has the appropriate stop/start commands, and then execute that instead, but it feels very hacky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant