Question: I have a batch file and I want to call a powershell script that returns several values to the batch file. 

I've tried to do it by setting environment variables, but that does not work.

This is the batch file:

```
::C:\temp\TestPScall.bat
@echo off
powershell -executionpolicy Bypass -file "c:\temp\PStest.ps1"
@echo [%psreturncode%]
@echo [%uservar%]
@echo [%processvar%]

```

This is the powershell script:

```
# c:\temp\PStest.ps1
$env:psreturncode = "9990"
[Environment]::SetEnvironmentVariable("UserVar", "Test value.", "User")
[Environment]::SetEnvironmentVariable("ProcessVar", "Test value.", "Process")

```

WHen I run it, the environment variables are not populated.

How can I get this to work?

Answer: 
You don't need an else on the statement. check to see if your variable is false and if it is it will return if not the rest of your function will run automatically.

```
function function1() {
function2(); // call function2
// after called function (here I need true or false, to decide if the function should stop or continue)
}

function function2() {
if (condition === false) {
    return;
} 

```

}
```
const function1 = check => {
   if (check === false) {
     return;
   } else {
   console.log("back from function2");
 }
};

function1(false) // console.log doesn't run
function1(true) // console.log runs

```

make sure that you pass in a Boolean value.