E
E
Eugene2013-06-07 17:53:10
cmd/bat
Eugene, 2013-06-07 17:53:10

How to win a batch file?

Colleagues, good day!
Faced such a problem. There is 1C from which thinapp is made. There are several user groups, each of which should see its own list of databases without manually adding these databases. Recently on Habré there was an article on a similar topic (here) .
The 1C admin wants to have several files with the V8I extension, where the bases visible to certain users will be registered. Accordingly, to do this, you need to put the 1CEStart.cfg file inside the sandbox, which will contain a link to one or another V8I file.
If you do everything manually, everything is fine, everything works. But when I try to write a batch file, I encounter the following problem: you need to put the file in the %userprofile%\AppData\Roaming\Thinstall\1C\%AppData%\1C\1CEStart folder. But as you can see, the %AppData% part of the path matches the same system variable. As a result, it was possible to ensure that the copy command

xcopy g:\ibases_test.v8i %userprofile%\AppData\Roaming\Thinstall\1C\"%"AppData"%"\1C\1CEStart /Y
, launched from the command line, works fine (percentage signs are in quotes), but the same line written to the bat file does not work and the "%" AppData "%" part is eaten, and I see a lot of cyclical questions about what I copy , file or folder?
I tried to save the file using different encodings, but it did not help. If anyone met with a similar one, tell me, please, in which direction should I dig? How to write a batch file so that the %AppData% part of the path is not perceived as a system variable?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Beresnev, 2013-06-07
@Evgenym

You can try %%AppData%%

0
074909, 2013-07-21
@074909

Yes, there is such a variable.
You should have just used an escape: the "^" symbol.

(COMPUTER\user) C:\Users\user\
>echo %appdata%
C:\Users\user\AppData\Roaming
(COMPUTER\user) C:\Users\user\
>echo ^%appdata^%
%appdata%

duckduckgo.com/?q=bat+OR+cmd+escaping

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question