0

The below code, for some reasons, is not working. I'm kinda new to this Windows Batch area and don't have any clue why this is not working. Sounds pretty simple and correct to me but something has gone wrong. Can you please help me? I'm running it on a Windows 10 machine.

@echo off

setlocal enabledelayedexpansion

SET pathOfFileName1 = C:\test\Dump_1_333398395823532298.zip
echo %pathOfFileName1%

PowerShell Expand-Archive "%pathOfFileName1%" "C:\test\unzip"

The pathOfFileName1 is not getting printed and the PowerShell stuff is not working when used with the variable 'pathOfFileName1'.

Powershell stuff is working when both parameters are used without any variables. echo is working when the value is directly given (instead of the variable)

Appreciate your inputs.

Thanks

MC ND
  • 69,615
  • 8
  • 84
  • 126
user1654044
  • 73
  • 1
  • 8

1 Answers1

0
SET pathOfFileName1 = C:\test\Dump_1_333398395823532298.zip

This line is actually setting an enviornment variable called "pathOfFileName1 ". Note the space after the variable name.

You probably want to use this instead

SET pathOfFileName1=C:\test\Dump_1_333398395823532298.zip

The lack of spaces before or after the equals sign are important. You don't want a space at the end of the variable name, or a space at the start of the string.

Anon Coward
  • 9,784
  • 3
  • 26
  • 37