---
slug: "flutter-windows-invoke-visual-studio-code"
title: "Launch VSCode from a Flutter Windows App"
description: "Launch VSCode (`code.cmd`) from a Flutter Windows app via `Process.run`. Covers how to pass arguments and handle quoting issues correctly."
url: "https://www.ytyng.com/en/blog/flutter-windows-invoke-visual-studio-code"
publish_date: "2021-03-21T12:08:36Z"
created: "2021-03-21T12:08:36Z"
updated: "2026-05-11T13:08:38.998Z"
categories: []
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/fc50e80c090f413c8b1b262b240e5fe7.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Launch VSCode from a Flutter Windows App

```dart
Process.run('code.cmd', ['<path-to-file-you-want-to-open>']);
```
Points to consider: When you install Visual Studio Code, you will be asked if you want to add it to the PATH. If you turn it ON, you will be able to start VSCode with the `code` command.

However, the correct command is actually `code.cmd`. Just `code` will not work when launching from Flutter's `Process.run`, so you need to include `.cmd`.

That's all.

----

Below is a previous workaround that seemed cumbersome but was kept as a memo because it might still be meaningful. Not recommended.

I wanted to launch VSCode from a Windows app made with Flutter.

```dart
if (Platform.isWindows) {
  var r = await Process.run('where.exe', ['code']);
  if (r.exitCode != 0 || r.stdout == '') {
    return;
  }
  var l = r.stdout.split('\r\n');
  Process.run(l[1], ['<path-to-file-you-want-to-open>']);
}
```
It's a bit forced, but this is how I did it.

`where.exe` works the same way as `which` on macOS or Linux. Error handling should be done more properly, but in this case, since the users are limited, I did it roughly like this.

The `ProcessResult` instance resulting from `Process.run` will have `exitCode == 0` if the command completes successfully. If it fails, it will be something other than 0, probably 1.

However, I didn't use the `exitCode` for determination this time.

The command result is stored in the `stdout` of the `ProcessResult`. In the case of Windows, the newline code is `\r\n`.

The result of `where.exe` will output the full path without extension on the first line and with the extension on the second line. To execute with `Process.run`, specify the one with the extension.
