Hey Guys -
I’ve got what will hopefully be a simple question for most. I’m trying to find the best way to launch a PS1 from the command line in a method where the application that called the execution doesn’t wait for it to complete.
Explanation
I’ve got an application that imports media files on a regular basis. I have it configured so that after each file is imported, a PowerShell script is executed which initiates an exe with a few passed variables that scans the imported file into a library plus writes some logging. It works great except for one thing: before additional files can be imported, the app waits for the script initiated by the prior file to complete which takes a couple of minutes. Therefore, importing ~5 files the way I have it set up now takes about 15 minutes yet if it didn’t wait for the script to complete after each, it would take about 15 seconds.
Current Configuration
Upon a file being imported into the app, I have the path “C:\Windows\SysWOW64\WindowsPowerShell\v1.0\PowerShell.exe” executed with the arguments "-ExecutionPolicy Bypass -file “C:\Scripts\Update.ps1”. I was hoping it would be as easy as adding a parameter like “-nowait”, but guess its not that easy so I tried making the adjustment to the string causing the delay within the script.
The Script
The script does a few things, but it’s the string that launches the exe which takes so long. I tried adding “Start-Job” to the beginning of the string, but it didn’t work since it started with an “&”. The string is “& “$scanner” --scan --refresh --section $id --directory $path” where $scanner is a variable set to an EXE file and other variables are pulled from the importing app.
Any suggestions? Thank You!