PHP launching a Windows application - php

I want to launch a bat file or exe
I tried
system("C:\\PATH\\TO\\FOLDER\\script.bat")
system("CMD.EXE C:\\PATH\\TO\\FOLDER\\script.bat")
system("C:\\PATH\\TO\\FOLDER\\exefile.exe /S nameOfFileToCreate.txt")
system("CMD.EXE C:\\PATH\\TO\\FOLDER\\exefile.exe /S nameOfFileToCreate.txt")
system("START C:\\PATH\\TO\\FOLDER\\script.bat")
system("START C:\\PATH\\TO\\FOLDER\\exefile.exe /S nameOfFileToCreate.txt")
With START, I get this error message. The others attempts result in the page loading forever!
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> WshShell.Exec<br/><b>Description:</b> The system cannot find the file specified. ' in C:\xampp\htdocs\upload.php:95 Stack trace: #0 C:\xampp\htdocs\upload.php(95): com->Exec('START C:\PROGRA...') #1 {main} thrown in C:\xampp\htdocs\upload.php on line 95

Try the exec function:
http://us2.php.net/function.exec

this didnt work. For whatever reason, I can't launch the app. I decided to create a simple VBS script and I restart the PC with PHP as a temp solution

Related

What would prevent a PHP die() from working? On my computer die() is not working

This is on MacOS with PHP 8.1.10 installed via homebrew ...
Just a blank index.php code in it with only this code ...
<?php
die('We Should Just Die Here');
throw new \RuntimeException('This exception should never be seen');
?>
And .. render in my browser to see ...
<br />
<b>Fatal error</b>: Uncaught RuntimeException: This exception should never be seen in /path/to/public/index.php:4
Stack trace:
#0 /Users/my-user/.composer/vendor/laravel/valet/server.php(234): require()
#1 {main}
thrown in <b>/path/to/public/index.php</b> on line <b>4</b><br />
Same story if I run it command line (taking valet out of the equation) ..
$ php index.php
Fatal error: Uncaught RuntimeException: This exception should never be seen in /path/to/public/index.php:4
Stack trace:
#0 {main}
thrown in /path/to/public/index.php on line 4
I have already tried ...
Upgrading PHP
Re-installed Valet
Composer updating everything
In my roughly 800 years of writing PHP code I have never seen anything like this. Please if anyone has any help I'm interested.
I've found it. I installed the php-uopz extension a while back. I had completely forgotten about that.
pecl uninstall uopz fixed this for me.
Thank you for the rubber ducking stack overflow ;P

Why my PhpSlim cannot run in FitNesse after I hit the Test button?

I hope that all is well with you all.
I was following Gregor Gramlich's tutorial from http://ggramlich.github.io/phpslim/installation.html to http://ggramlich.github.io/phpslim/first_test.html. I was using phpslim.phar from that tutorial. And then I was using FitNesse of release 20161106.
So I have a problem after I hit the Test button. FitNesse give me a warning:
Unable to start test system 'slim': fitnesse.slim.SlimError: Got invalid slim header from client. Read the following:
Then I clicked the Execution Log button. The Standard Output give me a description:
PHP Warning: socket_bind(): unable to bind address [13]: Permission denied in phar:///home/lubuntu/Documents/Time/phpslim.phar/PhpSlim/SocketService.php on line 14
PHP Fatal error: Uncaught exception 'PhpSlim_SlimError' with message 'socket_bind() failed: Permission denied' in phar:///home/lubuntu/Documents/Time/phpslim.phar/PhpSlim/Socket.php:135
Stack trace:
#0 phar:///home/lubuntu/Documents/Time/phpslim.phar/PhpSlim/SocketService.php(16): PhpSlim_Socket->raiseError('socket_bind() f...')
#1 phar:///home/lubuntu/Documents/Time/phpslim.phar/PhpSlim/SocketService.php(6): PhpSlim_SocketService->bind()
#2 phar:///home/lubuntu/Documents/Time/phpslim.phar/PhpSlim/Server.php(24): PhpSlim_SocketService->init()
#3 phar:///home/lubuntu/Documents/Time/phpslim.phar/PhpSlim.php(29): PhpSlim_Server->run('1')
#4 phar:///home/lubuntu/Documents/Time/phpslim.phar/index.php(4): PhpSlim::main(Array)
#5 /home/lubuntu/Documents/Time/phpslim.phar(9): include('phar:///home/lu...')
#6 {main}
thrown in phar:///home/lubuntu/Documents/Time/phpslim.phar/PhpSlim/Socket.php on line 135
I was using port 8070 when starting the FitNesse. I was using Lubuntu 12.04, PHP 5.3 and Java 1.7 (OpenJDK 7).
Would you all telling me how to solve this problem?
Thank you.
Everyone, I have found the answer for this problem. So I was actually asked this question in the GitHub page of PhpSlim. Mr. Gramlich is the one who answered this problem. You can see the detail here.
I can successfully run the MyFirstSlimTest from Mr. Gramlich's tutorial in my PhpSlim now.
I only need to change the java command from
java -jar fitnesse-standalone.jar -e 0 -p 8070 -d /path/to/project
to
java -Dslim.port=0 -jar fitnesse-standalone.jar -e 0 -p 8070 -d /path/to/project

