Run console application on windows restart

I have a deployment step that looks like this

Set-Location $OctopusParameters[“Octopus.Action.Package[x].ExtractedPath”]
Start-Process -WindowStyle hidden -FilePath x.exe

And that works well during deployment.
However if that machine restarts I would like to make sure the process is started.

As far as I can see I cannot runt a deployment step on every windows startup.
So instead I planned on using windows schedule to run a powershell script.

And during deployment I generate this powershell script to point to the last extracted path.
But this is where I run in to problems, the extracted path does not contain x.runtimeconfig.json despite it being part of the nuget package, and without that I cannot run the executable.

Any suggestions?

Hi @rickard,

Thanks for reaching out!

Setting up a scheduled task for this sounds like the best approach to me :+1:

The approach I’d take is to have your scheduled task to always look for a persistent place(*) that holds the latest path of your x.runtimeconfig.json so it can be used with your start-process cmdlet. Then, on each deployment you’d be updating the value of your persistent place (*) with the last extracted path.

(*) This could be:

  • A .config file
  • An environment variable
  • A Registry entry

Let me know if the above works/makes sense for your scenario.



I ended up solving it with making a copy of the extracted dir (under work) to a known location.
Then I got all files including runtimeconfig.json

When I did not do this the work directory seemed to be purged which is probably why that file kept dissapearing!

1 Like