Results 1 to 3 of 3

Thread: I wish to execute .exe file from my php program. I am using Window 7, WAMP.

  1. #1
    Join Date
    Feb 2014

    I wish to execute .exe file from my php program. I am using Window 7, WAMP.

    I wish to execute .exe file from my php program. I am using Windows 7 , WAMP on my local machine. My code is -

    exec('C:/wamp/www SkypeSetup.exe');


    $answer = shell_exec("C:/wamp/www/SkypeSetup.exe -args");
    echo $answer;
    But above code is not working. Please help. Thanks in advance.

  2. #2
    Join Date
    Feb 2014
    Ideally, you would want it so that the command you're passing will be executed without any command window popping up and will the rest of your page will not be forced to wait until the exec is finished. Also, if you're taking in user input, your code will allow for the user to execute any command, including file deletions. Read through the documentation HERE and take a look at some of the user comments.

  3. #3
    Join Date
    Feb 2014
    Ahmadabad, Gujarat, India
    Hello Friend, i heard this same questions in other thread, i am sharing the same information because the question you asked is similar as the earlier question..

    I have WAMP setup and I need to execute a program.
    WinXPPro sp3
    Apache 2.2
    PHP 5.3

    Right now I'm failing on all my attempts.

    I have tried...

    also opening a batch file and Python script that executes the program and I have no luck for now.

    I have been digging for couple of days and I can't find a solution for this problem.

    php file:
    PHP Code:
    $test = `F:\batch.bat`;
    $test = shell_exec('F:\batch.bat');
    $test = system('F:\batch.bat');
    $test = exec('F:\batch.bat',$output,$return);
    $test = popen('F:\batch.bat','r');

    batch file:
    PHP Code:
    "F:\Mozilla Firefox\firefox.exe"

    Start, cmd /c, cmd /d, don't work the way I want. Actually day don't execute the program. They just open a second cmd outside or inside the parent cmd.

    When I execute internal program... let us say "notepad" I can see in my task manager and Process Explorer that it is opening the "notepad" but it looks like a child process for Apache and it's not showing up on the screen.

    Suggesting Check:

    Is Apache running as a service? My guess is yes, and what is happening is Apache is launching under a different session/user than the one you are logged in as. Thus the window isn't visible to you. Unfortunately I'm not sure exactly how to fix that besides not running Apache as a service.

    Final Reply

    After you point me to the problem I went for investigation. So actually the problem is that any program that had to be run from php/apache it executes in different session and even if the user is the same I think it can't find the same session.

    The other difference that I notice is any program executed by cmd or explorer.exe are executed also as NT AUTHORITY\INTERACTIVE and any program from PHP/Apache is executed as NT AUTHORITY\SYSTEM.

    So some may ask so what... well it is not INTERACTIVE so I went to look for a way to start program in INTERACTIVE Authority and there was a Micro$oft Solution for that and it is called PsTools and their psexec.exe tool.

    The right command is:
    PHP Code:
    path/to/psexec.exe -i -s path/to/your/file.exe

    For now I think it is working. I will give it a better test to see if I can actually use it.

    Hope this can help you, if this will be helpful to you, please share your experience here. Best of Luck

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.09398 seconds
  • Memory Usage 2,852KB
  • Queries Executed 13 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates