Winbatch script/program setup as windows service not working

Started by guile, October 16, 2020, 08:16:15 AM

Previous topic - Next topic

guile

Trying examples and they compile .exs and do setup as window service but fail to run winbatch code even the example code thats included in the examples?  Just need a working example or advice, searched and tried multiple service templates having difficulties, HELP!!! PLEASE!!!

td

Did you read the Consolidated WIL Help file topic titled "Run as a Native Service" carefully?  Note that it states that

"Vista and newer

   Services cannot directly interact with a user"

So if you are not using XP, the example will not display any of the Box function output and you will have no idea if the service is functioning based on output.  The example is just a template and needs modification to actually do something.  Other than that, you haven't provided enough information to diagnose any addtional issues.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

guile

Hi td thank you, is their a working script that say launches like notepad?  So I can see a working example please, thank you very much.

td

As previously mentioned "services cannot directly interact with a user" so there is not a working script that launches notepad.  Why don't you just comment out the Box functions the Display function in the example? Write to a log file or something instead.

https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/Service+Interactive~Desktop~Service~Issue.txt
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

A common cause of service script failures is not properly configuring the service when it is created. This is turn causes the service to fail to start. The only way to assist with this type of issue is to be provided with information about how the service is being created (both technology and settings) on which version of Windows.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

guile

Note: This is my service program that needs to start a .bat file and continue to run every 30 minuets, it writes to the registry for a test,
Note: I also have a compiled separate .exe made up from the code in the DoWork sub code and the .exe works just fine,
Note: Question can a service run a compiled winbatch program that in turn runs the .bat file? 
Note: Testing on windows 10, servers 2012 R2,2016 and 2019
Note: Using Winbatch 2020A and compiler, thank you in advanced!!!

;Initialze variables for the SvcSetAccept function
SERVICE_ACCEPT_STOP             =   1    ;The service can be stopped
SERVICE_ACCEPT_PAUSE_CONTINUE   =   2    ;The service can be paused and continued
SERVICE_ACCEPT_SHUTDOWN         =   4    ;The service is notified when system shutdown occurs
SERVICE_ACCEPT_HARDWAREPRFCHG   =   3    ;The computer's hardware profile has changed.
SERVICE_ACCEPT_POWEREVENT       =   64   ;The computer's power status has changed.
SERVICE_ACCEPT_SESSIONCHANGE    =   128  ;The computer's session status has changed (requires XP/2003 or newer.)
SERVICE_ACCEPT_PRESHUTDOWN      =   256  ;The computer is about to shutdown (requires Vista/2008 or newer.)
SERVICE_ACCEPT_LOGOFF           =   32768;The service is notified when user logoff occurs

;Initialize variables for the SvcSetState function
SERVICE_STATE_STOPPED           =   1   ;The service is not running
SERVICE_STATE_STOP_PENDING      =   3   ;The service is stopping
SERVICE_STATE_RUNNING           =   4   ;The service is running
SERVICE_STATE_CONTIN_PENDING  =   5   ;The service continue is pending
SERVICE_STATE_PAUSE_PENDING     =   6   ;The service pause is pending
SERVICE_STATE_PAUSED            =   7   ;The service is paused

;Initialize variables for the SvcWaitForCmd function
SERVICE_CONTROL_NOT_SERVICE     =  -1   ;Script not running as a service
SERVICE_CONTROL_TIMEOUT         =   0   ;Timeout occurred or no codes to process
SERVICE_CONTROL_STOP            =   1   ;Requests the service to stop
SERVICE_CONTROL_PAUSE           =   2   ;Requests the service to pause
SERVICE_CONTROL_CONTINUE        =   3   ;Requests the paused service to resume
SERVICE_CONTROL_SHUTDOWN        =   5   ;Requests the service to perform cleanup tasks, because the system is shutting down
SERVICE_CONTROL_HARDWAREPRFCHG  =   12  ;The computer's hardware profile has changed.
SERVICE_CONTROL_POWEREVENT      =   13  ;The power status has changed.
SERVICE_CONTROL_SESSIONCHANGE   =   14  ;The session status has changed (requires XP/2003 or newer.)
SERVICE_CONTROL_PRESHUTDOWN     =   15  ;The system will be shutting down (requires Vista/2008 or newer.)
SERVICE_CONTROL_USER128         = 128   ;User command 128
SERVICE_CONTROL_USER129         = 129   ;User command 129
SERVICE_CONTROL_USER130         = 130   ;User command 130
SERVICE_CONTROL_USER131         = 131   ;User command 131
;                                       ;More user commands as needed
SERVICE_CONTROL_USER255         = 255   ;User command 255
SERVICE_CONTROL_LOGOFF          = 32768 ;logoff notification

