Newbie - checkout Batch file works, Powershell version does not - why?

50 views
Skip to first unread message

Neil Peers

unread,
Dec 27, 2023, 11:57:27 AM12/27/23
to TortoiseSVN
First venture in to using Windows Powershell having used batch files todate and I am trying to write a script to checkout repositories into a new location.
The original script using Windows batch files works ok but the same thing in a Powershell does not. I should point out that I am a hardware engineer and not a software engineer

Batch file command 
Tortoiseproc.exe /command:checkout /path:"C:\MEDC2\Projects\APEC\APEC000_Admin"                /url:"file:///R:/ProjectsSVN/APECsvn/APEC000_AdminSVN"   /closeonend:2  
works as expected.
If however, I try that exact same command in a Powershell script, it doesn't work with a "Unable to connect to a repository at URL..." message. 
The R drive is a drive on the network.

The target folder is created 

How come the batch file works, but not the powershell?
Is there anything I can do about it or should I do something different - and if so what please? 

Many thanks


Stefan

unread,
Dec 27, 2023, 12:49:11 PM12/27/23
to TortoiseSVN
Create the registry DWORD value HKCU\Software\TortoiseSVN\Debug and set its value to 1.
Then TSVN will show you the command line that was passed to it on every start.
This might help you debug the problem. 

Neil Peers

unread,
Dec 28, 2023, 6:15:29 AM12/28/23
to TortoiseSVN
Thank you for the suggestion. 
The solution, I discovered, is to NOT run Powershell in administrator mode. 

I'll leave the "why" to people who really know what they are talking about with Powershell.

Daniel Sahlberg

unread,
Dec 28, 2023, 9:59:53 AM12/28/23
to TortoiseSVN
torsdag 28 december 2023 kl. 12:15:29 UTC+1 skrev ne...@medina-electronics.co.uk:
Thank you for the suggestion. 
The solution, I discovered, is to NOT run Powershell in administrator mode. 

I'll leave the "why" to people who really know what they are talking about with Powershell.

I've replicated your setup and I get the same results.

For me, mapped network drives are not available within an elevated process (same with both PowerShell and CMD.exe). the command net use return differently from powershell running as a regular user and elevated (administrator mode): I can only see the  mapped network drive as a regular user. As administrator, I don't have any mapped drives. The same happens with a regular CMD.exe as well, I don't see the mapped drives in an elevated process.

There are two ways to solve this:
* Map the drive as part of the script.
* Use a UNC path to the repository: /url:"file:////server/share/path/to/repository"

Kind regards,
Daniel

David Balažic

unread,
Jan 8, 2024, 1:16:23 PM1/8/24
to TortoiseSVN
Maybe this is one more reason to not have a repository on a network share?



Reply all
Reply to author
Forward
0 new messages