0

I have following batch:

subst D: /d
subst D: C:\folder\folder2
pause

And it works fine.

So I tried something different:

set p2=folder2
set p1=C:\folder\%p2%

subst D: /d
subst D: %p1%  
pause

Although when run in console they both look exactly the same, the second version results in error:

subst is not found as internal or external command

Any ideas?

Piotrek
  • 169
  • 3
  • 17
  • Should work. I just did this the other day in a batch file I posted on SO. http://stackoverflow.com/questions/40247379/batch-parsing-out-file-path-from-dynamic-array/40248534#40248534 – Squashman Oct 27 '16 at 15:00
  • 2
    Did you have more code in the batch file? If you manipulated the PATH variable it will not find `subst.exe`. – Squashman Oct 27 '16 at 15:08
  • @Squashman This is a whole file. So `p1` is not manipulated unless creating it using another variable may be considered a manipulation. – Piotrek Oct 28 '16 at 05:24
  • Squashman isn't talking about `%p1%`or `%p2%`, but about the `%path%` system variable. – Stephan Oct 28 '16 at 06:34
  • @Stephan I've just open SO to write this. I was silly enough to try to use `path` as variable name... – Piotrek Oct 28 '16 at 07:27

1 Answers1

0

Problem solved - in fact has never existed. In genuine file I tried to use path as variable name instead of p1. Kind of bad idea in batch...

Piotrek
  • 169
  • 3
  • 17
  • 1
    Yes. Unless you know what you are doing. Also, obfuscating your code examples is an extremely bad idea when you have no idea what you are doing. As you can see in your example it covered up the real problem with your code. – Squashman Oct 28 '16 at 12:44