| 1. |
Solve : How to keep batch file running? |
|
Answer» Here's the problem. Scheduled tasks can only be initiated, modified, canceled by an administrator (so I think). I'll be testing batch files that are supposed to start Excel and ACCESS as scheduled tasks and run some jobs. calls some other batch file that I can modify at will. The scheduled 'shell' needs to stay alive until some action that I perform allows it to exit (e.g., delete a 'gate' file). Code: [Select]echo off call somename.bat :start if not exist gatefile.bla goto:eof other code goes here sleep 1 goto start If you don't have the sleep command installed, then you need to download it. Quote When it's finished, I'd like to modify it and have it run again. Not sure what you mean. How do you want it modified?Basically, I want to keep the shell (scheduled task) running but be able to change what the task does without cancelling the scheduled task itself. This is a testing period, so for example, I may want to have Excel started VIA the scheduled task and have it open a workbook and execute a 'workbook_open' event macro. while the scheduled task is still active, I may want to have it start Access with an 'Autoexec' macro. It all goes back to the fact that I have no control over initiating, modifying, cancelling a scheduled task. I can only request that one be scheduled. Hence the 'shell' concept where I can then modify the script that is called by it.I am unsure why you need the task scheduler at this point in your development. Why can't you test your batch file(s) from the command prompt until you are satisfied with the results? At that point you can have the administrator put the files directly on the schedule with no need for a "shell". Batch files do not run any different whether they are started from the command line or the scheduler, but be aware that a batch file will open will open a command window to run. Windows programs (Access or Excel) may also open their own Windows unless the startup macro leaves the VISIBLE property turned off. Due to the obscurity and obtuseness of some the the batch notation, you're better off keeping your batch files simple and not adding layers of complexity. Just a thought, I am doing testing via command line and also scheduling my own tasks, but this is on my desktop. The process will run on a remote server, so file locations, mail servers, etc. will be different. I don't want to keep requesting changes through the administrator. Quote The process will run on a remote server, so file locations, mail servers, etc. will be different. Not knowing any of the details of your operating system or batch files(s), you can make your code as generic as possible and use VARIABLES for specific values based on which system the code is running. For example you can query the %computername% variable and set file locations, mail servers, etc accordingly. Code: [Select]if %computername% EQU myComputer ( set accessdb=e:\path\file.mdb set excelbook=e:\path\file.xls ) if %computername% EQU Server ( set accessdb=x:\path\file.mdb set excelbook=x:\path\file.xls ) In reality you will probably have more variables, but I'm guessing you can see where this is going. Make sure the job can run from a shortcut or the command line on both your local machine and the server. Putting the job on the scheduler should be the final step in the process, not the first step. Good luck. Good suggestion. I think I'm getting close to what I need. Next step is to request scheduled task from administrator. |
|