;Setup debugging prompt strings....
debugcodes="0: Timeout|1: Stop|2: Pause|3: Continue|5: Shutdown|128: User Cmd 128|129:User Cmd 129|32768: Logoff"

;Tell system that we want specific notifications
flag=SvcSetAccept( SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_LOGOFF)
If flag== -1
   DoingDebug=@TRUE
   ;Pause("Debug Mode","Not currently running as a service")
Else
   DoingDebug=@FALSE
   ;Set up error handling
   IntControl(12,2+8,0,0,0)                    ;Tell WinBatch to not honor terminate and
                                               ;not complain on Windows exit
   IntControl(38,1,"errorlog.txt",0,0) ;Route fatal errors to a log file
EndIf

;Now for the main service loop
;in this service we respond to all control messages
;and check an ini file for work every 5 seconds
;BoxOpen("Initializing","main service loop")
While @TRUE
   If DoingDebug==@FALSE
      code=SvcWaitForCmd(5000)      ; Timeout in 5 seconds
   Else
       ;For Debugging.  Prompt tester to see what code should be pretended here
       code=AskItemlist("Service Debug",debugcodes,"|",@UNSORTED,@SINGLE)
       If code=="" Then Continue
       code=ItemExtract(1,code,":")
   EndIf

   Switch code
          Case SERVICE_CONTROL_TIMEOUT
               ;Timeout occurred
               ;BoxTitle("SERVICE_CONTROL_TIMEOUT")
               ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
               GoSub DoWork
               ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
               Break
          Case SERVICE_CONTROL_STOP
               ;Stop command received
               ;BoxText("Stop command received")
               SvcSetState(SERVICE_STATE_STOP_PENDING)
               ;do stop cleanup work here
               TimeDelay(5)
               SvcSetState(SERVICE_STATE_STOPPED)
               Exit    ;Goodbye
               Break
          Case SERVICE_CONTROL_PAUSE
               ;Pause command received
               ;BoxText("Pause command received")
               SvcSetState(SERVICE_STATE_PAUSE_PENDING)
               ;do pause cleanup work here
               SvcSetState(SERVICE_STATE_PAUSED)
               Break
          Case SERVICE_CONTROL_CONTINUE
               ;Continue command received
               ;BoxText("Continue command received")
               SvcSetState(SERVICE_STATE_CONTIN_PENDING)
               ;do resume from pause state initilization here
               SvcSetState(SERVICE_STATE_RUNNING)
               Break
          Case SERVICE_CONTROL_SHUTDOWN
               ;Shutdown notification received
               ;Approx. 20 seconds to process
               ;BoxText("Shutdown notification received")
               SvcSetState(SERVICE_STATE_STOP_PENDING)
               ;do stop cleanup work here
               SvcSetState(SERVICE_STATE_STOPPED)
               Exit    ;Goodbye
               Break
          Case SERVICE_CONTROL_USER128
               ;User command 128 received
               ;BoxText("User command 128 received")
               Break
          Case SERVICE_CONTROL_USER129
               ;User command 129 received
               ;BoxText("User command 129 received")
               Break
          Case SERVICE_CONTROL_LOGOFF
               ;Logoff command received
               ;BoxText("Logoff command received")
               Break
         Case code
               ;Unrecognized command received
               ;BoxText("Unrecognized command received")
               Break
      EndSwitch

EndWhile

