How do you call csc.exe from any directory on the command line?

phaxmohdem

Golden Member
Aug 18, 2004
1,839
0
0
www.avxmedia.com
I'm trying to teach myself some basic C# programming, and am starting out using notepad and the csc commandline compiler.

My problem, is to compile any source file I've written, I have to navigate to the folder where csc is, and call the compiler from there. Most things I've seen online have people just typing in csc.exe from anywhere and it compiling. My system does not do that.

Instead of just calling csc from the folder where my source code is I have to do the following:

cd
cd Windows\Microsoft.NET\Framework\v3.5
csc \out:c:\cs\hello.exe c:\cs\hello.cs

Gets a bit tedious.

Is there a way to be able to call csc from my source code folder?

(running Vista Ult. x64 if that makes any difference)
 

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
add the folder location of csc to your PATH and it'll know to look there first if it doesn't find it in the current folder.

Control Panel -> System -> Advance Settings -> Environment Variables.

Edit the Path variable and append the location to the end. Each location is delimited by ";".
 

phaxmohdem

Golden Member
Aug 18, 2004
1,839
0
0
www.avxmedia.com
Many thanks! I actually added that directory to my PATH variable before posting, but neglected to reboot my machine so it could take effect :eek:

C# here I come! Look out!
 

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
You don't need to reboot. I think just restarting the command prompt will be fine.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
You don't need to reboot. I think just restarting the command prompt will be fine.

Yea, it's incredibly annoying that there's no way to refresh a running cmd instance's environment. Of course cmd was made with large doses of "annoying" so it's not really surprising. =)