Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Steps to Run the Batch Script in Kiosk Mode

1. Prepare the Batch Script

  • Ensure your batch script (start_server.bat) is located in a secure and accessible location, such as C:\MayaWINX\.

  • Test the script to confirm it runs correctly in the background without requiring user interaction.

2. Run the Script as a Scheduled Task

Since the kiosk mode restricts access to the startup folder for the kiosk user, you can use Task Scheduler to run the script at system startup.

Steps:

  1. Open Task Scheduler (taskschd.msc).

  2. Click Create Task in the right-hand pane.

  3. In the General tab:

    • Name the task (e.g., StartServerScript).

    • Select Run whether user is logged on or not.

    • Check Do not store password (if applicable).

    • Check Run with highest privileges.

  4. In the Triggers tab:

    • Click New.

    • Set the trigger to At startup.

  5. In the Actions tab:

    • Click New.

    • Set Action to Start a program.

    • Browse to your batch script (C:\MayaWINX\start_server.bat).

  6. In the Conditions tab:

    • Uncheck any conditions that might prevent the script from running (e.g., "Start the task only if the computer is on AC power").

  7. In the Settings tab:

    • Ensure Allow task to be run on demand is checked.

    • Uncheck Stop the task if it runs longer than (unless you want to set a time limit).

  8. Click OK to save the task.

3. Test the Setup

  • Restart the computer to confirm the batch script runs automatically at startup.

  • Verify that the kiosk app (browser) launches correctly and the script runs in the background.

...

Step 1: Convert Batch File to Service Using sc Command

You can use the sc command to create a service that executes your batch script.

  1. Create a Windows Service using sc: Open Command Prompt (as Administrator) and run the following:

    sc create MayaWINXService binPath= "C:\Windows\System32\cmd.exe /c C:\MayaWINX\start_server.bat" start= auto

    Explanation:

    • MayaWINXService: The name of your service.
    • binPath: Command to run your batch script.
    • start= auto: Starts the service automatically at boot.
  2. Start the Service:

    sc start MayaWINXService

  3. Check Service Status:

    sc query MayaWINXService

...

Step 2: Optional — Use nssm for Better Control

If the batch script needs to run continuously

...

(e.g., a server process), use nssm (Non-Sucking Service Manager), which is more reliable than sc for running non-Windows executables.

Steps:

...

  1. Download nssm from https://nssm.cc/download.

...

Open Command Prompt as Administrator.

  1. Install your batch file as a service:

...

...

  1. nssm

...

  1. install

...

  1. MayaWINXService

  2. In the

...

  1. GUI that appears:

...

    • Path: C:\Windows\System32\cmd.exe
    • Startup Directory: C:\MayaWINX\
    • Arguments: /c start_server.bat

...

Configure the Startup directory (if needed).

...

...

Click Install service.

  1. Start the service:

...

net start StartServerService

Important Notes

  • Permissions: Ensure the batch script and any files it accesses have the correct permissions to run under the system or kiosk account.

  • Security: Kiosk mode is designed to restrict access, so ensure your script does not introduce vulnerabilities.

  • Testing: Thoroughly test the setup to ensure the script runs as expected without interfering with the kiosk app.

...

  1. nssm start MayaWINXService

...

Advantages of Running as a Service:

  • Runs before login, even in Kiosk Mode.
  • No UI pop-ups or user interaction required.
  • Automatically restarts if it crashes (with nssm).
  • Can be monitored and controlled using services.msc.