;Note.  The preceeding loop never exits
Exit   ; Just a formality

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;The DoWork subroutine can be used to execute the code you want to run while
;the service has not control requests
:DoWork
   ;BoxText("WinBatch Services test is running")
   RegSetValue(@REGMACHINE,"Software\Test\WinBatch Services[test1]","It Worked David")

      ;procfilename=("Scheduler_TEST_Worker")
   countProc=0
   count=tCountProc()
   proclist=tlistproc()
   For x = 1 to count
     item=ItemExtract(x,proclist,@Tab)
     procname=ItemExtract(1,item,"|")
     ;Display(10, "%procfilename% exists","Process Id is %procname%")
     ;if (procname)== procfilename
     ;procname=StrTrim(procname,3)
     ;Display(10, "%procfilename% exists","Process Id is %procname%")
      if (procname)== procfilename
      ;Message("Procname equals profilename", procname)
      ;TimeDelay (3)
           countProc = countProc + 1
      ; parse off process id
      procid=ItemExtract(2,item,"|")
      ;Message("Break", procid)
      ;Break
      ;TimeDelay (3)
      Else
      ;Display(10, "%procfilename% exists","Process Id is %procname%")
     endif
   Next
      ;Display(3, "Current window is", countProc)
         ;If countProc >= 1
         If countProc > 1
            ;Display(3, "Scheduler_TEST_Worker already running", countProc)
            ;Display(3, "      Scheduler_TEST_Worker ", "already running")
            TimeDelay (1)
            Exit
         Else
         TimeDelay (1)
         ;Display(3, "Else", WinGetactive( ))
Endif

;Run continuouly every 30 Min
;Display(2, "Run continuouly every 30 Min", WinGetactive( ))
while 1
wbtdir = DirScript()
DirChange("%wbtdir%")
   TimeDelay(1)
   ;Run("localworker.bat","")
   run("cmd.exe","/c localworker.bat"); service needs to run this batch file
   RegSetValue(@REGMACHINE,"Software\Test\WinBatch Services[test1]","It Worked Guile");Note this line works for testing
;Display(5, "Current Time should be", a)
a=TimeYmdHms( )
b=TimeAdd(a,"0000:00:00:00:01:00") ; Adds seconds to current time
TimeWait(b) ; Waits for that time to occur
   ;RunIcon("localworker.bat","")   
   TimeDelay(1)
EndWhile
Return


Notes: Your help is appreciated as I'm struggling and I have read all suggestions presented so far but the only thing that works is the writing to the registry for a test,
Note: Testing on windows 10, servers 2012 R2,2016 and 2019
Note: The service also seems to stop working after writing to the registry I think?

I'm fully stumped, please help!!!

guile

Modified script here's new script with all the extenders included and error log

Note: Error Log
3052:  Uninitialized variable, undefined function, or unquoted string

if (procname)== procfilename

<HR>

10/21/20  10:21:05  WBT - BEI_Worker_Windows_Native_Service.exs

3052:  Uninitialized variable, undefined function, or unquoted string

if (procname)== procfilename

<HR>


Note: Modified Program:

AddExtender('wwctl44i.dll')
AddExtender('WWPRC44I.DLL')
;==========================================================================================
;Set Internal Controls          
;==========================================================================================
;IntControl(35,200,0,0,0) ;Amount of time to delay between each keypress 
;IntControl(45,0,0,0,0) ;Don't speed up SendKey in DOS programs in Windows NT
IntControl (65,51200,0,0,0) ;Expand maximum string length
;IntControl(74,1000,0,0,0) ;Set Idle Wait for run commands
KeyToggleSet (@CAPSLOCK,@OFF)

curdir=DirChange(DirScript())
;Initialze variables for the SvcSetAccept function
SERVICE_ACCEPT_STOP             =   1    ;The service can be stopped
SERVICE_ACCEPT_PAUSE_CONTINUE   =   2    ;The service can be paused and continued
SERVICE_ACCEPT_SHUTDOWN         =   4    ;The service is notified when system shutdown occurs
SERVICE_ACCEPT_HARDWAREPRFCHG   =   3    ;The computer's hardware profile has changed.
SERVICE_ACCEPT_POWEREVENT       =   64   ;The computer's power status has changed.
SERVICE_ACCEPT_SESSIONCHANGE    =   128  ;The computer's session status has changed (requires XP/2003 or newer.)
SERVICE_ACCEPT_PRESHUTDOWN      =   256  ;The computer is about to shutdown (requires Vista/2008 or newer.)
SERVICE_ACCEPT_LOGOFF           =   32768;The service is notified when user logoff occurs

