RunPythonScript with spaces in file path

I’m trying to run Rhino + python script using Task Scheduler using the following syntax:

“C:\Program Files\Rhino 8\System\Rhino.exe” /nosplash /runscript=“_-RunPythonScript C:\Users\me\Company Name With Spaces\Folder Name With Spaces\PythonScript.py

I put the file path in single quotes since the larger RunPythonScript argument is in double quotes, but when Rhino opens and tries to RunPythonScript it still sees the whitespace as Enter.

Any ideas on a workaround?

Hi @declan, below seems to work here under windows:

“C:\Program Files\Rhino 8\System\Rhino.exe” /nosplash /runscript=“_-RunPythonScript (E:\path with spaces\Script.py)”

note the parenthesis around the script path.

_
c.

3 Likes

Shazam! That did it. Thank you sir!!

This is interesting. Can you explain why you are running Rhino and a python script like this?

I need to do some file format conversions (SVG to DXF) every day in perpetuity. I have a py script that works great in Rhino, and so this was the path of least resistance (especially considering i am working in a corporate environment with tight I. T. oversight).

I definitely will be learning how to properly run Rhino headless with standalone python, but for now, this does the trick.

1 Like

This stuff is new to me. I have never tried Task Scheduler before.
Can I set up a task to run a python script in rhino (like you showed above) when ever a file is moved to a folder?
Can the Task Scheduler do stuff like that? Or do I have to set it up to process all files in a given folder at a given time?
Sorry for the noob questions, and I could probably google this stuff, or ask ChatGpt, but I am so old that I still prefer human interaction :smiley:

It’s totally new to me too - just learning about it out of necessity. There is an “OnEvent” trigger, but I’m not sure how you specify those events:

1 Like

Thanks, I’ll look into it. I did ask ChatGpt though and here is the answer.
I have not tested this at all, so use the example method at own risk:

ChatGPT's answer

You can use Task Scheduler in Windows to automate an action when a file appears in a specific folder. However, Task Scheduler alone does not have a built-in way to monitor folders. To achieve this, you need to combine it with a PowerShell script that watches for new files and triggers an event.


Method 1: Task Scheduler + PowerShell

This method uses a PowerShell script to monitor a folder. When a new file appears, the script triggers an action.

1. Create a PowerShell Script

Create a new file called MonitorFolder.ps1 and add the following script:

$folderPath = "C:\Path\To\Watched\Folder"
$fileFilter = "*.*"  # Monitors all file types

$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $folderPath
$watcher.Filter = $fileFilter
$watcher.IncludeSubdirectories = $false
$watcher.EnableRaisingEvents = $true

Register-ObjectEvent $watcher "Created" -Action {
    Start-Process "C:\Path\To\ProgramOrScript.exe"  # Replace with the action you want to perform
}

while ($true) { Start-Sleep 10 }  # Keeps the script running

This script continuously monitors the folder for new files and executes a program or script when a file is added.

2. Schedule the Script to Run at Startup

  1. Open Task Scheduler (Win + R, type taskschd.msc, press Enter).
  2. Click Create Basic Task (on the right panel).
  3. Give it a name (e.g., “Monitor Folder Task”), then click Next.
  4. Select When the computer starts, then click Next.
  5. Choose Start a Program, then click Next.
  6. In Program/script, type:
powershell.exe
  1. In Add arguments, type:
-ExecutionPolicy Bypass -File "C:\Path\To\MonitorFolder.ps1"
  1. Click Finish.

This setup ensures the script runs automatically on startup and continuously monitors the folder.


Method 2: Task Scheduler with Event Viewer (Advanced)

If you don’t want a continuously running script, you can trigger Task Scheduler using an event log entry.

1. Enable File Auditing

  1. Open Local Security Policy (Win + R, type secpol.msc, press Enter).
  2. Go to Advanced Audit Policy Configuration > Object Access > Audit File System.
  3. Enable Success.

2. Set Folder Auditing

  1. Right-click the folder you want to monitor, select Properties.
  2. Go to Security > Advanced > Auditing.
  3. Click Add, select Everyone, check Create files / write data.

3. Create a Task in Task Scheduler

  1. Open Task Scheduler.
  2. Click Create Task.
  3. Under Triggers, select On an Event.
  4. Choose Log: Security, Event ID: 4663 (file created).
  5. Under Actions, set it to run a script or program.

This method is more complex but does not require a continuously running PowerShell script.


Which Method Should You Use?

  • Method 1 (PowerShell script) → Easier and runs in the background.
  • Method 2 (Event Viewer + Task Scheduler) → More efficient but harder to set up.
1 Like