Question: Executing a simple unit test over a Mongo Repository fails in Windows 10 due to

> 
> java.io.IOException: Cannot run program
> "C:\Users\myuser\AppData\Local\Temp\extract-88ea18ed-75d4-420f-be7f-623baeeb5c70extractmongod.exe":
> CreateProcess error=1260, This program is blocked by group policy. For
> more information, contact your system administrator
> 
> 
> 

This had worked until a few days ago, but failing now probably due to some recent Windows update.

Example of a failing test

```
@ExtendWith(SpringExtension.class)
@DataMongoTest
@AutoConfigureDataJpa
@AutoConfigureTestDatabase
@ExtendWith(LogbackSuppressorExtension.class)
@Import(TestConfiguration.class)
class AnnexContentRepositoryTest {
  @Autowired
  private MongoTemplate mongoTemplate;
  @Autowired
  private AnnexContentRepository annexContentRepository;

  @Test
  public void findAllByParentCodeAndParentType() {
    AnnexContent annexContent = addAnnexContent();
    Page<AnnexContent> annexContentResult = annexContentRepository
        .findAllByParentCodeAndParentType(annexContent.getParentCode(), ParentType.THE_ONE,
            Pageable.unpaged());

    Assertions.assertEquals(1, annexContentResult.getTotalElements());
  }

  private AnnexContent addAnnexContent() {
    AnnexContent annexContent = AnnexContentBuilder.buildDefault();

    return mongoTemplate.save(annexContent);
  }
}

```

Answer: 
The solution that I've found is to add two system variables that embedded mongo reads ("*de.flapdoodle.embed.io.tmpdir*" and "*EMBEDDED\_MONGO\_ARTIFACTS*") in test configuration (the same applies in running the application with embedded mongo, where these two system variables can be set also).

```
@Configuration
public class TestConfiguration {

  public TestConfiguration(Environment environment) {

    if (SystemUtils.IS_OS_WINDOWS) {
      System.setProperty("de.flapdoodle.embed.io.tmpdir", environment.getProperty("mongo-embedded.windows.temp-dir"));
      System.setProperty("EMBEDDED_MONGO_ARTIFACTS", environment.getProperty("mongo-embedded.windows.temp-dir"));
    }
  }
}

```

By changing the location from the embedded mongo default ("c:\myuser\appdata\local\temp") to, for example, "c:\temp", the problem disappears.
Pringi's solution works. Here it is, simplified with an actual Windows path in c:\temp\mongotemp

First manually create directory c:\temp\mongotemp

Add a new MongoConfig.java file:

```
import org.apache.commons.lang3.SystemUtils;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MongoConfig {

    public MongoConfig() {

        if (SystemUtils.IS_OS_WINDOWS) {
            System.setProperty("de.flapdoodle.embed.io.tmpdir", "c:\\temp\\mongotemp");
        }
    }
}

```

App should run now.

You can then inspect the contents of c:\temp\mongotemp , it's the executable that was previously being blocked by the system policy.

[![enter image description here](https://i.stack.imgur.com/bOYI6.png)](https://i.stack.imgur.com/bOYI6.png)