window environment variable

Started by mtruong1, November 18, 2013, 03:32:18 PM

Previous topic - Next topic

mtruong1

In Windows, I defined the environment variable as such
variable name = hook
variable value = c:\service\partition

Then, I put a txt file (ie, test.txt) under c:\service\partition directory
I opened a dos prompt and typed "copy %hook%\test.txt c:\" and this command would copy the test.txt to the C:\ drive

can I do the same in Winbatch??

In another words, if I write

filecopy(%hook%\test.txt, c:\, @FALSE) ; would this command copy the test.txt file onto the C:\ drive??



thanks

George Vagenas

You have to retrieve the value from the environment.
Code (winbatch) Select
Hook = environment("hook")
then your sample code would work.

Be aware that substitution has a limit as to the size of string it can handle, 2048, I think.  Lots of lovely traps waiting but you should check out substitution, you can do things that are nearly impossible to do without it.  WinBatch wouldn't be WinBatch without it IMHO.
Thanks

George

mtruong1