Skip to content

Latest commit

 

History

History
77 lines (62 loc) · 3.7 KB

File metadata and controls

77 lines (62 loc) · 3.7 KB

Setup on your own PC

This guide explains the overall auto run system and how to set it up on your Windows PC

How it Works

  • 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.bat is correctly modified and the WINCONSOLE.ID file is present on the root of any drive, an application will launch.

Noted issues:

  • BREAKING: The scripts will automatically run every 507 event. While the launcher.bat has 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

1. Modifying the launcher.bat file

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.

2. The Powershell Script

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

3. Create the Task in Task Scheduler

The Task Scheduler will execute the Powershell Script when a drive is connected and triggers a 507 event

To set this up:

  1. Press Win + R and open taskschd.msc

  2. Under the Actions on the right panel of the Task Scheduler select Create Task...

  3. 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
    • Check Hidden
    • Configure for: Windows 10
  4. 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
  5. 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
  6. Conditions tab

    • Uncheck everything
  7. 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 instance is selected on the bottom dropdown menu, thenm click OK
  8. Click OK, and now it's time to test!