Z
Z
ZenCast2021-07-08 22:56:55
cmd/bat
ZenCast, 2021-07-08 22:56:55

How to specify the path to your folder?

You need to install the program via .bat with add. parameters, you must run it as an administrator, for some reason, when you double-click on the batch file, installation does not occur.
The problem is the following, when you run the batch file on behalf of the admin, you must specify the full path to the .msi installation file, and since. installation will take place on many computers, then the path to the file will no longer be relevant.
Is it possible to somehow make it so that when the batch file is launched, it refers to the folder where the launch comes from, as it happens during normal startup (not on behalf of the administrator).
60e75862c0438990796099.png
60e758f560ff7708314327.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
wisgest, 2021-07-08
@ZenCast

%0\..\TeamViewer_Host.msi(it seems that it may not work in internal subroutines called by the command call :метка); %0should not be enclosed in quotes, since it may already contain them (but on the other hand, there may be undesirable consequences if it contains special characters outside the quotes ...), but you can use quotes in the rest of the path: %0\..\"TeamViewer Host.msi".
Or "%~dp0\TeamViewer_Host.msi"(extended command processing must be enabled, which is usually the default).

R
res2001, 2021-07-09
@res2001

See description of modifiers in for /? (modifiers are the letters that come after %~). They are described there for the loop variable, but modifiers work in the same way with batch file parameters, i.e. with variables of the form The name of the running batch file is stored in the variable , respectively, by applying modifiers, you can get only the path to the batch file from this variable:%0, %1, %2, ...
%0%~dp0

Z
Zzzz9, 2021-07-09
@Zzzz9

Is it possible to somehow make it so that when the batch file is launched, it refers to the folder where the launch comes from,

cd %cd%

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question