---
title: "Discussion on \"My Little Automation Script\" | Hashnode"
description: "Discussion on \"My Little Automation Script\". It's a simple script that helps to launch VSCode and Terminal at the provided path.\nI have to just type  node project.js\nconst { exec } = require('child_process');\nconst fullpath = '/desire/path';\n\nmain();\n\nfunction main() {\n  launchVSCodeAt(fullpath..."
url: "https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [My Little Automation Script](https://blog.saudchougle.com/my-little-automation-script?utm_source=hashnode&utm_medium=feed)

It's a simple script that helps to launch VSCode and Terminal at the provided path. I have to just type node project.js const { exec } = require('child\_process'); const fullpath = '/desire/path'; main(); function main() { launchVSCodeAt(fullpath...

Dec 13, 2020 · 1 min read · blog.saudchougle.com  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#automation](https://hashnode.com/tag/automation)
-   [#python](https://hashnode.com/tag/python)
-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#hashnodecommunity](https://hashnode.com/tag/hashnodecommunity)

## Written by

[saud chougle](https://hashnode.com/@chouglesaud)

@chouglesaud · India

  
[View profile](https://hashnode.com/@chouglesaud)

Learner, Software Developer, Freelancer

I am a software engineer who learns and build projects.

## Responses 4

Markdown supported · ⌘↵ to post

[DoyinSoft Technologies](https://hashnode.com/@doyinsoft)

[Dec 21, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fe05f76b78ac62dff80f0c7)

[chougle saud](https://hashnode.com/@chouglesaud) So I decided to enhance the codes making it possible to type in the desired path upon execution of the script:

you can find the new script below

```

const { exec } = require("child_process");
const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
var fp = "";
rl.question("Enter a Valid Path to Open: ", function (p) {
  fp = p;
  main();
  rl.close();
});

function main() {
  launchVSCodeAt(fp);
  launchTerminalAt(fp);
}

function launchVSCodeAt(path) {
  exec(`cd ${path} && code .`, (err) => {
    if (err) console.log(`failed to launch VSCode at ${path}`);
    console.log(`VSCode launched at ${path}`);
  });
}
function launchTerminalAt(path) {
  exec(`cd ${path} && start cmd`, (error) => {
    if (error) console.log(`failed to launch Terminal at ${path}`);
    console.log(`Terminal launched at ${path}`);
  });
}
```

[saud chougle](https://hashnode.com/@chouglesaud)

[Dec 21, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fe05f76b78ac62dff80f0c7#reply-5fe0a62ae2fcaa59715f43c6)

intresting. i will definitely try out. one catch how will we remember path 🤔.

[DoyinSoft Technologies](https://hashnode.com/@doyinsoft)

[Jan 11, 2021](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fe05f76b78ac62dff80f0c7#reply-5ffc5605aa5c467fe155ae54)

Always copy paths from the window explorer text box [chougle saud](https://hashnode.com/@chouglesaud)

[Joshua Alexander](https://hashnode.com/@CodeLawd)

[Dec 16, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fda83551485f22e24b30baf)

Thanks chougle saud, I'm definitely trying this out tomorrow

[saud chougle](https://hashnode.com/@chouglesaud)

[Dec 17, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fda83551485f22e24b30baf#reply-5fdb62a6b78ac62dff809caa)

[Alexander Joshua](https://hashnode.com/@CodeLawd) 👍

[DoyinSoft Technologies](https://hashnode.com/@doyinsoft)

[Dec 16, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fd9e328f9e9d5279a16f2b3)

# Interesting, what if I needed it opened at a new path, do I edit the script before every launch?

[saud chougle](https://hashnode.com/@chouglesaud)

[Dec 17, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fd9e328f9e9d5279a16f2b3#reply-5fdb63801485f22e24b31ed9)

hi, You can set multiple paths. or conditions according to your needs. I would love to see if you make it more interesting.

[DoyinSoft Technologies](https://hashnode.com/@doyinsoft)

[Dec 21, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fd9e328f9e9d5279a16f2b3#reply-5fe05f1bb78ac62dff80f0bd)

[chougle saud](https://hashnode.com/@chouglesaud) So I decided to enhance the codes making it possible to type in the desired path upon execution of the script:

you can find the new script below

```
const { exec } = require("child_process");
const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
var fp = "";
rl.question("Enter a Valid Path to Open: ", function (p) {
  fp = p;
  main();
  rl.close();
});

function main() {
  launchVSCodeAt(fp);
  launchTerminalAt(fp);
}

function launchVSCodeAt(path) {
  exec(`cd ${path} && code .`, (err) => {
    if (err) console.log(`failed to launch VSCode at ${path}`);
    console.log(`VSCode launched at ${path}`);
  });
}
function launchTerminalAt(path) {
  exec(`cd ${path} && start cmd`, (error) => {
    if (error) console.log(`failed to launch Terminal at ${path}`);
    console.log(`Terminal launched at ${path}`);
  });
}
```

[Edidiong Asikpo (Didi)](https://hashnode.com/@didicodes)

[Dec 16, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fd9d4ada6d970247d7f2ba2)

Welcome to Hashnode, [chougle saud](https://hashnode.com/@chouglesaud). This is an interesting script; I will definitely try it out.

[saud chougle](https://hashnode.com/@chouglesaud)

[Dec 17, 2020](https://hashnode.com/posts/my-little-automation-script/5fd5ac10f60e3973bae6bca8/comment/5fd9d4ada6d970247d7f2ba2#reply-5fdb6252b78ac62dff809ca4)

[Edidiong Asikpo](https://hashnode.com/@didicodes) thanks.
