Hazzaz Bin Faiz
Hazzaz Bin Faiz

Reputation: 33

PHP command is opening another window every time

I am using XAMPP in my computer.

I have added xampp/php in my path.

Now, when I run any PHP command, it opens another window for output every time.

image here

When I run "php -v" it opens another window and closes immediately.

Upvotes: 2

Views: 935

Answers (3)

my-me-my
my-me-my

Reputation: 1

I'm guessing it may have something to do with the user permissions when installing the file resources.

When I use powershell with normal user permissions the php screen pops up. But when I use administrator privileges, php works fine.

Upvotes: 0

Jose
Jose

Reputation: 46

CASE 1 - PERMISSIONS:

The first time I had this error, the problem was that my php folder only had read permissions, when I changed the permissions to: read and write php worked correctly.

CASE 2 - VIRUS:

The second time I had this error, it was because of two programs (virus) called: explorer.exe and svchost.exe. In this case, the best solutions are: format the PC or try an antivirus (the Windows defender does not detect them).

I fix the problem manually, if you also want to do it I detail the steps here:

IMPORTANT:

1) Check if your problem is the same: Open the "Task Manager" and look for these in the "Startup" and "Processes" tab.

  • explorer.exe (Different from windows explorer)
  • svchost.exe (It appears without name in the "processes" tab)

If this is not your case, the steps will not work, it is possible that another virus is causing the problem.

2) Make a backup, in case something goes wrong and you have to format your computer.

GUIDE:

Step 1: Open the "Task Manager", click on the "startup" tab, look for the names: explorer.exe and svchost.exe, mark them as disabled and restart the computer.

Step 2: In a file explorer, open the window: "Folder options", click on the "view" tab, enable the option: "Show hidden files and folders" and below disable the option: "Hide protected operating system files", then click the Apply button and close the window.

Step 3: Find these files and delete them, if the system does not let you delete them you will have to change the owner of the files:

If you have doubts about these files you can search them on the internet. These files should not be in that folder.

 C:\Windows\System\cmsys.cmn
 C:\Windows\System\explorer.exe
 C:\Windows\System\spoolv.exe
 C:\Windows\System\svchost.exe
 C:\Users\%username%\AppData\Roaming\mrsys.exe

Step 4: It is recommended to replace your PHP folder and reconfigure it (In my case when executing PHP the virus was re-generated and I had to follow all the steps again).

Step 5: Restart the computer, open the command prompt and try the "php -v" command. Don't forget to enable "Hide protected operating system files" option in "Folder options".

After these steps PHP worked correctly.

I hope this helps.

Upvotes: 3

René Höhle
René Höhle

Reputation: 27295

I think your problem appears because you don't run your commands as Admin. So try to start the "cmd" as Administrator then the command should run in the same window. I had the same problem before some time.

After that i have used the Git bash to work with. And after some trouble i used the Windows 10 Linux subsystem.

Upvotes: 0

Related Questions