Question: I'm having a hard time trying to save the output of the following command, which gets me the name of the OS to a variable.

```
systeminfo | findstr /B /C:"OS Name" 

```

I tried using a for loop as shown below but then the value of the variable is `OS`

```
for /f %%i in ('systeminfo ^| findstr /B /C:"OS Name" ') do set vard=%%i
echo the operating system name 2 is %vard%

```

Can someone please help me out with this ? 
I took a look at other approaches such as writing the output to a temporary file and then reading it back later on but I'd like to achieve this without resorting to using temporary files

Answer: 
This may not be the actual answer but it may helps you to find out the way of achieving what you want:

```
onSubmitInvoiceData = () => {
const { files } = this.state;
    if(files.length < 1) this.setState({ isLoading: false, errors: {...this.state.errors, general: ['Gelieve minstens één factuur te uploaden']} });
        else {
        const promises = [];

        Promise.all(
            files.map(file => {
                return new Promise((resolve,reject)=>{

                    const uploadTask = Storage.ref(`session-123/files/${file.name}`).put(file);
                    promises.push(uploadTask);

                    uploadTask.on('state_changed', snapshot => {
                        const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
                    }, error => { console.log(error) }, () => {
                        uploadTask.snapshot.ref.getDownloadURL().then(downloadURL => {
                            console.log('url: ', downloadURL);
                            return resolve ({id: file.id, name: file.name, url: downloadURL});
                        });
                    });

                })
            })
        ).then(filesArr=>{
            Promise.all(promises).then(tasks => {
                console.log('tasks: ', tasks);
                Database.ref(`sessions/123`).update({
                    lastUpdate: Firebase.database.ServerValue.TIMESTAMP,
                    files: filesArr
                }).then(() => this.setState({ isLoading: false }))
            });
        })
    }    
}

```

I replaced your `forEach` function with `map` which can returns a promise. and put it inside a `Promise.all` so after they all got their `filesArr`, you will continue to next part.

The way you treated with `async/await` in your code is not correct. while `await` actually waiting for a promise to resolve, you have no `Promise.resolve`, and you are using `await` and `.then()` together which i can't understand why! 
check this:
 `let downloadURL = await uploadTask.snapshot.ref.getDownloadURL();`
OR
 `uploadTask.snapshot.ref.getDownloadURL().then(downloadURL=>...)`

I hope this can help you.
I think you will just need reduce with promise as follows 

```
  files.reduce((promiseChain, item, index) => {
    return promiseChain.then(() => new Promise((resolve) => {
      //here item is one of the items in files array.
      this.myFunction(item, resolve);
    }));
  }, Promise.resolve()).then((tasks) => {
    //tasks
  });

```

Callback function which resolves current request.

```
 myFunction(item, resolve) {
        setTimeout(() => {
          //do something with item, alongside send resolve when it is finished.
          resolve(item);
        }, 100);
    }

```