0

I am attempting to start recording the screen using Camtasia however am triggering this using a batch file.

As i need the recordings to be 30 seconds long, i have a secondary batch file. It doesn't work as intended as i would like to avoid multiple windows executing the commands opening. I know the command taskkill isn't correct and have included it to illustrate what i am intending to achieve.

The batch files need to be able to run on both Windows 7 and Windows 8 devices.

The process is started with a starting batch file that launches the secondary batch file to commence the countdown.

StartFile.bat

start EndFile.bat
"C:\Program Files\TechSmith\Camtasia Studio 8\CamRecorder.exe" /record 

EndFile.bat

timeout /T 30 /NOBREAK
"C:\Program Files\TechSmith\Camtasia Studio 8\CamRecorder.exe" /stop
timeout /T 30 /NOBREAK
taskkill /f /im StartFile.bat <-- To kill the first batch file so there aren't multiple windows
start StartFile.bat <-- To create a new instance of the starting batch file.
exit
PeanutsMonkey
  • 6,919
  • 23
  • 73
  • 103

1 Answers1

2

Just do it all in a single batch file with a GOTO loop (edited to take account of the discussion in the comments; the start is only needed because starting recording doesn't return control):

:startofloop
start "" "C:\Program Files\TechSmith\Camtasia Studio 8\CamRecorder.exe" /record
timeout /T 30 /NOBREAK
"C:\Program Files\TechSmith\Camtasia Studio 8\CamRecorder.exe" /stop
timeout /T 30 /NOBREAK
goto startofloop
Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
  • That won't work as `"C:\Program Files\TechSmith\Camtasia Studio 8\CamRecorder.exe" /record timeout /T 30 /NOBREAK` doesn't kick in as the recording is perpetual until the command `"C:\Program Files\TechSmith\Camtasia Studio 8\CamRecorder.exe" /stop` is called. – PeanutsMonkey May 26 '14 at 22:03
  • You mean that calling `CamRecorder.exe` ties up the command prompt until the process is stopped instead of opening the recorder and returning straight away? – Matthew Strawbridge May 27 '14 at 11:26
  • Does it work if you do `start "C:\Program Files\TechSmith\Camtasia Studio 8\CamRecorder.exe" /record` as the second line instead? – Matthew Strawbridge May 27 '14 at 19:04
  • Does it work if you begin the second line of my version of the batch file with the word `start`? – Matthew Strawbridge May 28 '14 at 05:56
  • No it doesn't. The error i get is that /record is an invalid switch – PeanutsMonkey May 28 '14 at 06:57
  • Try adding some an empty `""` as well after the `start`, as explained here: http://stackoverflow.com/questions/154075/using-the-dos-start-command-with-parameters-passed-to-the-started-program – Matthew Strawbridge May 28 '14 at 18:44