1

I am trying to run a command in windows powershell that will start a task schedule. Below is the command that I am using: Start-ScheduledTask -TaskName "pkms task scheduler" The powershell can run the task and the batch files from the scheduler but I do not know what is the problem why the Firefox window is not appearing even though the browser is running in the background. Here is the code for the batch file: @echo off cls start "" /d "C:\Kiosk Advertisement" firefox.exe.lnk exit

Hope that you can help me. Comment if you need more information

I did try to put "/max" beside the start command but the window is still not appearing.

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • All in one line? Why use a .lnk? Open a `CMD` window and enter `start "" /d "C:\Kiosk Advertisement" firefox.exe`. See what happens and work from there. – AcK Mar 31 '22 at 14:59
  • Please check If you set the same user in your task. – An-dir Mar 31 '22 at 17:01
  • Not necessarily in one line. The .lnk was used becuase the machine that we are working on only reads .lnk (will confirm this tho) and with regards to your tip, i entered it on cmd and the window appeared but upon running with the task scheduler, the batch file is not working – rheniel ilagan Apr 01 '22 at 06:46

1 Answers1

1

If your goal is just to start Firefox, the simplest way would be to use the path to your firefox executable to create the scheduled task action, like so:

$StartFirefoxScheduledTaskAction = 
    New-ScheduledTaskAction `
        -Execute 'C:\Program Files\Mozilla Firefox\firefox.exe'

Register-ScheduledTask `
    -TaskName 'Start Firefox' `
    -Action $StartFirefoxScheduledTaskAction

Note: you can pass multiple actions to the Register-ScheduledTask's -Action parameter.

Now, if you need something more sophisticated, please elaborate your question and tell us what you're trying to achieve with more details.

unsolaci
  • 53
  • 5
  • thanks for the response. Here is the whole situation. We would like to execute a powershell command that will run a task schedule. the task schedule will run a .bat file and in that batch file, it will a firefox .lnk. Now the thing is that when starting the powershell command, It will run the firefox in the background but the browser window is not appearing. – rheniel ilagan Apr 01 '22 at 06:53
  • @rhenielilagan Is there a reason for running the `.lnk` file from a `.bat` file, instead of just the direct executable path to `firefox.exe`? It all seems much more complicated than it should be, and introducing unnecessary complexity often leads to issues that are difficult to debug. – unsolaci Apr 01 '22 at 12:11
  • @rhenielilagan If you're seeing the firefox process running, check which user it's running as. It might be that you're registering the scheduled task for a different user (e.g. `SYSTEM`). – unsolaci Apr 01 '22 at 12:20
  • with regards to the .lnk, i think it should be fine not running it as I tested running the .exe file and the result is fine. Thanks for the tip.. will check the user and update this post once done. – rheniel ilagan Apr 01 '22 at 12:36