;Initialize variables for the SvcSetState function
SERVICE_STATE_STOPPED           =   1   ;The service is not running
SERVICE_STATE_STOP_PENDING      =   3   ;The service is stopping
SERVICE_STATE_RUNNING           =   4   ;The service is running
SERVICE_STATE_CONTIN_PENDING  =   5   ;The service continue is pending
SERVICE_STATE_PAUSE_PENDING     =   6   ;The service pause is pending
SERVICE_STATE_PAUSED            =   7   ;The service is paused

;Initialize variables for the SvcWaitForCmd function
SERVICE_CONTROL_NOT_SERVICE     =  -1   ;Script not running as a service
SERVICE_CONTROL_TIMEOUT         =   0   ;Timeout occurred or no codes to process
SERVICE_CONTROL_STOP            =   1   ;Requests the service to stop
SERVICE_CONTROL_PAUSE           =   2   ;Requests the service to pause
SERVICE_CONTROL_CONTINUE        =   3   ;Requests the paused service to resume
SERVICE_CONTROL_SHUTDOWN        =   5   ;Requests the service to perform cleanup tasks, because the system is shutting down
SERVICE_CONTROL_HARDWAREPRFCHG  =   12  ;The computer's hardware profile has changed.
SERVICE_CONTROL_POWEREVENT      =   13  ;The power status has changed.
SERVICE_CONTROL_SESSIONCHANGE   =   14  ;The session status has changed (requires XP/2003 or newer.)
SERVICE_CONTROL_PRESHUTDOWN     =   15  ;The system will be shutting down (requires Vista/2008 or newer.)
SERVICE_CONTROL_USER128         = 128   ;User command 128
SERVICE_CONTROL_USER129         = 129   ;User command 129
SERVICE_CONTROL_USER130         = 130   ;User command 130
SERVICE_CONTROL_USER131         = 131   ;User command 131
;                                       ;More user commands as needed
SERVICE_CONTROL_USER255         = 255   ;User command 255
SERVICE_CONTROL_LOGOFF          = 32768 ;logoff notification

;Setup debugging prompt strings....
debugcodes="0: Timeout|1: Stop|2: Pause|3: Continue|5: Shutdown|128: User Cmd 128|129:User Cmd 129|32768: Logoff"

;Tell system that we want specific notifications
flag=SvcSetAccept( SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_LOGOFF)
If flag== -1
   DoingDebug=@TRUE
   ;Pause("Debug Mode","Not currently running as a service")
Else
   DoingDebug=@FALSE
   ;Set up error handling
   IntControl(12,2+8,0,0,0)                    ;Tell WinBatch to not honor terminate and
                                               ;not complain on Windows exit
   IntControl(38,1,"errorlog.txt",0,0) ;Route fatal errors to a log file
EndIf

