This guide explains the overall auto run system and how to set it up on your Windows PC
- Task Scheduler monitors for drive events, triggering a Powershell script
- The Powershell script looks for a specific file on the root of each drive, and if found, a Batch script is run
- The batch script runs a specific executable on the drive on which it is located, but first it runs a check to see if the application is already running
This system is designed to be a universal launching system, so that as long as the
launcher.batis correctly modified and theWINCONSOLE.IDfile is present on the root of any drive, an application will launch.
- BREAKING: The scripts will automatically run every 507 event. While the
launcher.bathas a trigger to stop if the application is already running, It will autolaunch if the drive is plugged in, even if the target application has been previously closed. I am open to help with this issue! - Command window opens anytime a 507 event is triggered, I could use help refining the events or at the least hiding the cmd pop-up
The launcher.bat is designed to run on the root of a removable drive. It will check to see if the program in question is already running, and if not, to launch it.
You only need to edit the :: Set your application details here section with the .exe file and path.
Example:
:: SET YOUR APPLICATION DETAILS HERE
set "EXE_NAME=Hob.exe"
set "EXE_PATH=%~dp0/Hob/HOB.exe"Ensure you place the modified launcher.bat and WINCONSOLE.ID files on the root of the removable drive you are launching the application from.
When run, the powershell script will look for the WINCONSOLE.ID file on the root of each drive. When found, it will run the launcher.bat file.
It is designed to run only once if triggered multiple times by the Task Scheduler, and to only run if the computer is unlocked.
No need to edit anything. Just place winconsole-batrun.ps1 in C:\Scripts
The Task Scheduler will execute the Powershell Script when a drive is connected and triggers a 507 event
To set this up:
-
Press
Win + Rand opentaskschd.msc -
Under the Actions on the right panel of the Task Scheduler select Create Task...
-
General tab:
- Name:
WinConsole Launcher - Description:
Launches WinDonsole drive executables - Security options:
- **Change User or Group...*, and under
Enter the object name to select (examples):type your Windows username exactly, then click OK - Select Run only when user is logged on
- Check Run with highest privileges
- **Change User or Group...*, and under
- Check Hidden
- Configure for:
Windows 10
- Name:
-
Triggers tab:
- Select New...
- Begin the taks:
On an event - Select Basic
- Log:
Microsoft-Windows-Storage-ClassPnP/Operational(long dropdown list) - Source:
StorDiag - Event ID: 507
- Uncheck all but the final Enabled, and click OK
-
Actions tab:
- Select New...
- Action:
Start a program - Settings:
- Program/script:
cmd.exe - Add arguements (optional):
/c powershell.exe -ExecutionPolicy Bypass -NoProfile -File "C:\Scripts\winconsole-batrun.ps1" - Click OK
- Program/script:
-
Conditions tab
- Uncheck everything
-
Settings tab: Check the following:
- Allow task to be run on demand
- Run task as soon as possible after a scheduled start is missed
- If the running task does not end when requested, force it to stop
- Ensure
Do not start a new instanceis selected on the bottom dropdown menu, thenm click OK
-
Click OK, and now it's time to test!