Can SC launch Windows batch files?

For a project I’m working on, I’m using a Windows workstation with SC 3.10 running on it.

I would like for SC to stop audio and shutdown the pc when receiving a particular OSC message.
I was thinking about a shell script file to be launched by the a Pipe object but I eventually realized that this object only works for UNIX environments.
In fact this concept of “OSC message --> SuperCollider Pipe obj --> Shell Script” perfectly works on Linux but not on Windows.

Is there a similar obj which works the same on Windows?
If not, how to get the job done? I mean, I don’t like the idea to create some python script daemon which runs underground to do that, I would prefer SC in doing this. Is it possible?

Thanks for your help

About a year ago, while investigating a Quarks problem in Windows, I did do some tests of Pipe in Windows, and found that simple commands executed fine. See – tests 2-4 execute “cd” and “dir” commands through Pipe, and those were successful. (The problem in issue 4359 occurred when running specifically a git command.)

So the problem is not with Pipe. (Unless there’s been a regression in the last year.)

So first, try Pipe.callSync("dir", { |... args| args.debug("ok") }, { |... args| args.debug("failed") });. If this says “ok,” then we can rule out a new Pipe bug.

Assuming there’s no problem here, then possible problems might be:

  • Maybe the path to your batch file is incorrect?

  • Or maybe Pipe actually doesn’t support batch files (though it supports MS-DOS commands). I can’t test at the moment.

Also try unixCmd. It was named unixCmd because SC3 started on macOS, which is based on UNIX commands. Unfortunately the name leads Windows users to believe that it’s not supported in Windows, but that’s not true – you can issue DOS commands e.g. "dir".unixCmd.

If you’re shutting down the machine, then you don’t need to pipe the results back – unixCmd should be sufficient.


1 Like

hi @jamshark70,

thank you for your exahustive reply. I was eventually able to shutdown my Windows Pc via SuperCollider using the methods you shown me.

I’ve tried both with a direct command like this:

"shutdown /s /f /t 0".unixCmd({"process exited".postln}, postOutput:false);

and with a .bat file containing the same MS-DOS command

"myshutdown.bat".unixCmd({"process exited".postln}, postOutput:false);

I’ve also tried with the Pipe command and it works (Pipe is returning me “ok”)!

Pipe.callSync("cd C:\\myScriptDirectory && myshutdown.bat",
	{ |... args| args.debug("ok") },
	{ |... args| args.debug("failed") }

Thank you again