How to: Compile JScript Code from the Command Line
To produce an executable JScript program, you must use the command-line compiler, jsc.exe. There are several ways to start the compiler.
If Visual Studio is installed, you can use the Visual Studio Command Prompt to access the compiler from any directory on your machine. The Visual Studio Command Prompt is in the Visual Studio Tools program folder within the Microsoft Visual Studio program group.
As an alternative, you can start the compiler from a Windows command prompt, which is the typical procedure if Visual Studio is not installed.
The Windows Command Prompt
To start the compiler from a Windows command prompt, you must run the application from within its directory or type the fully qualified path to the executable at the command prompt. To override this default behavior, you must modify the PATH environment variable, which enables you to run the compiler from any directory by simply typing the compiler name.
To modify the PATH Environment Variable
Use the Windows Search feature to find jsc.exe on your local drive. The exact name of the directory where jsc.exe is located depends on the name and location of the Windows directory and the version of the .NET Framework installed. If you have more than one version of the .NET Framework installed, you must determine which version to use (typically the latest version).
For example, the compiler may be located in C:\WINNT\Microsoft.NET\Framework\v1.0.2914.
Right-click the My Computer icon on your Desktop (Windows 2000), and select Properties from the shortcut menu.
Select the Advanced tab and click the Environment Variables button.
In the System variables pane, select "Path" from the list and click Edit.
In the Edit System Variable dialog box, move the cursor to the end of the string in the Variable Value field and type a semicolon (;) followed by the full directory name found in Step 1.
Continuing with the example in Step 1, you would type:
Click OK to confirm your edits and close the dialog boxes.
After you change the PATH environment variable, you can run the JScript compiler at the Windows command prompt from any directory on the machine.
Using the Compiler
The command-line compiler has some built-in help. A help screen is displayed by using the /help or /? command-line option or by using the compiler without any options. For example:
There are two ways to use JScript. You can write programs to be compiled from the command line, or you can write programs to be run in ASP.NET.
To compile using jsc
At the command prompt, type jsc file.js
The command compiles the program named file.js to produce the executable file named file.exe.
To produce a .dll file using jsc
At the command prompt, type jsc /target:library file.js
The command compiles the program named file.js with the /target:library option to produce the library file named file.dll.
To produce an executable with a different name using jsc
At the command prompt, type jsc /out:newname.exe file.js
The command compiles the program named file.js with the /out: option to produce the executable named newname.exe.
To compile with debugging information using jsc
At the command prompt, type jsc /debug file.js
The command compiles the program named file.js with the /debug option to produce the executable named file.exe and a file named file.pdb that contains debugging information.
There are many more command-line options available for the JScript command-line compiler. For more information, see.