1

I created a custom windows service in Visual Basic using Visual Studios '05.

The service is on our server which is running Windows Server 2003. I have installed the service, and it runs perfectly when I go into Computer Management and Start the service manually.

I have created a batch file to start the service using the NET START command. Whenever I run the batch file, the service doesn't start. I get this message from the command prompt:

The 'Service Name' is starting.

The 'Service Name' could not be started. The service did not report an error. More help is available by typing NET HELPMSG 3543.

I'm not sure what to do. (Been "googling" for a couple of hours.) It starts up when I manually run it, but it wont start via the batch file. Thanks!

Seki
  • 11,135
  • 7
  • 46
  • 70

1 Answers1

0

Try forcing it to elevate in the batch file.

@ECHO OFF
:: Automatically elevate...

@ECHO OFF
SETLOCAL

:: Check if script was run with administrator privilages
    >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

:: If the error flag is set, we do not have admin.
    IF "%ERRORLEVEL%"=="0" GOTO GOTADMIN

:UACPROMPT
    ECHO. Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    ECHO. UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%TEMP%\getadmin.vbs"
    EXIT /B

:GOTADMIN
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    CD /D "%~dp0"
ENDLOCAL
GOTO SCRIPTSTART


:: THE ACTUAL SCRIPT STARTS HERE
:SCRIPTSTART
NET START [whatever service]