Ollama Control is a suite of lightweight and robust Windows batch scripts designed to manage, monitor, and automate the local Ollama LLM server and application.
Ollama is a popular tool for running Large Language Models locally. However, its implementation on Windows presents several challenges that these scripts are designed to solve:
- Persistent Memory Consumption (VRAM/RAM): Once launched, Ollama keeps models loaded in your GPU VRAM or system RAM. This can severely degrade system performance when playing video games, rendering 3D graphics, or running other memory-intensive tasks.
- Hidden Background Processes: Ollama runs both as a GUI tray application and a background server process. Closing the GUI does not always release the background server or free the active model from memory.
- API Port Binding Issues: Sometimes Ollama's API port (11434) remains bound by zombie processes, preventing new instances from launching properly.
- Hardcoded User Paths: Standard startup shortcuts often rely on fixed user directories, making them break when shared or moved between different Windows users.
This project addresses these issues by providing one-click scripts to gracefully start, completely stop (reclaiming all VRAM/RAM), check the status of, and update/restart Ollama.
Ensure Ollama is installed on your Windows machine before running these scripts:
- Download the Windows installer from the official website: https://ollama.com/download/windows
- Run the OllamaSetup.exe installer.
- Verify the installation by running
ollama --versionin your command prompt.
- No Emojis or Bloat: Clean, text-based terminal outputs.
- Dynamic Path Detection: Automatically resolves directories using environment variables such as %LocalAppData%, %ProgramFiles%, and %USERPROFILE%.
- Complete Resource Cleanup: Forcefully terminates all related Ollama tasks and releases port 11434, ensuring your GPU memory is completely freed.
- Port-Aware Startup: Checks if the port is active before launching the CLI or GUI, preventing duplicate instance conflicts.
start-ollama.bat: Detects if the CLI is in the system PATH, verifies if the API server is active on port 11434 (starts it if not), launches the system tray application, and opens the status page in your default browser.stop-ollama.bat: Forcefully kills all process trees starting with "ollama" and terminates any remaining process listening on port 11434 to free system resources.status-ollama.bat: Scans the active Windows process list to report whether the Ollama server is running.update-and-restart.bat: Pulls updates for your specified model, kills the running instance, and launches a fresh server.
-
Clone the repository to your local machine:
git clone https://github.com/qafaraz/ollama-control.git cd ollama-control -
Run any script by double-clicking it:
- Run
start-ollama.batto launch Ollama. - Run
stop-ollama.batto completely shut down Ollama and reclaim resources. - Run
status-ollama.batto see if it is running. - Run
update-and-restart.batto pull the latest model and reload.
- Run
By default, the update script pulls the llama3 model. If you use a different model:
- Open
update-and-restart.batin a text editor. - Locate the line
ollama pull llama3. - Replace
llama3with your model name (e.g.gemma2ormistral). - Save the file.
This project is open-source and licensed under the MIT License. Feel free to use, modify, and distribute it.