;Now for the main service loop
;in this service we respond to all control messages
;and check an ini file for work every 5 seconds
;BoxOpen("Initializing","main service loop")
While @TRUE
   If DoingDebug==@FALSE
      code=SvcWaitForCmd(5000)      ; Timeout in 5 seconds
   Else
       ;For Debugging.  Prompt tester to see what code should be pretended here
       code=AskItemlist("Service Debug",debugcodes,"|",@UNSORTED,@SINGLE)
       If code=="" Then Continue
       code=ItemExtract(1,code,":")
   EndIf

   Switch code
          Case SERVICE_CONTROL_TIMEOUT
               ;Timeout occurred
               ;BoxTitle("SERVICE_CONTROL_TIMEOUT")
               ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
               GoSub DoWork
               ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
               Break
          Case SERVICE_CONTROL_STOP
               ;Stop command received
               ;BoxText("Stop command received")
               SvcSetState(SERVICE_STATE_STOP_PENDING)
               ;do stop cleanup work here
               TimeDelay(5)
               SvcSetState(SERVICE_STATE_STOPPED)
               Exit    ;Goodbye
               Break
          Case SERVICE_CONTROL_PAUSE
               ;Pause command received
               ;BoxText("Pause command received")
               SvcSetState(SERVICE_STATE_PAUSE_PENDING)
               ;do pause cleanup work here
               SvcSetState(SERVICE_STATE_PAUSED)
               Break
          Case SERVICE_CONTROL_CONTINUE
               ;Continue command received
               ;BoxText("Continue command received")
               SvcSetState(SERVICE_STATE_CONTIN_PENDING)
               ;do resume from pause state initilization here
               SvcSetState(SERVICE_STATE_RUNNING)
               Break
          Case SERVICE_CONTROL_SHUTDOWN
               ;Shutdown notification received
               ;Approx. 20 seconds to process
               ;BoxText("Shutdown notification received")
               SvcSetState(SERVICE_STATE_STOP_PENDING)
               ;do stop cleanup work here
               SvcSetState(SERVICE_STATE_STOPPED)
               Exit    ;Goodbye
               Break
          Case SERVICE_CONTROL_USER128
               ;User command 128 received
               ;BoxText("User command 128 received")
               Break
          Case SERVICE_CONTROL_USER129
               ;User command 129 received
               ;BoxText("User command 129 received")
               Break
          Case SERVICE_CONTROL_LOGOFF
               ;Logoff command received
               ;BoxText("Logoff command received")
               Break
         Case code
               ;Unrecognized command received
               ;BoxText("Unrecognized command received")
               Break
      EndSwitch

EndWhile

;Note.  The preceeding loop never exits
Exit   ; Just a formality

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;The DoWork subroutine can be used to execute the code you want to run while
;the service has not control requests
:DoWork
   ;BoxText("WinBatch Services test is running")
   RegSetValue(@REGMACHINE,"Software\Test\WinBatch Services[test1]","It Worked David")

      ;procfilename=("Scheduler_TEST_Worker")
   countProc=0
   count=tCountProc()
   proclist=tlistproc()
   For x = 1 to count
     item=ItemExtract(x,proclist,@Tab)
     procname=ItemExtract(1,item,"|")
     ;Display(10, "%procfilename% exists","Process Id is %procname%")
     ;if (procname)== procfilename
     ;procname=StrTrim(procname,3)
     ;Display(10, "%procfilename% exists","Process Id is %procname%")
      if (procname)== procfilename
      ;Message("Procname equals profilename", procname)
      ;TimeDelay (3)
           countProc = countProc + 1
      ; parse off process id
      procid=ItemExtract(2,item,"|")
      ;Message("Break", procid)
      ;Break
      ;TimeDelay (3)
      Else
      ;Display(10, "%procfilename% exists","Process Id is %procname%")
     endif
   Next
      ;Display(3, "Current window is", countProc)
         ;If countProc >= 1
         If countProc > 1
            ;Display(3, "Scheduler_TEST_Worker already running", countProc)
            ;Display(3, "      Scheduler_TEST_Worker ", "already running")
            TimeDelay (1)
            Exit
         Else
         TimeDelay (1)
         ;Display(3, "Else", WinGetactive( ))
Endif

;Run continuouly every 30 Min
;Display(2, "Run continuouly every 30 Min", WinGetactive( ))
while 1
wbtdir = DirScript()
DirChange("%wbtdir%")
   TimeDelay(1)
   ;Run("localworker.bat","")
   run("cmd.exe","/c localworker.bat"); service needs to run this batch file
   RegSetValue(@REGMACHINE,"Software\Test\WinBatch Services[test1]","It Worked David");Testing
;Display(5, "Current Time should be", a)
a=TimeYmdHms( )
b=TimeAdd(a,"0000:00:00:00:01:00") ; Adds seconds to current time
TimeWait(b) ; Waits for that time to occur
   ;RunIcon("localworker.bat","")   
   TimeDelay(1)
   IntControl(38,1,"errorlog.txt",0,0) ;Route fatal errors to a log file
EndWhile
Return

td

To debug your script use DebugTrace to create a trace file. Let the service run just long enough for or error to occur.  Otherwise, you will have a lot of lines to wade through.   

