Skip to content

Complete IIS and Windows Environment Variables Knowledge Base

Category: Windows System Administration Tags: Windows, Environment Variables, IIS, System Administration, Configuration

Windows Environment Variables Reference

What are Environment Variables?

Environment variables are system-defined values that programs use to find files and folders regardless of which drive Windows is installed on or how the system is configured.

System Location Variables

  • %windir% = Windows directory (usually C:\Windows)
  • %SystemRoot% = Same as %windir% (C:\Windows)
  • %SystemDrive% = Drive where Windows is installed (C:)
  • %System32% = System32 folder (C:\Windows\System32)
  • %ProgramFiles% = Program Files folder (C:\Program Files)
  • %ProgramFiles(x86)% = 32-bit programs on 64-bit systems (C:\Program Files (x86))
  • %ProgramData% = Shared application data (C:\ProgramData)
  • %CommonProgramFiles% = Shared program files (C:\Program Files\Common Files)
  • %CommonProgramFiles(x86)% = 32-bit shared files (C:\Program Files (x86)\Common Files)

User Profile Variables

  • %UserProfile% = Current user's home folder (C:\Users\YourName)
  • %HomeDrive% = Drive containing user profiles (C:)
  • %HomePath% = Path to user profile (\Users\YourName)
  • %AppData% = User's roaming application data (C:\Users\YourName\AppData\Roaming)
  • %LocalAppData% = Local app data (C:\Users\YourName\AppData\Local)
  • %Temp% = Temporary files folder (C:\Users\YourName\AppData\Local\Temp)
  • %TMP% = Same as %Temp%
  • %Desktop% = User's desktop (C:\Users\YourName\Desktop)
  • %Documents% = User's documents (C:\Users\YourName\Documents)
  • %StartMenu% = User's start menu (C:\Users\YourName\AppData\Roaming\Microsoft\Windows\Start Menu)
  • %Startup% = User's startup folder (C:\Users\YourName\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup)

System Information Variables

  • %ComputerName% = Your computer's name
  • %UserName% = Currently logged in user
  • %UserDomain% = Domain name (if joined to a domain)
  • %UserDnsDomain% = DNS domain name
  • %LogonServer% = Domain controller that authenticated the user
  • %ProcessorArchitecture% = CPU type (AMD64, x86, ARM64)
  • %ProcessorIdentifier% = Detailed CPU information
  • %ProcessorLevel% = CPU family
  • %ProcessorRevision% = CPU revision
  • %Number_of_Processors% = Number of CPU cores

Network and Domain Variables

  • %ComputerName% = Local computer name
  • %UserDomain% = Logon domain
  • %LogonServer% = Domain controller name
  • %UserDnsDomain% = DNS domain name

Development and System Variables

  • %Path% = System PATH variable (directories searched for executables)
  • %PathExt% = File extensions considered executable (.exe, .bat, .cmd, etc.)
  • %OS% = Operating system name (Windows_NT)
  • %Processor_Architecture% = Processor architecture
  • %Random% = Random number between 0 and 32767
  • %Time% = Current time
  • %Date% = Current date
  • %CD% = Current directory
  • %CmdCmdLine% = Command line used to start cmd.exe

Special Shared Folders

  • %Public% = Public user folder (C:\Users\Public)
  • %AllUsersProfile% = All users data (C:\ProgramData)
  • %CommonStartMenu% = Shared start menu (C:\ProgramData\Microsoft\Windows\Start Menu)
  • %CommonStartup% = Shared startup folder (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp)
  • %CommonDesktop% = Shared desktop (C:\Users\Public\Desktop)
  • %CommonDocuments% = Shared documents (C:\Users\Public\Documents)

How to View Environment Variables

Command Prompt:

set                    # Show all variables
echo %windir%         # Show specific variable
set windir            # Show variables starting with "windir"

PowerShell:

Get-ChildItem Env:           # Show all variables
$env:windir                  # Show specific variable
$env:windir = "C:\Windows"   # Set variable

Windows GUI: - Press Win + R, type sysdm.cpl, press Enter - Click "Advanced" tab → "Environment Variables" button

Why Use Environment Variables?

  • Portability: Scripts work on any Windows system regardless of drive configuration
  • Flexibility: Programs find files even if Windows is installed to different drives
  • Maintenance: Easier to update paths centrally
  • Security: Avoid hardcoding sensitive paths in scripts

IIS Knowledge Base Guide

Why Install IIS on F: Drive Instead of C:

Performance Benefits - Separates web content from system drive to reduce I/O contention - F: drive is typically larger storage dedicated to data - C: drive reserved for operating system files

Management Advantages - Easier backup strategies - web content isolated from system files - Better security through application separation - Corporate policies often mandate separating applications from OS - Storage management - prevents web logs from filling system drive

IIS Manager vs Log Files

IIS Manager

What it is: Graphical management console for configuring IIS - Configure websites, application pools, virtual directories - Set authentication, SSL certificates, URL rewriting rules - Monitor real-time performance and active connections - Location: %windir%\system32\inetsrv\InetMgr.exe

IIS Log Files

What they are: Automatically generated records of all web requests - Default location: %SystemDrive%\inetpub\logs\LogFiles\W3SVC1\ - Contains request details, response codes, timestamps, IP addresses - Used for traffic analysis, troubleshooting, security monitoring, compliance

W3C Log Format - Why Use It?

Industry Standard - W3C Extended Log Format is universally recognized - Compatible with most log analysis tools (LogParser, AWStats, Webalizer)

Customizable and Efficient - Choose which fields to log (date, IP, status codes, user agents, etc.) - Only logs necessary data, reducing file size and storage costs - Well-structured format enables automated parsing and analysis

Tool Integration - Works seamlessly with Microsoft LogParser - Supports third-party analytics and monitoring solutions - Easy to import into databases and reporting tools

IIS Server Configuration Options

.NET Authorization

Purpose: Controls access to .NET applications and resources

What it manages: - Authentication methods (Windows Authentication, Forms Authentication, Anonymous) - Authorization rules for specific users and roles - Access control for pages, directories, or application methods - Integration with ASP.NET membership providers and Active Directory

.NET Compilation

Purpose: Defines how ASP.NET code is compiled and executed

Key settings: - Debug vs Release mode: Debug includes debugging symbols, Release is optimized for performance - Target Framework: Specifies .NET version (.NET Framework 4.8, .NET Core, etc.) - Compilation options: Batch compilation settings for better performance - Temporary files: Manages compiled assemblies in temporary ASP.NET files directory

.NET Error Pages

Purpose: Controls how application errors are displayed to users

Configuration options: - Custom error pages: Display user-friendly pages instead of technical stack traces - Error modes: - On - Always show custom errors - Off - Always show detailed errors (development only) - RemoteOnly - Show custom errors to remote users, detailed to local users - Default redirects: Specify custom pages for 404 (not found) and 500 (server error) responses - Security benefit: Prevents sensitive application information from being exposed to end users

MIME Types

Purpose: Tells web browsers how to handle different file types

How it works: - File associations: Maps file extensions to content types - .pdfapplication/pdf - .jpgimage/jpeg - .jsonapplication/json - Browser behavior: Determines whether file is displayed in browser or downloaded - Content handling: Controls streaming, caching, and compression settings - Security: Prevents execution of unknown or potentially dangerous file types

Common MIME types: - text/html - HTML web pages - text/css - Cascading Style Sheets - application/javascript - JavaScript files - image/png - PNG image files - application/json - JSON data responses - application/octet-stream - Generic binary files (forces download)

IIS Environment Variables

  • %SystemDrive%\inetpub\wwwroot - Default website root
  • %SystemDrive%\inetpub\logs\LogFiles - Default log location
  • %windir%\system32\inetsrv - IIS binaries and tools
  • %ProgramFiles%\IIS - IIS program files (if installed)

Quick Reference Commands

Check Environment Variables

echo %windir%              # Windows directory
echo %SystemDrive%         # System drive
echo %UserProfile%         # User profile path
echo %ComputerName%        # Computer name
echo %UserName%           # Current user

IIS Quick Paths

  • IIS Manager: %windir%\system32\inetsrv\InetMgr.exe
  • Default Website: %SystemDrive%\inetpub\wwwroot
  • Default Logs: %SystemDrive%\inetpub\logs\LogFiles\W3SVC1\
  • IIS Config: %windir%\system32\inetsrv\config\applicationHost.config

Log File Information

  • Naming Convention: ex[YYMMDD].log (example: ex241201.log)
  • Key Fields: date, time, c-ip, cs-method, cs-uri-stem, sc-status, time-taken
  • Status Codes: 200=OK, 404=Not Found, 500=Server Error, 403=Forbidden