Windows how to change path to C drive directory?

I use Windows 10, root 5.34/36.
I want to run a macro script stored on my desktop. Since my computer doesn’t support root command on cygwin (nothing shows up after executing root command even after waiting for a long time), I will open up the root session. Fine.
Here’s how I tried to navigate from D drive to Desktop on C drive:
(the path to desktop on C drive is C:\Users\a\Desktop)
root [0] gSystem->pwd()
(const char* 0x12f8de8)"D:\root_v5.34.36"
root [1] gSystem->ls()
OBJ: TWinNTSystem WinNT WinNT System : 0 at: 012E2778
root [2] gSystem->cd(“C:\Users”)
(Bool_t)1
root [3] gSystem->pwd()
(const char* 0x12e27cd)"C:\Users"
root [4] .L a
Error in TRint::ProcessLine: macro a not found in path .;D:\root_v5.34.36/macros;
root [5] gSystem->pwd()
(const char* 0x12e27cd)"C:\Users"
root [6] gSystem->cd(“C:\Users/a/Desktop”)
(Bool_t)1
root [8] gSystem->ls()
OBJ: TWinNTSystem WinNT WinNT System : 0 at: 012E2778

Does the (Bool_t)1 mean the directory is successfully changed?
Also I had trouble reading file names under a directory using ls (maybe root uses another command? Also how to load a file under the current directory?

Thanks,
CY

Hi,

See the TSystem class reference.
Like on Linux, you can use gSystem->cd(“path”) or gSystem->ChangeDirectory(“path”). For example:

C:\Users\bellenot>root -l
root [0] gSystem->pwd()
(const char* 0x3ce2e8)"C:\\Users\\bellenot"
root [1] gSystem->cd("Tracing");
root [2] gSystem->pwd()
(const char* 0x2268f90)"C:\\Users\\bellenot\\Tracing"
root [3] gSystem->Exec("dir")
 Volume in drive C is System
 Volume Serial Number is FCE6-FDB1

 Directory of C:\Users\bellenot\Tracing

20/03/2014  13:51    <DIR>          .
20/03/2014  13:51    <DIR>          ..
20/03/2014  13:51                 0 Communicator-uccapi-0.uccapilog
20/03/2014  10:51                 0 Communicator-uccapi-0.uccapilog.bak
29/01/2016  10:31    <DIR>          WPPMedia
               2 File(s)              0 bytes
               3 Dir(s)  125,126,811,648 bytes free
(Int_t)0
root [4] gSystem->ChangeDirectory("WPPMedia");
root [5] gSystem->pwd()
(const char* 0x225e0f0)"C:\\Users\\bellenot\\Tracing\\WPPMedia"
root [6]

Cheers, Bertrand.

Hi,
I have two questions.
First of all, in ROOT session, I followed your code but gSystem->Exec(“dir”) sometimes doesn’t work with me. It shows up this error message:
root [4] gSystem->Exec(“dir”)
Volume in drive C has no label.
Volume Serial Number is 9616-0CB6
And this error message occurs for multiple folders. How to fix it?

Second of all, can you help me getting cygwin terminal to work please? Every time I type in root in cygwin64 (or cygwin) terminal, the command prompt never shows up, and here’s a copy of the screen (with nothing showing up after “Enclose multiple statements between { }.”
$ root


  •                                     *
    
  •    W E L C O M E  to  R O O T       *
    
  •                                     *
    
  • Version 5.34/36 5 April 2016 *
  •                                     *
    
  • You are welcome to visit our Web site *
  •      [root.cern.ch](http://root.cern.ch)            *
    
  •                                     *
    

ROOT 5.34/36 (v5-34-36@v5-34-36, Apr 05 2016, 10:25:45 on win32)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.

Thanks,
Chuan

Hi,

[quote=“chuanyin”]First of all, in ROOT session, I followed your code but gSystem->Exec(“dir”) sometimes doesn’t work with me. It shows up this error message:
root [4] gSystem->Exec(“dir”)
Volume in drive C has no label.
Volume Serial Number is 9616-0CB6
And this error message occurs for multiple folders. How to fix it?
[/quote]
Which error? I don’t see any error in your example…

I’ll check next week, but may I ask why you want to run ROOT in a cygwin terminal?

Cheers, Bertrand.

The error is that while you can see the subfolder files using the command “gSystem->Exec(“dir”)”,
for me no files show up.
For running on cygwin I meant running root on a remote computer by ssh command on cygwin.

thanks,
CY

Hi Chuan,

[quote=“chuanyin”]The error is that while you can see the subfolder files using the command “gSystem->Exec(“dir”)”, for me no files show up.[/quote]Oh OK, I see, but I don’t know how to fix this, since I’ve never seen such a behavior…

[quote=“chuanyin”]For running on cygwin I meant running root on a remote computer by ssh command on cygwin.[/quote]Well, I can run ROOT on a remote Linux machine via ssh from a Cygwin terminal (xterm). Running a native Windows executable (on a remote Windows machine) via ssh in cygwin is most probably not going to work, unless you build ROOT on Cygwin, which is not officially supported anymore…

Cheers, Bertrand.