# Run a root script from CMD

**URL:** <https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702>\
**Category:** Newbie\
**Created:** [August 20, 2019, 9:38am UTC](https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702 "2019-08-20T09:38:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stzanos](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stzanos/32/19538_2.png) [@stzanos](https://root-forum.cern.ch/u/stzanos)\
**Post date:** [August 20, 2019, 9:38am UTC](https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702/1 "2019-08-20T09:38:06Z")

</div>

Hello guys,

I’m following this: [https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#start-and-quit-a-root-session](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#start-and-quit-a-root-session)

which states in an example that to pass a string as a parameter you’re supposed to do:

```auto
root -b -q 'myMacro.C("text")' > myMacro.log

```

I have a root script with two string arguments `writeHVDataPlots(const string data_location, const string data_timestamp)` which plots and writes TGraphs in a Root file. I’m trying to run it from command prompt:

```auto
root -q 'writeHVDataPlots.C("\\cern.ch\Users\User\data\", "data_from_sometime_to_sometime")'

```

I get the error:

```auto
Warning in <TApplication::GetOptions>: macro 'writeHVDataPlots.C not found

```

Notice how the second `'` is not there on the error. I even tried the complete path of the script but still same error.

PS 1: I’m running on Windows 10.  
PS 2: Script works perfectly fine when I do it through root.

Thanks in advance for any help

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [August 20, 2019, 9:50am UTC](https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702/2 "2019-08-20T09:50:17Z")

</div>

You may need to use more escape characters for all the backslashes. Try to create a macro that just prints the argument, and call ROOT with that macro, then make sure that the escaping is correct. I don’t use Windows, but maybe using

```auto
root -q 'writeHVDataPlots.C("\\cern.ch\\Users\\User\\data\\", "data_from_sometime_to_sometime")'

```

might work for you.

---

<div class="post-metadata">

**Author:** ![stzanos](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stzanos/32/19538_2.png) [@stzanos](https://root-forum.cern.ch/u/stzanos)\
**Post date:** [August 20, 2019, 10:10am UTC](https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702/3 "2019-08-20T10:10:21Z")

</div>

That was a good call, but sadly same error =/

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [August 20, 2019, 11:19am UTC](https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702/4 "2019-08-20T11:19:46Z")

</div>

It looks like ROOT thinks `'` is part of the name of the macro.  
With some clever usage of double quotes and escaping I think you can make things work with just double quotes. If that works, this might be a bug report for ROOT’s command line parsing logic.

---

<div class="post-metadata">

**Author:** ![stzanos](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/stzanos/32/19538_2.png) [@stzanos](https://root-forum.cern.ch/u/stzanos)\
**Post date:** [August 20, 2019, 12:26pm UTC](https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702/5 "2019-08-20T12:26:53Z")

</div>

First of all, to clarify, I’ve made a mistake in the first place. For a root script to run in Windows it would need the path in slashes and not in backslashes as in Windows paths or else it gives an error. It’s really weird but since it works, that’s fine.

However, I repeated all the steps and the problem persists so I’ve tried it with other scrips of mine and it works fine without a parameter. When I try to pass a string inside, as @eguiraud has noted, it again seems as if ROOT reads the first `'` as part of the macro. I tried to use escaping of some sort but couldn’t get it to work.

Is there a way around this? Any other clue here?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [September 9, 2019, 9:27am UTC](https://root-forum.cern.ch/t/run-a-root-script-from-cmd/35702/6 "2019-09-09T09:27:34Z")

</div>

Hi,

Single quote is not supported in the command prompt on Windows. Try to only use double quotes

Cheers, Bertrand.
