# Run cmake with batch file and double click

**URL:** https://discourse.cmake.org/t/run-cmake-with-batch-file-and-double-click/5430
**Category:** Usage
**Tags:** os:windows
**Created:** [April 11, 2022, 9:34am UTC](https://discourse.cmake.org/t/run-cmake-with-batch-file-and-double-click/5430 "2022-04-11T09:34:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [April 11, 2022, 9:34am UTC](https://discourse.cmake.org/t/run-cmake-with-batch-file-and-double-click/5430/1 "2022-04-11T09:34:24Z")

</div>

I write a batch file to install lib.  
If I run it `install.bat` on command prompt. It can generate the release folder.

But I try to double click the install.bat. It will not generate the release folder.

Here is this install.bat batch file

```auto
cmake -G "Visual Studio 16 2019" ^
		-S ./ ^
		-B ./build-release ^
		-DCMAKE_BUILD_TYPE=release ^
cmake --build build-release --config release
cmake --install build-release --config release --prefix ../release

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 12, 2022, 12:01pm UTC](https://discourse.cmake.org/t/run-cmake-with-batch-file-and-double-click/5430/2 "2022-04-12T12:01:05Z")

</div>

Double clicking doesn’t really have a current working directory defined AFAIK. I recommend adding a `cd` to the right directory in there.

---

<div class="post-metadata">

### Author: ![alice](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alice/32/1615_2.png) [@alice](https://discourse.cmake.org/u/alice)
#### Post date: [April 13, 2022, 5:56am UTC](https://discourse.cmake.org/t/run-cmake-with-batch-file-and-double-click/5430/3 "2022-04-13T05:56:33Z")

</div>

Sorry, I don’t know how to use cd on this sample.  
Because I use --prefix to assign the install path.

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [April 13, 2022, 5:33pm UTC](https://discourse.cmake.org/t/run-cmake-with-batch-file-and-double-click/5430/4 "2022-04-13T17:33:30Z")

</div>

Use this at the beginning of your batch:  
`PUSHD %~dp0`

---

<div class="post-metadata">

### Author: ![JRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@JRR](https://discourse.cmake.org/u/JRR)
#### Post date: [April 14, 2022, 10:27pm UTC](https://discourse.cmake.org/t/run-cmake-with-batch-file-and-double-click/5430/5 "2022-04-14T22:27:19Z")

</div>

Also consider adding a

```auto
pause

```

call at the end of the script so that the windows stays open so you can see any errors that may occur (or revel in your success!)
