How to open any application, in web application program?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

How to open any application, in web application program?

Post by mubeena »

hai,

In desktop application, using our code we can make open , any application.

Is it possible, in web application?

Regards,
Jasmine
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to open any application, in web application program?

Post by requinix »

Yes, in most circumstances.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: How to open any application, in web application program?

Post by Christopher »

In the browser then no. On the server you can execute applications if the configurations allow it. You would need to use a plug-in or Java for that.
(#10850)
mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

Re: How to open any application, in web application program?

Post by mubeena »

Hai,
i want to open a wordpad, using the PHP.
If i tried this code,

<?php

// Some servers may have an auto timeout, so take as long as you want.
set_time_limit(0);

// Show all errors, warnings and notices whilst developing.
error_reporting(E_ALL);

// Used as a placeholder in certain COM functions where no parameter is required.
$empty = new VARIANT();

// Load the appropriate type library.
com_load_typelib('Word.Application');

// Create an object to use.
$word = new COM('word.application') or die('Unable to load Word');

print "Loaded Word, version {$word->Version}\n";

// Open a new document with bookmarks of YourName and YourAge.
$word->Documents->Open('C:/web/Sundance/Delivery Notes/Delivery_Template.doc');

?>

I am getting the error message,

Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `word.application': Access is denied. ' in D:\DocStation\testing_MIME\11.php:79 Stack trace: #0 D:\DocStation\testing_MIME\11.php(79): com->com('word.applicatio...') #1 {main} thrown in D:\DocStation\testing_MIME\11.php on line 79

Can anyone give me as suggesstion to solve this issue?

Regards,
Jasmine
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to open any application, in web application program?

Post by Benjamin »

Please use the proper [ code = php ] tags when posting code.
mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

Re: How to open any application, in web application program?

Post by mubeena »

<?php
print 'test';
set_time_limit(0);
error_reporting(E_ALL);
$empty = new VARIANT();
com_load_typelib('Word.Application');
$word = new COM('word.application') or die('Unable to load Word');
print "Loaded Word, version {$word->Version}\n";
$word->Documents->Open('C:/web/Sundance/Delivery Notes/Delivery_Template.doc');
?>
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to open any application, in web application program?

Post by Benjamin »

Please use the proper [ code = php ] tags when posting code.

You may also want to edit your existing posts so that other users can better read your code.
mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

Re: How to open any application, in web application program?

Post by mubeena »

i didnt understand? What u are expecting?

using my Php code, i want to open a word application.
That is, if i execute, this program, MsWord application, should open automatically.

This is my Php code

<?php
set_time_limit(0);
error_reporting(E_ALL);
$empty = new VARIANT();
com_load_typelib('Word.Application');
$word = new COM('word.application') or die('Unable to load Word');
print "Loaded Word, version {$word->Version}\n";
$word->Documents->Open('C:/web/Sundance/Delivery Notes/Delivery_Template.doc');

?>

This is my another example, to open the Notepad.

<?php
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run("notepad.exe", 7, false);

?>
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to open any application, in web application program?

Post by Benjamin »

There is a Code button you press when you want to post your PHP code. You then put your code inside of the tags. Once you have finished, change [ code ] to [ code=php ]. It will then look like this:

Code: Select all

 
<?php
print 'test';
set_time_limit(0);
error_reporting(E_ALL);
$empty = new VARIANT();
com_load_typelib('Word.Application');
$word = new COM('word.application') or die('Unable to load Word');
print "Loaded Word, version {$word->Version}\n";
$word->Documents->Open('C:/web/Sundance/Delivery Notes/Delivery_Template.doc');
?>
 
mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

Re: How to open any application, in web application program?

Post by mubeena »

Now i got it. :idea:
mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

Re: How to open any application, in web application program?

Post by mubeena »

hai tasairis,

I just go through, which you gave reference.

i tried one example,

Code: Select all

  <?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
   echo exec('whoami');
?>
 

I am getting the error message,

Warning: exec() [function.exec]: Unable to fork [whoami]
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to open any application, in web application program?

Post by Benjamin »

mubeena
Forum Newbie
Posts: 17
Joined: Fri Jan 30, 2009 4:26 am

Re: How to open any application, in web application program?

Post by mubeena »

I did that settings and then restarted my system.

Again, i executed my Program.

It shows, same error message.
Post Reply