I copied the batch function MakeAbsolute https://www.dostips.com/DtCodeCmdLib.php#MakeAbsolute and stored it in file MakeAbsolute-Original.cmd.
I called it from Test-Original.cmd containing the following code:
Code: Select all
set "testFilename=def.txt"
call MakeAbsolute-Original.cmd testFilename "C:\Program Files (x86)\Microsoft Visual Studio"
When running I get the output:
Code: Select all
C:\xxx>Test-Original.cmd
C:\xxx>set "testFilename=def.txt"
C:\xxx>call MakeAbsolute-Original.cmd testFilename "C:\Program Files (x86)\Microsoft Visual Studio"
C:\xxx>SETLOCAL ENABLEDELAYEDEXPANSION
C:\xxx>set "src=testFilename"
C:\xxx>if defined testFilename set "src=!testFilename!"
C:\xxx>set "bas=C:\Program Files (x86)\Microsoft Visual Studio"
C:\xxx>if not defined bas set "bas=C:\xxx"
C:\xxx>for /F "tokens=*" %a in ("C:\Program Files (x86)\Microsoft Visual Studio.\def.txt") do set "src=%~fa"
C:\xxx>set "src=C:\Program Files (x86)\Microsoft Visual Studio\def.txt"
"\Microsoft" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
C:\xxx> IF defined testFilename (SET testFilename=C:\Program Files (x86)\Microsoft Visual Studio\def.txt) ELSE ECHO.C:\Program Files (x86)\Microsoft Visual Studio\def.txt
C:\xxx>
My system environment is:
Code: Select all
Windows version: Microsoft Windows [Version 10.0.19044.1586]
Product name: Windows 10 Pro
Processor arch: AMD64 and 64 bit Windows
Date format: dd/mm/yy = 04.04.2022
Time format: 24 hours = 3:24:09,29
Extensions: system:Enabled user:Enabled
Delayed expansion: system:Disabled user:Disabled
Locale name: de-DE Code Pages: OEM 850 ANSI 1252
DIR format: 31.03.2022 15:42 8.589.934.592 pagefile.sys
Do you have any ideas?
Kind Regards
Thomas