Skip to main content

iis server cannot run shell exec

iis server cannot run shell exec


After hours and hours of trying and searching for an answer i coudn't get it working.
Hosting details:
Windows Server 2012 R2
Plesk 12
IIS 8.5

The problem

My problem is: I want to execute this command in PHP. The command is necessary to reload the configs for filezilla, after creating a new user with an PHP script.
C:\Program Files (x86)\FileZilla Server\FileZilla Server.exe /reload-config
It does work when i try it directly in CMD. But in PHP if doens't somehow work. I tried so many things, that im going to try to give you all the manners i tried.
I tried to do this at the following ways:

Trial 1

$command = '"C:\\Program Files (x86)\\FileZilla Server\\FileZilla Server.exe" /reload-config'; 
exec( $command, $output, $return); 

print_r($output);
echo '<br/>' .$return;
Output:
Array ( ) 
0

Trial 2

$command = '"C:\\Program Files (x86)\\FileZilla Server\\FileZilla Server.exe" /reload-config'; 
system( $command, $output); 

print_r($output);
Output: 0

Trial 3

$command = 'C:\\"Program Files (x86)\\FileZilla Server\\FileZilla Server.exe" /reload-config'; 
exec( $command, $output, $return); 

print_r($output);
echo '<br/>' .$return;
Output: 0

Trial 4 (The only one that returns an error!)

exec( 'C:\\"Program Files (x86)\\FileZilla Server\\FileZilla Server.exe" /stop 2>&1', $output); 
print_r($output);
Output:
Array ( [0] => Toegang geweigerd. )
In english:
Array ( [0] => Access denied. )

Privileges:

In allmost all awnsers found they talked about privileges. I did following privileges:
Gave all web users and IUSR privileges to CMD.exe and FileZilla Server.exe, and tried to set the IIS authentication from anonymous to an Administrator account
Somebody said to try this:
echo '<pre>';
    system('set', $retval);
echo ' </pre>'; 
If i do that my output is: http://pastebin.com/SjzeQpJ0
If you guys want anymore details just ask. I hope you guys can figure it out for me. I tried to be as clear as possible. Thanks.

Finaly found the solution!!


If you encounter the same problem as i did, and you dont know how to fix this, follow this steps.
  1. Login to the Remote of your server (if you have access to it) Open
  2. Open the IIS manager
  3. Select -> Application Pools node underneath the machine node (left panel)
  4. Right click on the desired domainname -> Advanced settings
  5. Scroll to Process Model -> Id
  6. Click on the 3 dots
  7. Check the Custom Account radio button
  8. Fill in an existing administration account which has access to the remote desktop and of course its password
  9. Press OK
  10. Now go to the .exe or whatever file you want to access throught the exec command and
  11. Right click on the file and select properties
  12. Go to the security tab
  13. Select Edit
  14. Now grand full rights to the account you selected before. If its not listed than add it manualy by clicking on Add
If you have done all of this, it now should work.



Finaly found the solution!!


If you encounter the same problem as i did, and you dont know how to fix this, follow this steps.
  1. Login to the Remote of your server (if you have access to it)
  2. Open the IIS manager
  3. Select -> Application Pools node underneath the machine node (left panel)
  4. Right click on the desired domainname -> Advanced settings
  5. Scroll to Process Model -> Id
  6. Click on the 3 dots
  7. Check the Custom Account radio button
  8. Fill in an existing administration account which has access to the remote desktop and of course its password
  9. Press OK
  10. Now go to the .exe or whatever file you want to access throught the exec command and
  11. Right click on the file and select properties
  12. Go to the security tab
  13. Select Edit
  14. Now grand full rights to the account you selected before. If its not listed than add it manualy by clicking on Add
If you have done all of this, it now should work.



Comments

Popular posts from this blog

Sejarah desa sumber kecamatan jatitujuh kabupaten majalengka

            KI. Bagus Arimba / KI. Bagus Arsitem dilahirkan di kecamatan Ligung kabupaten Majalengka sekitar abad ke-17 putra dari KI. Bagus demang Secayuda yang merupakan pejuang anti penjajah belanda (VOC pada zaman itu).             Ketika istri KI. Demang secayuda mengandung, beliau berpesan apabila nanti lahir laki-laki maka di beri nama KI.Bagus Arimba dan jika lahir anak perempuan maka namanya diserahkan pada isteri beliau. Kemudian KI. Demang secayuda meneruskan perjuangannya melawan penjajah di tanh air indonesia tercinta sampai-sampai kuburan beliaupun tidak ditemukan.            Sesudah menginjak dewasa KI. Bagus Arimba meneruskan perjuangan ramanya (bapaknya) yakni mengajarkan ilmu agama dan tata ilmu kejawen (pertanian dan perdagangan ) danmenentang anti penjajah yang pada waktu itu penjajah VOC Belanda. Beliau mendirikan pesanggrahan (pesantren) di desa subur Djati /Sumber Jati (yang sekarang dimekarkan menjadi dua desa yaitu desa sumber Wetan dan Sumb

SASAKALA SITU BAGENDIT

Di wewengkon Garut aya situ anu ngaranna kawentar ka mana-mana, nyaéta Situ Bagendit. Cék sasakala mah, éta Situ Bagendit téh asal-muasalna kieu: Baheula, aya hiji randa beunghar katelahna Nyi Endit. Ieu téh saenyana mah nénéhna, da ngaranna sajati mah Nyi Bagendit. Manéhna téh kacida pisan kumedna. Geus taya nu bireuk deui kana kakumedanana téh. Salian ti pakacar-pakacarna mah, tara aya nu larsup ka imahna. Éstuning lain babasan éta mah hirup nyorangan téh. Ngahaja mencilkeun manéh, ngababakan di tengah pasawahan anu upluk-aplak. Maksudna taya lian, ku bawaning embung campur jeung batur, da sieun kasoro téa. Kacaturkeun keur usum panén, di ditu di dieu ceuyah dibaruat. Ka sawah Nyi Endit ogé réa nu gacong. Ari réngsé dibuat jeung sanggeus paréna dikaleuitkeun, sakumaha tali paranti, Nyi Endit nyieun sidekah. Ngondang lebé jeung sawatara tatangga. Popolahna saniskara ku sorangan, teu aya nu ngabantuan. Barang geus tarapti, sakur nu mantuan ngakut tuluy diondang ngariung tumpeng.

Bioteknologi Proses pembuatan tempe

•        Bioteknologi Pembuatan Tempe •        Alat dan Bahan Alat ü   Baskom ü   Saringan ü   Dandang ü   Kipas Angin /Kipas ü   Sotel kayu ü   Tampah ü   Kompor ü   Peralatan lain yang diperlukan Bahan ü   Kacang kedelai ü   Ragi tempe (inokulum RAPRIMA) atau biakan murni Rhizopus sp. ü   Kantong plastik, atau daun pisang, atau daun jati. •        Cara Membuat Cucilah tampah, ayakan, kipas dan cukil yang akan digunakan, kemudian dikeringkan. Bersihkan kacang kedelai dari bahan-bahan lain yang tercampur, kemudian cuci hingga bersih. Rendam kacang kedelai yang telah dicuci bersih selama 12-18 jam dengan air dingin biasa (proses hidrasi agar biji kedelai menyerap air sebanyak mungkin ). Lepaskan kulit biji kedelai yang telah lunak, kemudian cuci atau bilas dengan menggunakan air bersih. Kukus / rebus biji kedelai tersebut sampai empuk. Setelah biji kedelai terasa empuk, tuangkan biji-biji tersebut pada tampah yang