Trouble getting cakephp 2.4.0 running - fatal errors when attempting to complete tutorial

I am trying to follow the instructions for the cakephp tutorial found here: http://book.cakephp.org/2.0/en/getting-started.html
I uploaded the CakePHP files to my webserver, created the database using MySQL workbench, and created database.php and updated it to point to my MySQL server.
At this point it sounds like I should be able to open up the website in my browser and see something, but instead I get these errors (I have removed the full path):
Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache in /caketut/lib/Cake/Cache/Cache.php on line 325
Warning: caketut/app/tmp/cache/persistent/ is not writable in /www/premium/med/pediatrics/www.hobmt.umn.edu/htdocs/caketut/lib/Cake/Cache/Engine/FileEngine.php on line 380
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /caketut/lib/Cake/Cache/Cache.php:181
Stack trace:
#0 /caketut/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_')
#1 /caketut/app/Config/core.php(367): Cache::config('_cake_core_', Array)
#2 /caketut/lib/Cake/Core/Configure.php(72): include('/www/premium/me...')
#3 /caketut/lib/Cake/bootstrap.php(177): Configure::bootstrap(true)
#4 /caketut/app/webroot/index.php(92): include('/www/premium/me...')
#5 {main} thrown in /caketut/lib/Cake/Cache/Cache.php on line 181
I tried setting the permissions for the Cache folder located in /caketut/lib/Cake and all subfolders/files to be 0776, and this removes all errors except this one:
Fatal error: Class 'Cache' not found in /caketut/app/Config/core.php on line 361
I tried doing searches but was unsuccessful in finding a solution. I would really appreciate any assistance!
try to chmod the whole script with 0777 permissions .
sudo chmod -R 0777 caketut

Failed to create COM object `WScript.shell': CoInitialize has not been called

At sometime today, this error occurred and the script hanged:
[21-Aug-2013 08:35:06] PHP Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `WScript.shell': CoInitialize has not been called.
' in C:\path\to\my\script.php:357
Stack trace:
#0 C:\path\to\my\script.php(357): com->com('WScript.shell')
#1 {main}
thrown in C:\path\to\my\script.php on line 357
This is the line (running in a loop) causing the error:
$com = new Com('WScript.shell');
This line usually runs fine so I'm not missing any libraries. Why could this happen ?
Go to php.ini and add this line. After that, restart php server. Good luck to you
extension=php_com_dotnet.dll
That is most likely due to desktop heap allocation error. One way to verify is to go to Windows Event Log (system category) and search for "desktop heap allocation failed" error or warning. As an workaround, you can consider using shell_exec.
For more details about desktop heap allocation error, see KB 184802
Effectively include the library "extension = php_com_dotnet.dll" in php.ini can serve in executing $ command = new Com ('WScript.Shell');
in my case it worked with Apache / 2.2.29 server (Win64) PHP / 3.5.29 mod_ssl / 2.2.29
thanks a lot.

Error on using Chilkat.Zip2

Can anybody please let me know, i have used the below code to access COM object...
$zip = new COM("Chilkat.Zip2");
echo $zip;
but, which shows an like this...
Fatal error: Uncaught exception 'com_exception' with message 'Failed
to create COM object `ZipActiveX': Invalid syntax ' in
D:\xampp\htdocs\test\testscript1.php:2 Stack trace: #0 D:\xampp\htdocs\test\testscript1.php(2): com->com('ZipActiveX')
#1 {main} thrown in D:\xampp\htdocs\test\testscript1.php on line 1
please advice me, that do i need to change anything in my php.ini file to access COM?
shut down apache and start in administrator mode if using windows vista or 7.
edited:
chillkat zip activex is for windows server. you can download and install from this url http://www.chilkatsoft.com/download/ZipActiveX.msi
run webserver in windows using xampp adn run locally
xampp download url: http://www.apachefriends.org/en/xampp.html

Categories