TortoiseSVN Hook Scripts No Longer Run - windows

A while a go we set up a post_commit hook script in TortoiseSVN, this is a simple batch file, and this worked fine. We are running Windows 10.
Recently (around the beginning of 2023) this stopped working. TortoiseSVN now reports:
The hook script returned an error:
The process cannot access the file because it is being used by another process.
The script executes fine when run manually.
Changing the script to execute to another batch file or a program, results in the same message.
Does anyone have any suggestions?
Thanks,
Chris
Edit:
The hook script is client side and is configured as:
Working Copy Path:
C:\Temp\Repo
Command Line To Execute:
C:\Users\chris\SVNFeeder\testrepo_sync.bat
Wait for script to finish: True
Hide the script while running: False
Always execute the script: True
The batch file contains the following:
java -jar %USERPROFILE%/SVNFeeder/SvnFeeder.jar -c %USERPROFILE%/SVNFeeder/testrepo_configFile
The java file updates our Jira server with commit messages.
Changing the command line to execute the java file directly results in the same error, even a simple batch file that only creates a folder doesn't execute.
There is nothing wrong with the batch file or the java file as both execute fine outside of TSVN.

I have just found out that Sophos was blocking the execution of the script.
There was no mention of this in the events page, which didn't help track it down.

Related

Execute WIndows bat file in Jenkins

I am using Jenkins 2.46.1
I have a build pipeline plugin installed and I want to execute a Windows batch file in it. The batch file should execute in a new command window and not on jenkins console output. I give the below Jenkins pipeline groovy script:
node {
stage 'Init'
bat '''
call C:\\myprj\\mybat.bat stop
EXIT /B 0
'''
stage 'Deploy'
bat '''call C:\\myprj\\mybat.bat'''
}
In the init stage, I want to kill the process if it is already open and in stage deploy it should open a new command window and run my batch file.
The problem is that the above does not work. The build is succesful but no command window opens up. Pls suggest
Technically, to do what you're asking you should be able to run
bat 'start cmd.exe /c C:\\myprj\\mybat.bat'
This will launch a new command windows (cmd.exe) and run the batch file given. Depending how your Jenkins slave is running you may not see anything. (eg if it's running as a windows service or different user, you won't see anything)
Alternative solution if the agent is running in a service and you would like to get output:
bat(readFile("mybat.bat"))
Note: The bat file will need to be in your workspace.
Additional Note: You are no longer running the bat file from its original location. Instead it is being run from a temp location created by the underlying durable task system. This means things like %~dp0 in your script are not going to return the paths you might expect.

run curl from windows task scheduler automatically

I have a simple one line bat file that runs a curl localhost:port. My curl.exe is in the same folder as the bat I don't have it installed globally. It runs fine if I double click it, it also runs fine if I right click in task scheduler and select run task. It also says it completes the "scheduled tasks" successfully but nothing happens (I'm sure of this as I'm checking data that should update if the script is run, and it doesn't happen under the scheduled/automatic scenarios). After reading lots of users issues I tried configuring in two ways (all on 5 minute updates):
Common Way
Action: Start a Program
Program/script: C:\p\updater.bat
Start in: C:\p\
Other Way
Action: Start a Program
Program/script: cmd
Add arguments: /c start "" "C:\p\updater.bat"
I have set permissions to the bat and the containing folder to allow all for all users/etc. Neither work when automatically triggered, neither error. I've tried in Server 2008 and Windows 10 (my OS) mode. Both work if I right click run task, neither automatically, any ideas?
Default working directory for scheduled script is %Windows%\system32. Try to add in first line to you updater.bat:
cd c:\p\
For diagnostic, you can add output redirect to you commands in bat file:
echo Script Started >> c:\p\log.txt
curl SomeCommand SomeCommand >>c:\p:\curloutput.txt
echo Script Ended >> c:\p\log.txt
and check files log.txt and curloutput.txt after execution of your script

SVN update using windows task scheduler not working

I want to setup a windows cron job to update svn. I created a batch file with this step:
START TortoiseProc.exe /command:update /path:"C:\svn" /closeonend:0
and setup the task scheduler to run this daily. This svn requires a password which I want to enter each time rather than cache it. The batch file works as expected without any issues.
The task scheduler shows that the job was successfully executed. However, I don't get the GUI to enter the password, neither does the directory get updated. Also, when I tried to manually update the svn directory thereafter, it says that svn is locked.
Why is task scheduler reporting successful?
Why is svn getting locked?
Task scheduler reports success because START seems to return exit code 0. START only starts an application and exits. It doesn't wait until the started application has exited. The task scheduler never sees the exit code of TortoiseProc this way.
You can do this with START WAIT. Enter START /? in a CMD for more information.
You can also do this with CMD /K itself. Enter CMD /? in a CMD for more information.
But I don't think you need START or CMD at all. You can either run TortoiseProc directly or call it via a batch script. In the batch script you can add more debugging like echos and redirected output in files to see what happens.
Do not use TortoiseProc.exe for this task! Use Subversion command-line client (svn.exe). Read the docs:
Remember that TortoiseSVN is a GUI client, and this automation guide
shows you how to make the TortoiseSVN dialogs appear to collect user
input. If you want to write a script which requires no input, you
should use the official Subversion command line client instead.

Batch file is not running through Windows 7 Task Scheduler

I have a batch file that executes a php script which fetches files(pdfs) from the backend and saves locally. I have tried executing the batch file through command prompt and it works perfectly.
But when I setup a Windows Task Scheduler to run this batch, it is not working. The command prompt window pop ups and displays alot of unreadable characters and hangs there.
I have also chosen the option for the bat to run with highest privileges but no difference.
Any idea what's wrong?
My mistake. Managed to solve it. The path to php was not set properly.
Now it is fine.

How to prevent batch file (.bat) from closing terminal when running commands?

On a Windows 7 machine if I run a PHPUnit Selenium command like this manually in the terminal:
phpunit --verbose --log-junit _selenium_tests\results\home.xml _selenium_tests\frontend\home.php
It spawns a browser and runs the test just fine. Then it outputs the following on the screen:
Time: 10 seconds, Memory: 3.50Mb
OK (1 test, 3 assertions)
And the terminal stays open.
Now if I copy and paste the exact command in an empty file and save it as test.bat and click it, it also runs the test. I can see the browser open and all tests run. Only problem is it closes the terminal prompt right after. So I can't see the above output.
An even bigger problem is, since it closes the terminal if I add more commands for other tests after that initial one they don't run.
I tried adding:
pause
at the end of the bat file but no luck, it still closes. Any idea how to prevent this and be able to run one command after another without the terminal ever closing?
Your question is similar to this one. Try using call in front of your command. If you run a .bat file from another .bat file and don't use call, control doesn't return to the first batch file, so pause doesn't get executed.
Try cmd /K phpunit --verbose --log-junit _selenium_tests\results\home.xml _selenium_tests\frontend\home.php
The /K option in cmd /K string Carries out the command specified by string but remains,see http://www.computerhope.com/cmd.htm
Also, I don't know the file type of the phpunit command you execute - I'm not familiar with selenium. If it is batch file (i.e. ends with .bat), you just can't call them from another batch file: everything below the call to the second batch file will never get executed.
You then need to use the CALL command. CALL Enables a user to execute a batch file from within another batch file, see http://www.computerhope.com/call.htm

Resources