php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66746 win32_create_service, user and password parameters
Submitted: 2014-02-20 09:56 UTC Modified: 2018-10-08 18:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: asd12daqdqv at mail dot ru Assigned: jbnahan (profile)
Status: Closed Package: win32service (PECL)
PHP Version: 5.4.25 OS: Windows Server 2008 R2
Private report: No CVE-ID: None
 [2014-02-20 09:56 UTC] asd12daqdqv at mail dot ru
Description:
------------
I want to create Windows service with administrative permissons using win32_create_service function. Web-server IIS7 works from administrator. PHP works as FastCGI. 

PHP has been downloaded from: http://windows.php.net/downloads/releases/php-5.4.25-nts-Win32-VC9-x86.zip. 
Win32 service library has been downloaded from: http://windows.php.net/downloads/pecl/releases/win32service/0.1.0/php_win32service-0.1.0-5.4-nts-vc9-x86.zip

If service creates witout user and password parameters it returns 0 and means service created. But if i run win32_create_service with user and password parameters it returns 2.

All paths, user and password is correct.

Windows system error codes: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382%28v=vs.85%29.aspx

Error 2: The system cannot find the file specified.

I didn't find actually information about this error on PHP sites/forums.

Sorry for my english. I hope you understand me.

Test script:
---------------
$service_install = win32_create_service(Array(
	'service'     => 'service_name',
	'display'     => 'Service Extended Name',
	'description' => 'Service Description',
	'path'        => 'C:\php\php.exe',
	'params'      => 'C:\inetpub\wwwroot\service.php' . ' run',
	'user' => 'Administrator',
	'password' => 'test123', 
));

var_dump($service_install);
exit;

# Output: int(2)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-05 10:53 UTC] asd12daqdqv at mail dot ru
I'm sorry. It's not a bug. There are 2 features:
1. User key must be provided in MACHINENAME\User format or just .\User
2. User key must be in Win-1251 (only if cyrillic?) charset: 'user' => iconv('UTF-8', 'windows-1251', '.\Администратор')

So next code is working perfectly:

$service_config = array(
	
	'service'      => 'service_name',
	'display'      => 'Service Extended Name',
	'description'  => 'Service Description',
	'path'         => 'C:\php\php.exe',
	'params'       => 'C:\inetpub\wwwroot\service.php' . ' run',
	'user'         => '.\Администратор',
	'password'     => 'test123', 
		
);
	
function utf8_to_win1251($in) {
	return iconv('UTF-8', 'windows-1251', $in);
}
	
$service_config = array_map('utf8_to_win1251', $service_config);
$service_install = win32_create_service($service_config);

var_dump($service_install);
exit;

# Outputs int(0)
 [2017-05-02 21:09 UTC] jean-baptiste at nahan dot fr
Hi,

Have you the same issue with PHP 7.0+ ?

The new version 0.2.1 is now available.
 [2018-10-08 18:46 UTC] jbnahan@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: jbnahan
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 20 08:01:26 2020 UTC