DEV Community

Cover image for Automation of OBS Scene Loading in Windows
Ivaj O'Franc
Ivaj O'Franc

Posted on Edited on Originally published at dev.to

Automation of OBS Scene Loading in Windows

id: 2788202
title: "Automation of OBS Scene Loading in Windows"
published: true
tags: ["obs", "powershell", "windows", "automation"]
series: "I Fixed It and I Don't Know How"
description: "🎬 I fixed it and I don’t know how: Automating OBS Scene Loading on Windows   🇪🇸 Leer este..."
canonical_url: "https://dev.to/ivajofranc/automation-of-obs-scene-loading-in-windows-26p5"
cover_image: "https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp5afeg9yiacrvhcc0law.png"
Enter fullscreen mode Exit fullscreen mode

🎬 I fixed it and I don’t know how: Automating OBS Scene Loading on Windows

🇪🇸 Leer este post en español

It all started with something that seemed simple: I wanted that every time any user logged into a PC, an OBS scene file (scenes.json) would automatically be copied into their profile. In theory, it was just a PowerShell script. In practice, it was another story.


🧩 The basic PowerShell script

First, I put together the script copy_scenes_test.ps1, which basically copied the scenes.json file to the OBS scenes folder in the user’s profile:

$source = "C:\Path\Source\scenes.json"
$destDir = "$env:APPDATA\obs-studio\basic\scenes"
$dest = Join-Path -Path $destDir -ChildPath "scenes.json"

if (!(Test-Path -Path $destDir)) {
    New-Item -ItemType Directory -Path $destDir -Force | Out-Null
}

Copy-Item -Path $source -Destination $dest -Force
Enter fullscreen mode Exit fullscreen mode

Simple, right? Now I just had to make it run on every logon.


🔍 First idea: the official way (GPO)

The first solution I thought of was: use a GPO in Active Directory to run the script at user logon.

On paper, perfect: centralized, controlled, with logs.

In reality… too heavy for just one machine. I decided to look for something simpler.


🚀 The alternative: common startup folder

I went for the classic startup folder:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
Enter fullscreen mode Exit fullscreen mode

First attempt: a shortcut with .bat

I made a .bat that created a shortcut to run PowerShell. It worked, but with one annoying detail: the PowerShell window popped up at logon. Not pretty.


🛠 The final solution: a .vbs to hide it

The trick was to use a .vbs that executed the PowerShell script hidden:

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "powershell.exe -ExecutionPolicy Bypass -File \"C:\Path\copy_scenes_test.ps1\"", 0, False
Enter fullscreen mode Exit fullscreen mode

And then a .bat to create the shortcut pointing to that .vbs:

@echo off
set startup=%ProgramData%\Microsoft\Windows\Start Menu\Programs\Startup
powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%startup%\Copy scenes test.lnk');$s.TargetPath='wscript.exe';$s.Arguments='\"C:\Path\hidden_test.vbs\"';$s.WorkingDirectory='C:\Path';$s.Save()"
Enter fullscreen mode Exit fullscreen mode

Now it worked: it ran at logon, with no annoying windows, and without requiring strange privileges.


🧪 Silent check

To make sure everything was working, I added a log at the end of the .ps1:

Add-Content "$env:TEMP\obs_test_log.txt" "Copied on $(Get-Date)"
Enter fullscreen mode Exit fullscreen mode

That way I could verify it without asking users.


✅ Result

  • On every logon, the scenes.json file is copied to the correct profile.
  • Execution is invisible to the user.
  • No admin rights required.
  • No need to touch global execution policies.

In short: it looked like a mess, but it ended up working fine. Another case of “I fixed it and I don’t know how”.

Top comments (0)