Windows 10: Keep Console Open after running power shell script through task scheduler

Discus and support Keep Console Open after running power shell script through task scheduler in Windows 10 Network and Sharing to solve the problem; I am running a powershell script using task scheduler: Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe Add arguments... Discussion in 'Windows 10 Network and Sharing' started by HareshGP, Nov 5, 2020.

  1. HareshGP Win User

    Keep Console Open after running power shell script through task scheduler


    I am running a powershell script using task scheduler:

    Program/Script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

    Add arguments optional: C:\Users\Administrator\Desktop\JO.ps1



    This works fine. However I want the powershell console to remain open. After looking at this article keep-powershell-console-window, I tried:


    1. Adding an argument within task scheduler

    Add arguments optional: -NoExit "C:\Users\Administrator\Desktop\JO.ps1"

    The script runs fine but the console window does not remaining open I can't even see it momentarily appear.


    2. Changing the script file itself

    I added the following line to the end of my script: Read-Host -Prompt "Press Enter to exit"

    When the script is run manually the console window remains open, but if the script is run through the task scheduler the console window does not remain open.



    Please help.

    Haresh


    :)
     
    HareshGP, Nov 5, 2020
    #1

  2. Scheduled tasks run with elevated privileges can't access stored Windows credentials

    It seems that after Creators update scheduled tasks run with elevated privileges ('run with highest privileges' option) can't access stored Windows credentials. Is that a bug or an intentional change and is there a recommended workaround?

    Here's one way to reproduce the behaviour:

    • Start Credential Manger and add some Windows share credentials.
    • In a console window type 'cmdkey /list', which should list the added credentials
    • Create a task in a task manager:
      • Trigger: on user logon
      • Action: run cmd.exe
      • Tick the 'run with highest privileges' option
    • Reboot the machine and log in
    • In the console window (let's call it 'console 1') opened from the scheduled task type 'cmdkey /list'. This most likely won't display the credentials added in step 1 and properly listed in step 2. ->
      This looks like a bug
    • Now, without closing 'console 1' open another console window as an administrator (let's call it 'console 2') and type 'cmdkey /list'. This will properly list credentials added in step 1.
    • Switch to 'console 1' and type 'cmdkey /list' again. This time the credentials are listed properly, unlike in step 5. It looks like an access to Windows credentials was somehow 'unlocked' by step 6.
     
    MarcinMrowiec, Nov 5, 2020
    #2
  3. Peer_Sam Win User
    Task Scheduler doesn't run script

    Hi,

    Thank you for writing to Microsoft Community Forums.

    Are you able to run the script manually? If yes, does it do what it is intended to?

    Disable the UAC temporarily.

    Make sure that the Task scheduler
    service is running.

    Press ‘Win+R’.

    Type Services.msc.

    Locate the service Task scheduler
    and make sure that it is in running state.

    Go to the Conditions
    tab in task scheduler and make sure that no such condition is set which could block the task from running.

    Enable All Tasks History in Task scheduler and run the scheduled task.

    Refresh the task scheduler and check if you find any error message/code for any step in the task run.

    Also try with disabling Run whether the user is logged on or not
    option and see if the script runs.

    Hope it helps.

    Peer Samie

    Microsoft Community-Moderator
     
    Peer_Sam, Nov 5, 2020
    #3
  4. S-278 Win User

    Keep Console Open after running power shell script through task scheduler

    Task Scheduler doesn't run script

    Hey Microsoft Community,

    I'm trying to create a task in Task Scheduler that runs a specific script. The issue is that when the task runs (whether I do it manually or if it's scheduled), the script doesn't actually get executed. I know that the script works, and I have tried using
    both .EXE and .BAT scripts. I have set the task to run whether I'm logged in or not, using Highest Privileges, from my Administrator account; I have Full Access to the script file and the directory it's in; I have tried putting the directory it's in into the
    "Start in" field; I have tried opening Task Scheduler as an Administrator. Every time the task runs successfully, but the thing my script is supposed to do isn't done, from which I am inferring that the script doesn't get executed. The script isn't using any
    network connections. It's also not being blocked by my antivirus, I checked by temporarily turning it off.

    System info:

    Windows 10 x64 version 1803

    Thanks in advance!
     
    S-278, Nov 5, 2020
    #4
Thema:

Keep Console Open after running power shell script through task scheduler

Loading...
  1. Keep Console Open after running power shell script through task scheduler - Similar Threads - Keep Console Open

  2. Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...

    in Windows 10 Network and Sharing
    Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...: Windows 10Hello Is it possible to write a script for either a .bat file, or a CMD shell or Power Shell script, to automate running a single small .exe Snap2HTML.exe over and over again while stating the program parameters. I wish to use a small program called Snap2html...
  3. Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...

    in Windows 10 Software and Apps
    Script for either a .bat file, or a CMD shell or Power Shell script, to automate running a...: Windows 10Hello Is it possible to write a script for either a .bat file, or a CMD shell or Power Shell script, to automate running a single small .exe Snap2HTML.exe over and over again while stating the program parameters. I wish to use a small program called Snap2html...
  4. Unknown Power shell script running

    in Windows 10 Gaming
    Unknown Power shell script running: Hi,I usually get a brief pop-up for a script that runs at random times as far as I can gather. Its only for a split second, but its a nuisance if I am gaming as my controller is just disabled until I swap out and back to the game window again.I can see that there are several...
  5. Unknown Power shell script running

    in Windows 10 Software and Apps
    Unknown Power shell script running: Hi,I usually get a brief pop-up for a script that runs at random times as far as I can gather. Its only for a split second, but its a nuisance if I am gaming as my controller is just disabled until I swap out and back to the game window again.I can see that there are several...
  6. Unable to generate hash id file through running script in Power Shell

    in Windows 10 Gaming
    Unable to generate hash id file through running script in Power Shell: Hi,After running the below script in Power Shell for generating hash id file for restting machine it showing below error and please check attached error.Script : Get-CimInstance -Namespace root/cimv2/mdm/dmmap -Class MDM_DevDetail_Ext01 -Filter "InstanceID='Ext' AND...
  7. Unable to generate hash id file through running script in Power Shell

    in Windows 10 Software and Apps
    Unable to generate hash id file through running script in Power Shell: Hi,After running the below script in Power Shell for generating hash id file for restting machine it showing below error and please check attached error.Script : Get-CimInstance -Namespace root/cimv2/mdm/dmmap -Class MDM_DevDetail_Ext01 -Filter "InstanceID='Ext' AND...
  8. Unable to generate hash id file through running script in Power Shell

    in AntiVirus, Firewalls and System Security
    Unable to generate hash id file through running script in Power Shell: Hi,After running the below script in Power Shell for generating hash id file for restting machine it showing below error and please check attached error.Script : Get-CimInstance -Namespace root/cimv2/mdm/dmmap -Class MDM_DevDetail_Ext01 -Filter "InstanceID='Ext' AND...
  9. Power shell script

    in Windows 10 Support
    Power shell script: Not sure where to post this. Can anyone tell me what this does. C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy UnRestricted function IJ($A) {$L = $Null;Get-ChildItem $A -Recurse -Depth 1 -ErrorAction 'SilentlyContinue' | ? {$_.extension -eq '.lnk'}...
  10. Task Scheduler doesn't run script

    in Windows 10 Software and Apps
    Task Scheduler doesn't run script: Hey Microsoft Community, I'm trying to create a task in Task Scheduler that runs a specific script. The issue is that when the task runs (whether I do it manually or if it's scheduled), the script doesn't actually get executed. I know that the script works, and I have tried...