0

I an attempting to write a bat file that will find a path variable, or at the very least, find all path variables. I want to be able to find where ImageMagick is stored so that I can run it using a pascal script in xEdit for skyrim, currently I have this:

@ECHO off

IF "%PATH%" == "Magick.exe" GOTO NOPATH
:YESPATH
PATH=%PATH%
@ECHO %PATH%
GOTO END
:NOPATH
@ECHO false
PATH=C:\DOS;
GOTO END
:END
echo. > ygg.new
for /F "delims=\= tokens=1,2" %%k in (Ygg.ini) do (
    if "%%k" NEQ "MagickPath" GOTO P1
)

:P2
    >>ygg.new echo %%k=%PATH%
    GOTO SECONDEND
:P1
    >>ygg.new echo %%k=%%L
    GOTO SECONDEND
:SECONDEND
del Ygg.ini
ren ygg.new Ygg.ini

this bat will only export if ygg.ini exists, and will output %k=<path> instead of what I want, which is MagickPath=<path>. I would like to be able to automatically create the file if it doesnt exist, as well as the section it should be in (BaseData).

I have a repository set up here: https://github.com/yggdrasil75/Ygg-Scripts/blob/master/YggLoadScreens.pas which shows the full code of the pascal script that will be executing the bat file.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Yggdrasil75
  • 115
  • 7
  • You could try quering the registry instead using `reg query`. Many programs store their installation path in a registry key in `HKLM\Software\{program_name}` and this key name is normally consistant across versions and machines. Alternativly, the program may store it as part on an Uninstall string in `HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{program_name}` the key may also be a GUID rather than the program name. – Durry42 Mar 13 '20 at 05:35
  • 2
    Also, you cannot use the name `PATH` as a variable in your script as it is a reserved name by the system (In a command prompt type `set` then press enter to see all the reserved/system variable names that cannot be used). Instead you something like `set progPath=` – Durry42 Mar 13 '20 at 05:43
  • Do not use the variable name `PATH` as it is used by the system to provide a list of paths to find executables! However, if you *are* actually trying to find a certain path in the semicolon-separated list in the system-reserved variable `PATH`, then take a look at [this thread](https://stackoverflow.com/q/5471556)... – aschipfl Mar 13 '20 at 09:27

0 Answers0