Start Batch File Minimized via Task Scheduler

Page 2 of 3 FirstFirst 123 LastLast

  1. Posts : 61
    Windows 7 and 10
    Thread Starter
       #11

    Thanks for your replies. Sad to say, I have never learned VBS, and can't make that investment now, so the VBS suggestions elude me. The Nircmd and shortcut suggestions are familiar, but as far as I can tell they run the batch file invisibly, so that I can't bring it back to fullscreen by coolswitching or clicking on a taskbar icon. I looked at WinAutomation, but it seems the price is $400.

    FreeBooter: interesting script. I'm not sure I get it, though. The script issues commands that, collectively, construct a batch file and then run it minimized. So I would rewrite my batch files to consist of similar commands. What's running, ultimately, is not the commands presently found in my batch file. What's running is the temporary batch file constructed from the lines in my rewritten batch files. It's credible, but damn ungainly.

    Could I do something similar with TYPE or COPY commands that would stick the contents of a normal-looking batch file into a new, temporary batch file that CMD /C would then run minimized? It seems like this shouldn't be hard, but I'm tired and I can't quite wrap my head around it.

    Thanks again, one & all ...
      My Computer


  2. Posts : 4,525
    Windows 11 Pro 64-bit
       #12

    Batch script i posted will Echo all your code line by line to Temp.bat and execute it i know you will have to use Echo command front of all the single codes to copied into Temp.bat file that's best i can think of it for now maybe you can use For command to Echo your codes to Temp.bat file. Make sure to not to Echo cmd.exe /c start /min %tmp%\Test.bat to Temp.bat file. If i come up with something else i let you know.
      My Computer


  3. Posts : 11,390
    Windows 10 Home x64 Version 21H2 Build 19044.1706
       #13

    Raywood,

    The procedure I posted a link to takes you through the whole thing and you will not need to learn VBS or anything else. And you will not need to spend anything.

    Denis
      My Computer


  4. Posts : 11,390
    Windows 10 Home x64 Version 21H2 Build 19044.1706
       #14

    Try3 said:
    Use this procedure Make Windows 10 Task scheduler run a batch file minimised and with a specific icon - MSA Forum article
    I wrote that article but post any questions here not there as I do not contribute to that forum anymore.
    The procedure has now been posted in TenForums.
    Make Task scheduler run a batch file minimised and with a specific icon - TenForums

    Denis
      My Computer


  5. Posts : 3
    Win 10
       #15

    A complete solution - and no VBS! or PowerShell required!


    Here's a simple batch file (C:\Test.bat) attached.
    Code:
    @echo off
    if "%2" EQU "" goto Usage set FLDR=%1 shift set BATCH=%1 shift Start "Minimised command" /D %FLDR% /MIN %BATCH%.bat %* goto :eof :Usage echo. echo Must be run with echo Arg1=Start_Folder, echo Arg2=Batch_name (excl .bat), echo Args 3.... (optional) echo [Passed to called Batch Command file] echo. pause goto :eof

    And a scheduled task to run it (on demand only) is attached
    Which runs the script above which starts C:\Test2.bat and terminates leaving C:\test2.bat running, with supplied arguments, in a minimized state on the taskbar
    Start Batch File Minimized via Task Scheduler Attached Files
      My Computers


  6. Posts : 11,390
    Windows 10 Home x64 Version 21H2 Build 19044.1706
       #16

    What about its icon? Can your method be extended to set a specific one?

    Denis
      My Computer


  7. Posts : 11,390
    Windows 10 Home x64 Version 21H2 Build 19044.1706
       #17

    Small points about transferring TS Task xml definitions
    - The xml file needs a real date-time. That field cannot be emptied as you have done.
    - The line <UserId></UserId> has to be deleted not just emptied.

    Major point - The command console flashes up onscreen momentarily. That is avoided by using the vbs intermediary in my solution [which also achieves the allocation of specific icons].


    All the best,
    Denis
      My Computer


  8. Posts : 34,980
    Win 10 Pro (1903) (2nd PC is 21H2)
       #18

    Here's how I chose to do it using nircmd by Nirsofer:
    NirCmd - Windows command line tool

    Start Batch File Minimized via Task Scheduler-1.jpg

    You can see the nircmd files on C:

    The bat file is truncated in the screenshot: FunctDiscoveryNetwork.bat
      My Computers


  9. Posts : 3
    Win 10
       #19

    Try3 said:
    Small points about transferring TS Task xml definitions
    - The xml file needs a real date-time. That field cannot be emptied as you have done.
    - The line <UserId></UserId> has to be deleted not just emptied.
    Sorry Denis, you misconstrue my intent with the XML. It was an example not a piece of loadable code. The items removed were just to delete sensitive information. The salient items were the command / argument definition entries, not (for example) what time it was to run.

    Try3 said:
    Major point - The command console flashes up onscreen momentarily. That is avoided by using the vbs intermediary in my solution [which also achieves the allocation of specific icons].
    Each to his own. I'm sure your solution is marvellous. Possibly less so if the OP doesn't know and doesn't want to learn VBS. If he doesn't and your solution is perfectly "shrink wrapped" there is the statement that they didn't like it.

    Sorry about that.

    Yes, the question of the icon could be addressed but, as you only asked it in order to score points - and it was never requested - I'll just pass on biting on that one.

    Regards

    Think
      My Computers


  10. Posts : 11,390
    Windows 10 Home x64 Version 21H2 Build 19044.1706
       #20

    dalchina said:
    Here's how I chose to do it using nircmd
    Thanks for that. I had not used NirCmd's exec option before.
    - It does not directly let me call an .lnk shortcut in order to achieve the icon choice
    - But it does let me [well, TS] call another batch file as an intermediary and that route lets me run the target batch file minimised & with a chosen icon yet without a cmd window momentarily flashing onscreen.
    So, that's a success.

    My original method [vbs intermediaries] has a by-product in that they can be pinned to the Taskbar to let me run the target batch file minimised & with a chosen icon yet without a cmd window momentarily flashing onscreen
    - Now I'll have to play with the NirCmd intermediary method to see if there is some variation on this theme that will achieve this end as well.
    - I had played around with a PS1 intermediary that achieved this aim but I never managed to get that to work from TS in the desired manner.
    - Perhaps I'll end up with some PS1-NirCmdExec hybrid.

    I have long had a vague intention to dispense with using vbs intermediaries altogether and your suggestion might be the step forward that gets me there.
    - Microsoft Defender ["WD"] can often be a pig when it comes to vbs [as it can be with VBA] but seems to play nicely with PS.
    - It would be good to be able to get rid of the many WD Exclusions I've had to set up to allow my scripts to run without incident [WD does not always obey its own folder Exclusions so I keep having to add individual scripts to the list every time WD has another hissy fit].

    All the best,
    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 16:06.
Find Us




Windows 10 Forums