Yes, you can start applications from a service but the applications will not be running in a currently attached user session so the application cannot interact directly with a logged-on user.  There are several ways to get around this.  One is to use the wtsEnumSessions and wtsSendMessage functions from the terminal server extender to display a message to the active desktop - not very useful.   The other is to separately start a WinBatch program in an active user session that reads a file (like and ".ini" file) generated by the service. The file contains instructions that the other WinBatch application follows to perform a task.  Not very practical for what you are attempting to do.

Your goals might best be achieved by using a scheduled task instead of a service.  Unlike services scheduled tasks can be configured to interact with the user in the current user session. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

guile

Thanks but the issue is we cant use task scheduler anymore because of new security policy, so Im stuck trying to make it work with winbatch which I was hoping to be easy,

ChuckC

You should do some Google Searches for issues related to Windows Services and "Session Zero Isolation".

Prior to Windows Vista, the physical keyboard & mouse were associated with the console session #0, which is also the same session that native NT services run in.  On those older versions of Windows, you had the option of checking a box to enable a service to interact with the desktop.  This capability was considered to be a security risk.

To eliminate the security risk, terminal services is used so that even the physical console is, in fact, associated with a non-zero session number under terminal services.  This permits a complete separation of session #0 and all its associated native NT services from any/all user sessions that exist.

The Windows Task Schedule has always had a component that runs within a user session, even if the session is currently locked, and that was how it achieved running tasks as a specific user.  If the user session was locked, then any task being executed was subject to all of the restrictions associated with sending virtual keystrokes & mouse-move events to other applications in the locked session.

Now that you have mentioned that a change in security policy is preventing the usage of the task scheduler, it would be helpful if you explained what the actual problem is that you are trying to solve.  Not knowing what the problem domain is really makes it difficult to provide meaningful advice.

guile

Appreciate the knowledge and help, new security policy is no more task scheduler tasks as the task scheduler has been disabled on servers which I need to replace with a service that runs a specific .bat file or starts an executable that will initiate and run the .bat file, I'm spending a lot of time studying and testing but I'm not being very successful spinning my wheels

ChuckC

Does the "task" that was being started by the Task Scheduler have any actual dependency/requirement on being run in an interactive user session under a specific user account?


guile

Hi Chuck the only thing is for this program is to run a bat file every 15 minuets, it also checks for other instances of itself incase started manually wont have duplicates running,

ChuckC

Let's refine the requirement a bit further...

I'll re-ask my question about the .BAT file that needs to be executed every 15 minutes...   Is that .BAT file performing any actions that are dependent upon the user account that it runs as or upon having interactive desktop access?

Also, for whatever the .BAT file is doing, is it something that can be performed natively within WinBatch itself?  I don't know if the content of the .BAT file changes by being edited or overwritten between iterations of execution, or if its content remains constant.  However, if it does remain constant, is there is any reason to write a WinBatch script to execute the .BAT file if it's possible to simply write a WinBatch script to directly perform the work?

guile

Thanks Chuck,

The bat file needs to be executed every 15 minuets,

The code executed in the bat file
C:
cd \DD_Worker
echo "running local" > .\Logfile.txt

java -jar .\DD_worker.jar  >> .\LOGFILE.TXT 2>&1

Ive been trying to execute the java statement in different winbatch run combinations but no luck?

Maybe winbatch cant handle it or running as a service very well?

Im starting the think the latter,

guile

Hi Chuck,

I cant even get a batch file to kick off, Im thinking going winbatch route might be a waste of time?

ChuckC

Please provide a snippet of WinBatch code that shows how you are trying to launch the .BAT file from your script.  It is very likely that you don't have the command syntax correct for launching an instance of CMD.EXE that has been instructed to execute the .BAT file.

Think of things like this:  The Task Scheduler was creating a process running CMD.EXE, at timed intervals, and passing it parameters to execute the .BAT file.  Now that you want to have a compiled WinBatch script running as a native NT service taking the place of the Task Scheduler, your script has to replicate the same 2-step operation of running CMD.EXE in a child process and giving it the necessary parameters to execute the .BAT file.


td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade