{"id":498,"date":"2011-07-13T04:00:54","date_gmt":"2011-07-13T10:00:54","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=498"},"modified":"2026-03-26T05:57:32","modified_gmt":"2026-03-26T11:57:32","slug":"how-to-fix-error-php-has-encountered-an-access-violation-at-7d611952","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/how-to-fix-error-php-has-encountered-an-access-violation-at-7d611952\/","title":{"rendered":"How to Fix \u201cPHP Is Not Recognized as an Internal or External Command\u201d in Windows"},"content":{"rendered":"\n<p>&nbsp;If you see this error in Command Prompt:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'php' is not recognized as an internal or external command<\/code><\/pre>\n\n\n\n<p>it means Windows cannot find the PHP executable file.<\/p>\n\n\n\n<p>This happens when the PHP installation directory is not added to the system <strong>PATH environment variable<\/strong>.<\/p>\n\n\n\n<p>Let\u2019s understand why this happens and how to fix it properly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why This Error Occurs<\/h2>\n\n\n\n<p>Windows uses a special environment variable called <strong>PATH<\/strong> to locate executable files when you run commands in Command Prompt.<\/p>\n\n\n\n<p>If PHP was:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Installed manually<\/li>\n\n\n\n<li>Extracted from a ZIP archive<\/li>\n\n\n\n<li>Installed without automatic configuration<\/li>\n<\/ul>\n\n\n\n<p>then its installation directory may not have been added to PATH.<\/p>\n\n\n\n<p>When that happens, Windows doesn\u2019t know where <code>php.exe<\/code> is located \u2014 and the command fails.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">What Is the PATH Variable?<\/h1>\n\n\n\n<p>The PATH variable is a list of directories that Windows searches when you type a command.<\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\system32\\wbem<\/code><\/pre>\n\n\n\n<p>If <code>C:\\php<\/code> is not included in this list, Windows will not find <code>php.exe<\/code>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Solution: Add PHP to the PATH Variable<\/h1>\n\n\n\n<p>You need to add your PHP installation folder (for example, <code>C:\\php<\/code>) to the system PATH.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Current PATH<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\system32\\wbem;C:\\Program Files\\Intel\\DMIX<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Corrected PATH (PHP Added)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\php;%SystemRoot%\\system32;%SystemRoot%;%SystemRoot%\\system32\\wbem;C:\\Program Files\\Intel\\DMIX<\/code><\/pre>\n\n\n\n<p>Placing <code>C:\\php<\/code> at the beginning ensures Windows checks that directory first.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Step-by-Step Instructions (Windows 10 \/ 11)<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Open System Properties<\/h3>\n\n\n\n<p>Press:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Win + R<\/code><\/pre>\n\n\n\n<p>Type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysdm.cpl<\/code><\/pre>\n\n\n\n<p>Press Enter.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Go to Advanced Tab<\/h3>\n\n\n\n<p>Click <strong>Advanced<\/strong> \u2192 <strong>Environment Variables<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Edit System PATH<\/h3>\n\n\n\n<p>Under <strong>System Variables<\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Find <strong>Path<\/strong><\/li>\n\n\n\n<li>Click <strong>Edit<\/strong><\/li>\n\n\n\n<li>Click <strong>New<\/strong><\/li>\n\n\n\n<li>Add:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\php<\/code><\/pre>\n\n\n\n<p>(Replace with your actual PHP installation directory)<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Save Changes<\/h3>\n\n\n\n<p>Click <strong>OK<\/strong> on all windows.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Restart Command Prompt<\/h3>\n\n\n\n<p>Close and reopen Command Prompt.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Verify the Fix<\/h1>\n\n\n\n<p>Run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php -v<\/code><\/pre>\n\n\n\n<p>If configured correctly, you will see your installed PHP version instead of an error.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">How to Confirm PHP Location<\/h1>\n\n\n\n<p>If you&#8217;re unsure where PHP is installed:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check where you extracted it<\/li>\n\n\n\n<li>Look inside <code>C:\\Program Files<\/code><\/li>\n\n\n\n<li>Use File Explorer search for <code>php.exe<\/code><\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">Common Mistakes to Avoid<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">Adding the wrong folder<\/h3>\n\n\n\n<p>Make sure you add the folder containing <code>php.exe<\/code>, not the file itself.<\/p>\n\n\n\n<p>Correct:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\php<\/code><\/pre>\n\n\n\n<p>Wrong:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\php\\php.exe<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Not Restarting Command Prompt<\/h3>\n\n\n\n<p>Environment changes require a new terminal session.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Multiple PHP Versions in PATH<\/h3>\n\n\n\n<p>If you have multiple PHP versions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first one listed in PATH takes priority<\/li>\n\n\n\n<li>Remove unused versions<\/li>\n\n\n\n<li>Reorder paths carefully<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">Advanced Tip: Check Current PATH via Command Line<\/h1>\n\n\n\n<p>You can see your current PATH using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo %PATH%<\/code><\/pre>\n\n\n\n<p>This helps identify duplicates or incorrect entries.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">FAQ<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Why does PHP work in XAMPP but not in Command Prompt?<\/h2>\n\n\n\n<p>Because XAMPP runs PHP internally and does not require a global PATH entry. For system-wide access, PHP must be added to PATH.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Do I need to restart my computer?<\/h2>\n\n\n\n<p>No. Restarting Command Prompt is usually enough.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Can this issue happen on Windows Server?<\/h2>\n\n\n\n<p>Yes. The solution is the same &#8211; update the system PATH variable.<\/p>\n\n\n\n<p>In case of any doubt, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\" title=\"\">contact SupportPro<\/a>.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><a href=\"https:\/\/www.supportpro.com\/freecheckup.php\"><\/a><\/span><\/span><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Partner with <strong>SupportPRO<\/strong> for 24\/7 proactive cloud support that keeps your business secure, scalable, and ahead of the curve.<\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;If you see this error in Command Prompt: it means Windows cannot find the PHP executable file. This happens when the PHP installation directory is not added to the system&hellip;<\/p>\n","protected":false},"author":4,"featured_media":15603,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-498","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server-tweaking"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=498"}],"version-history":[{"count":13,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/498\/revisions"}],"predecessor-version":[{"id":16683,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/498\/revisions\/16683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media\/15603"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}