Answered by:
Using powershell to create a windows service for a .cmd file(script)

Question
-
Hello all,
I am running:
windows 2008 serverI would like to know what i am doing wrong with trying to get this script file i created to be successfully be created as a service and sart successfully. If i use the new-service command. It creates the windows service but it will not start. I have used regular cmd prompt but i just started using this powershell.
here is what i typed in powershell and output i recieved:
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.PS C:\Windows\system32> cd\
PS C:\> new-service -name WlsAdmin -binaryPathName "C:\Oracle\Middleware\user_projects\domains\FRClassicDomain\bin\start
ManagedWebLogic.cmd -k beasvc"Status Name DisplayName
------ ---- -----------
Stopped WlsAdmin WlsAdminPS C:\> start-service -name WlsAdmin
Start-Service : Service 'WlsAdmin (WlsAdmin)' cannot be started due to the following error: Cannot start service WlsAdm
in on computer '.'.
At line:1 char:14
+ start-service <<<< -name WlsAdmin
+ CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service],
ServiceCommandException
+ FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Commands.StartServiceCommandthe script code i created:
SETLOCAL
set DOMAIN_NAME=FRClassicDomain
set USERDOMAIN_HOME=C:\Oracle\Middleware\user_projects\domains\FRClassicDomain
set SERVER_NAME=AdminServer
set WL_HOME=C:\Oracle\Middleware\wlserver_10.3
set WLS_USER=username
set WLS_PASSWORD= password
set ADMIN_URL=t3://nyct2bwyugosdv1:7001
set JAVA_VENDOR=Sun
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0
set PRODUCTION_MODE=true
set MEM_ARGS=-Xms512m –Xmx512m
call "C:\Oracle\Middleware\wlserver_10.3\server\bin\installSvc.cmd"
ENDLOCAL
***If this is not the right place to ask this type of question can you direct me where would be the right place***
***i already posted to other forums regarding this. all feeedback i tried failed, which included using the cmd prmpt and node manager that is used with oracle software***
Wednesday, May 15, 2013 7:42 PM
Answers
-
Hi,
How about with the parameter -startuptype automatic?
Please also go through the below links:
http://www.activexperts.com/activmonitor/windowsmanagement/powershell10/0132/
Regards,
Cataleya Li
TechNet Community Support- Marked as answer by Yan Li_ Tuesday, May 28, 2013 2:17 AM
Monday, May 20, 2013 5:36 AM
All replies
-
from help new-service -detailed:
PARAMETERS
-BinaryPathName <string>
Specifies the path to the executable file for the service. This parameter is required.the "Binary" in BinaryPathName, along with the examples, suggests that this needs to be a "binary" "executable" file. a .cmd "batch script" file is sometimes referred to as an executable, however, it is not binary, and can only be executed by another binary called cmd.exe.
Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.
Wednesday, May 15, 2013 8:11 PM -
Hi,
How about with the parameter -startuptype automatic?
Please also go through the below links:
http://www.activexperts.com/activmonitor/windowsmanagement/powershell10/0132/
Regards,
Cataleya Li
TechNet Community Support- Marked as answer by Yan Li_ Tuesday, May 28, 2013 2:17 AM
Monday, May 20, 2013 5:36 AM