Home > Software engineering >  run serve -s build from .bat file
run serve -s build from .bat file

Time:09-06

I want to execute serve -s build from .bat file as admin, this is my .bat file:

@ECHO OFF  
cd "C:\Users\user\Desktop\Brabender\build-20220517T114506Z-001"  
serve -s build

It works if I manually run it as admin, but I need it to run from Windows Startup Folder everytime the system starts, any ideas how to do it as admin automatically?

CodePudding user response:

Some minor changes to your batch file, adding /d to the cd command

@echo off
cd /d "C:\Users\user\Desktop\Brabender\build-20220517T114506Z-001"  
serve -s build

Assuming we call the file something like serve-build-script.bat, run from cmd.exe

schtasks /create /tn "Serve-Build" /tr "c:\<Path-to-Batch-file>\batchfile-name.bat" /sc onstart /ru "user" /rp "password" /np /f

The correct version updated as per confirmation from the chat.

  • Related