Asked  2 Years ago    Answers:  5   Viewed   59 times

Possible Duplicate:
php How do I start an external program running - Having trouble with system and exec

how to open exe with php?
I had this idea and make hard to success it for several years,but failed at last. any one tell me a success method to do the job ?

<?php 
    if(isset($_POST['file_path'])){
        /* ------- 
            using "notepad++.exe" to open "test.php" file.
            or run a bat file which calling "notepad++.exe" to open "test.php" file.
            how to seting php.ini or firefox or any setting to do this job. 
            it is only for conveniently developing web page in my PC ,not for web servers
        ------- */
    }
?>

<form action="test.php" method="post">
    <input type="text" name="file_path" value="test.php"/>
    <button type="submit">open with notepad++</button>
</form>

This would create something like:

 Answers

2

To launch a program on the computer which runs the webserver:

<?php
exec('"C:Program Files (x86)Notepad++notepad++.exe" "C:foo.php"');

The above will work on vista/win7 IF the webserver does not run as a windows service. For example, if you run apache and it automatically starts when your computer boots, you probably installed it as a service. You can check to see if apache shows up in the windows services tab/thingy.

If the webserver runs as a service, you'll need to look into enabling the "allow desktop interaction" option for the service. But otherwise:

An easy test using php's new built in webserver(php 5.4+). The key thing here is you manually start the server from a shell, so it runs as your user instead of as a service.

<?php
// C:myhtdocsscript.php
exec('"C:Program Files (x86)Notepad++notepad++.exe" "C:foo.php"');

start a webserver via a command window

C:pathtophp.exe -S localhost:8000 -t C:myhtdocs

Then in your browser http://localhost:8000/script.php

Wednesday, August 10, 2022
2

Here is a code by which you can start activity using the name of the activity

String activityToStart = "com.example.MainActivity";
try {
    Class<?> c = Class.forName(activityToStart);
    Intent intent = new Intent(this, c);
    startActivity(intent);
} catch (ClassNotFoundException ignored) {
}

EDIT

Here class name will be full name of the class with the package name. For example if your package name will be x.y.z and if you have Activity name called A then the full name of the Activity A will be x.y.z.A.

Sunday, September 18, 2022
 
3

The MDN top level page for addons used to give an overview over the different extension types (since FF57 only webextensions are supported).

Components.utils.import

this is for restartless/XUL (legacy) extensions.

const { Cu } = require("chrome");

this is for SDK extensions.

Neither will work in webextensions.

Unlike the other extension types webextensions are restrictive, they do not provide access to the low-level APIs that you can find all over the wiki.

So stick to pages that are under the webextensions hierarchy or standard web APIs when you're looking for documentation related to this extension type.

Saturday, December 10, 2022
 
4

Yes, you can.

Here some ways for this:

  • Command Line PHP — is for developing shell applications with PHP;
  • PHP Desktop — is open source project for developing native desktop GUI applications using web technologies (PHP, HTML5, JavaScript & SQLite);
  • WinBinder — is a open source extension that allows PHP programmers to easily build native Windows applications;
  • Phalanger — is implementation of PHP, rewritten in C#. You can get access to C# libs;
  • ExeOutput — this makes it possible to create applications in native format for Windows with PHP, JavaScript and HTML;
  • PHP GTK — is an extension for the PHP programming language that implements language bindings for GTK+. But it is not supported from 2010;

Of course, maybe there are other ways, but I recommend you for creating Windows apps use something like C++, Python, Java, C#, etc. It's save your time and nerve.

Tuesday, October 11, 2022
 
strik3r
 
2

Is there a good work-around"

I'd like to add onto Andrew's answer with some code examples.

As it turns out, promise chains destroy the browser's notion of what is and isn't triggered by a user input handler. Take the code below, for example:

document.getElementById('foo').addEventListener('click', event => {
  browser.permissions.request({origins: ["https://google.com/*"]})
})

This code works as expected. I originally assumed that it was Vue.js's unique event handling framework that was eating my "browser events", such as when you do <div @click="somefunc"></div>. This actually works just fine, as long as you put your permissions request in somefunc.

Now it gets fun. If you replace your permissions request with a promise that resolves and then does a permissions request, VIOLA!

Promise.resolve('foobar').then(foobar => {
    browser.permissions.request({origins: ["https://google.com/*"]})
})

Results in:

Error: permissions.request may only be called from a user input handler

Why does this happen?

I'm going to guess it has to do with stack traces. Firefox can't detect that a permission came from a stack with a user input event at the root if the permissions request happens in a promise chain.

I consider this to be a pretty egregious design choice. My app is large (>4K LoC) and to keep it simple I rely on promise chains to keep the spaghetti away. This has crippled my ability to write clean code, and as a result, I've moved from asking for optional_permissions and then prompting the user for permissions only when needed to just being overly permissive at the time of installation.

GG, Firefox.

Thursday, August 11, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :
 

Browse Other Code Languages