WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mtruong1 on November 18, 2013, 03:32:18 PM

Title: window environment variable
Post by: mtruong1 on November 18, 2013, 03:32:18 PM
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
Title: Re: window environment variable
Post by: George Vagenas on November 18, 2013, 10:14:04 PM
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.
Title: Re: window environment variable
Post by: mtruong1 on November 19, 2013, 07:56:25 AM
Thank you, George.  That work.