I need to Start and Stop Window Services using Test complete J script?
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to Start and Stop Window Services using Test complete J script?
Hello ,
I need to Start and Stop Window Services using TestComplete J Script?
ThanksinAdvances
Vasanth.V
Vasanth.V
Wittmann Battenfeld India Pvt. Ltd.,
Chennai.
Email : Vasanth.Veeravijayan@wittmann-group.com
Website : www.wittmann-group.com
Mobile: +91 8870219392 | Landline: +91 44 4207700
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Does this article help? http://support.smartbear.com/viewarticle/9044/?SearchQuery=starting%2520windows%2520services&_ga=1.2...
Regards,
Kevin
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vasanth,
You may either execute 'net start/stop' command using WScript.Run() or do this via WMI (google for something like "WMI stop windows service").
You may also search this forum - there were a couple of samples here on how to do this using WMI.
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello ,
I already refered this link.But same code i use and it not affect on the Services .
Vasanth.V
Wittmann Battenfeld India Pvt. Ltd.,
Chennai.
Email : Vasanth.Veeravijayan@wittmann-group.com
Website : www.wittmann-group.com
Mobile: +91 8870219392 | Landline: +91 44 4207700
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
-- Did you check in Task Manager that the relevant service process starts/stops?
-- Does the account that executes the start/stop code have anough privileges (as mentioned in the referenced article)?
-- Can you post here your actual code?
-- Any related messages in the Windows Event Viewer logs?
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to stop/start the service using javascript , I found this in testcomplete but it is using jscript. When I ran this I got an invalid parameter error. Can you help me convert this to javascript? I tried the suggestion in the thread as well to convert it somehow to javascript but got the not authorized error
function fn_GetService(computerName, serviceName)
{
var wmiService, objectsList, eObjectsList, item, sysID;
wmiService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" +
computerName + "\\root\\cimv2");
objectsList = wmiService.InstancesOf("Win32_Service")
if (objectsList.Count > 0) {
eObjectsList = new Enumerator(objectsList);
for (; !eObjectsList.atEnd(); eObjectsList.moveNext()) {
item = eObjectsList.item();
if (item.Name == serviceName)
return item;
}
}
return null;
}
I appreciate your help. Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, starting/stopping a windows service is simply a command line of "net start <servicename>" or "net stop <servicename>". This can be done using the WshShell.Run method (https://support.smartbear.com/testcomplete/docs/reference/program-objects/wshshell/index.html).
The way I would do it is simply something like this. FYI, this should work both for JScript as well as JavaScript:
function startService(serviceName){ WshShell.Run('net start ' + serviceName, 1, true); } function stopService(serviceName){ WshShell.Run('net stop ' + serviceName, 1, true); }.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Robert, let me try.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By the way can i use net stop remotely? I tried entering the path but failed. I need to stop & start the service remotely. Can you help?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I also need to pass on credentials.
SO how can i use net stop to stop the service remotely with different credentials. Help please!
