Same AppDomain when using a Engine.NewExecution

Hi everyone,
I looked at the forum but I dont see any solution about it.
Right now, Im running sequence file through the TestStand Engine from a custom c# application we made. My problem is My C# application and the TestStand execution dont share the same AppDomain.
Is there a way to, when I load th TestStand.Engine, share the same AppDomain between them.
Thank you
I hope I was clear about my issue. Is there something, let me know, I will add more details.
Ross
Solved!
Go to Solution.

You can't currently make the executions use the same appdomain as your UIs, however you can share .NET objects between the appdomains if they are derived from MarshalByRefObject or are serializeable (serializeable objects are copied rather than passed as a reference). If you are using TestStand 2010 or higher (and this might work in older versions too, but I'm not 100% sure), you can then pass the object between appdomains using a TestStand Object Reference variable. You can use a StationGlobal or other variable that is accesible from both locations. Call SetValInterface from one, and GetValInterface from the other. The assembly containing these shared objects must also either be in the GAC, or in your application's base path (i.e. the directory of the exe) or you will get errors.
Hope this helps,
-Doug

Similar Messages

  • Several of us have a iPhone 6s and are having trouble with hearing and speaking at the same time when using the phone. ? The speakers seem to be too far apart? Are others having this issue? Solutions?

    Several of us have a iPhone 6plus and are having trouble with hearing and speaking at the same time when using the phone. ? The speakers seem to be too far apart? Are others having this issue? Solutions?

    Not having the problem, don't personally know anyone who is.

  • TS2570 doesn't work, still the same problem when using Rapidweaver software. NOT with other software.

    i tried everything in this article, but still have the same problem when using Rapidweaver software. NOT with other software. I am converting my iWeb site  to Rapidweaver, whenever there is a calmer period in my office. I have 16 Gb RAM on my NEW iMac and have Parallels desktop, mail, safari, iWeb and Rapidweaver running simultanious.
    I never have the problem if i don't use Rapidweaver, but after i have added several pages to Rapidweaver, the problem begins. my iMac won't start up. the only thing that works is re-installing Macos OS X 10.8. i tried even whiping the completeharddrive, and reinstalling with a complete new user, the same problem.
    I had it on my previous iMac also, and bought a new one because i thought the problem was in the iMac first. i hadn't noticed it only happens with using rapidweaver.
    i sent my complete rapidweaver project to the programmers from rapidweaver at Realmacsoftware, but they couldnt reproduce my problem, there macs started up without any problem.
    i deleted all the rapidweaver addons and extra stacks, and started a complete new project.
    saterday i had the problem again, after adding about 5 new pages to my rapidweaver site.
    i think i have reinstalled Macos OS X 10.8.2 20 or 30 times by now
    does anyone have a sollution?

    Type '''about:support''' in the URL bar and hit Enter.
    Scroll down almost to the bottom of that listing and see if you have '''user.js Preferences''' just above the '''''Graphics''''' category.
    If you do have that, click on '''user.js file''' in this sentence. <br />
    ''Your profile folder contains a user.js file, which includes preferences that were not created by Firefox.''
    Does that "different homepage" appear in that user.js file?

  • Optimizing EtherCAT Performance when using Scan Engine

    Hello everyone,
    This week I have been researching and learning about the limitations of the LabVIEW's Scan Engine. Our system is an EtherCAT (cRIO 9074) with two slaves (NI 9144). We have four 9235s, two 9237s and two 9239 modules per chassis. That means we have a total of 144 channels. I have read that a conservative estimation for each scan is 10 usec. This means with our set up, assuming we only scan it would take 1.44 msec which would yield roughly a rate of 694 Hz. I know that when using a shared variable, the biggest bottle neck is transmitting the data. For instance, if you scan at 100 Hz, it'll be difficult to transmit that quickly, so it's best to send packets of scans (which you can see in my code).
    With all of that said, I'm having difficulties scanning any faster than 125 Hz without railing out my CPU. I can record at 125 Hz at 96% of the CPU usage but if I go down to 100 Hz, I'm at 80%. I noticed that the biggest factor of performance comes when I change my top loop's, the scan loop, period. Scanning every period is much much more demanding than every other. I have also adjusted the scan period on the EtherCAT's preferences and I have the same performance issues. I have also tried varying the transmission frequency(bottom loop), and this doesn't affect the performance at all.
    Basically, I have a few questions:
    1. What frequency can I reasonably expect to obtain from the EtherCAT system using the Scan Engine with 144 channels?
    2. What percent of the CPU should be used when running a program (just because it can do 100%, I know you shouldn't go for the max. Is 80% appropriate? Is 90% too high?)
    3.Could you look through my code and see if I have any huge issues? Does my transmission loop need to be a timed structure? I know that it's not as important to transmit as it is to scan, so if the queue doesn't get sent, it's not a big deal. This is my first time dealing with a real time system, so I wouldn't be surprised if that was the case.
    I have looked through almost every guide I could find on using the scan engine and programming the cRIO (that's how I learned the importance of synchronizing the timing to the scan engine and other useful facts) and haven't really found a definitive answer. I would appreciate any help on this subject.
    P.S. I attached my scan/transmit loop, the host program and the VI where I get all of the shared variables (I use the same one three times to prevent 144 shared variables from being on the screen at the same time).
    Thanks,
    Seth
    Attachments:
    target - multi rate - variables - fileIO.vi ‏61 KB
    Get Strain Values.vi ‏24 KB
    Chasis 1 (Master).vi ‏85 KB

    Hi,
    It looks like you are using a 9074 chassis and two 9144 chassis, all three full with Modules and you are trying to read all the IO channels in one scan?
    First of all, if you set your scan engine speed for the controller (9074), then you have to synchronize your Timed Loop to the Scan Engine and not to use a different timebase as you do in your scan VI.
    Second the best performance can be achieved with I/O variables, not shared variables and you should make sure to  not allocate memory in your timed Loop.  memory will be allocated if an input of a variable is not connected, like the error cluster for example or if you create Arrays from scratch as you do in your scan VI.
    If you resolve all these Issues you can time the code inside your Loop to see how long it really takes and adjust your scan time accordingly.  The 9074 does not have that much power so you should not expect us timing. 500 Hz is probably a good estimate for the max. Performance for 144 channels and depending on how much time the additional microstrain calculation takes.
    The ECAT driver brings examples which show how to program these kinds of Apps. Another way of avoiding the variables would be the programmatic approach using the variable API.
    DirkW

  • FF4 freezes when loading default homepage, Google and when using search engines

    Whenever I open FF4, it will freeze/hang when loading the default homepage, Google.
    Same with the problem on other search engines, Yahoo!, MSN, Bing, etc.
    Search engines main problem.

    Do you have the McAfee Site Advisor installed? If so, remove it from your PC and try using any search engine with FF. Removing the Site Advisor worked for me, seems like FF 4 b10 isn't compatible with the Site Advisor.

  • Open in same window, when using simple finder window

    When I am using finder windows in simplified mode (no sidebar) any folder I open, pops up a new window. Is it possible to have folders open in the same window?
    Thanks

    noondaywitch wrote:
    Thanks for the correction ref. the opt key, Don. However I always have the finder selection unchecked and in icon view it still opens new windows…
    Odd. When I check or uncheck that item in Finder Preferences, the resultant behavior is as expected in all folder view modes, including Icon view.

  • Finder Folder defaults, not the same defaults when using Office Mac2011

    I might be being a touch simple here - i've got my file formats sorted nicely in Finder (excuse my simple terms here, new to iMac, love it though..) and the default view opens each time without issue.
    What I want now is the same default view when I open, save, save as etc anything out of Office Mac2011. Currently files, documents and folders are all over the shop. I can't find anything obvious like there is in Finder to re-sort the default views etc.
    Anyone help at all...?
    Ta!

    Not possible. The open and save dialog boxes don't reflect what you've set as view options for Finder windows.
    Since you're new to the Macworld, see these and welcome:
    Switching from Windows to Mac OS X,
    Basic Tutorials on using a Mac,
    Mac 101: Mac Essentials,
    Mac OS X keyboard shortcuts,
    Anatomy of a Mac,
    MacTips, and
    Switching to the Mac: The Missing Manual, Snow Leopard Edition.
    Additionally, *Texas Mac Man* recommends:
    Quick Assist,
    Welcome to the Switch To A Mac Guides,
    Take Control E-books, and
    A guide for switching to a Mac.

  • How do you plot multiple curves on the same graph when using a while loop?

    I am writing a program that will plot the IV Output chracterisitcs curves for a MOSFET transistor. I have two sweep variables Vg and Vd. For each Vg valve selected, Vd is swept from its start to stop voltage creating a graph for that Vg valve. Both of the sweeps are done using while loops. Ideally I would like to display all of the Vg plots on the same graph while having the ability to do real-time graphing. Can anyone help me figure this problem out? I have attached my program. Thanks!!
    Tammy
    Attachments:
    outputfin2.vi ‏165 KB

    Hi Tammy & Tica T,
    As far as I see it - this thread is a very bad version of already existing bad version......
    http://forums.ni.com/ni/board/message?board.id=170&message.id=127857
    I expected, that an Applications Engineer from NI knows something about  a Transistor and how an Output characteristic looks like !!  Take a look to a typical Transistor Datasheet ( e.g. n-channel MOSFET) - you will see, that there is no relation of ID vs Time like in your example ( values vs time )  but  IDrain vs VDrain at different VGate's ( no relation to Mr. Bill Gates ).
    Find attached a vi, that in general does what you need - drawing of  curves vs x-axis (XY-graph in use)  - in test_sweep.zip.  And that you geet an impression, how it might be done ...... dynamic Output characteristic of a Transistor with Standard Equipment of a Lab ( Scope + Generator + Power Supply ) find in addition a Frontpanel - picture. One of the interesting points here is - the self-heating effect; visible on ch3 of scope - 5µs Pulse is already a very long time...... This measurement was done in order to compare with our own Transistors......... 
    Hope this helps a little bit to understand, what we are talking about.
    Regards
    Werner
    Attachments:
    test_sweep.zip ‏358 KB
    dynamic Transistor char.png ‏65 KB

  • Reuse of same tab when using same link

    Hi, I got a new third question...
    Safari 3.1.2, Windows XP Pro SP2
    On one of the web pages I use, there is a listing of topics to which I can link. In IE and Firefox, if I right click on one of the topics and select "Open link in new tab", then once that tab is created, if I go back to the original page and just left click on another topic, that topic opens up in the SAME tab that was used for the first topic.
    More precisely, in IE and Firefox:
    1. I am on tab 1 for page 1, and I right click on topic A, choosing "open link in new tab"
    2. tab 2 is created, and topic A is displayed in tab 2
    3. I return to tab 1, which is still displaying page 1
    4. From page 1, I LEFT click on topic B
    5. I return to tab 2, and see topic B displayed in tab 2.
    In Safari, if, in step 4 above, I just LEFT click on topic B, topic B opens up in a new window. In Safari, if, in step 4 above, I right click on topic B and choose "open link in new tab", a completely new tab (tab 3) is created, and tab 2 still displays topic A.
    In Safari, is there a way for me (in step 4) to click on a new topic on tab 1, page 1, and have it display in tab 2, instead of creating a new tab or a new window?
    Thanks,
    Steve

    Is this the part you're confused about?
    'In Safari, if, in step 4 above, I right click on topic B and choose "open link in new tab", a completely new tab (tab 3) is created, and tab 2 still displays topic A.'
    That is the expected operation. But I am guessing that you wanted to see Topic B in a new tab, and you mistakenly opened Topic A in a new tab? If that's the case, how do you open Topic B in a new tab in IE or Firebox? Seems to leave tab #2 alone... which is identical to Safari.

  • Forcing the opendoc call to open in the same page when using web elements

    Hi,
    I'm using the WE Submit web element to send an opendoc call to BOE, I'm calling the same report and re-running with new search criteria.
    Is there a way to force the report to open in the same viewer as opposed to opening a new window?
    Thanks in advance,
    Angela.

    hello Angela,
    i assume that you're using a WETargetPath function along with the submit. normally the submit function should then open the report in the same window.
    for example, if your report has an ID of 12134, then the following code should open the same report in the same window
    stringvar path:= WETargetPath ("rpt", "ID", "12134", "");
    WESubmit ("S1", "Button", "GO", path, '')
    you can also use the last parameter in the WETargetPath to specify a location...using "Same" will force opening in the same window, while "New" will force a new window.
    stringvar path:= WETargetPath ("rpt", "ID", "12134", "weWindow=Same");
    WESubmit ("S1", "Button", "GO", path, '')
    If you've downloaded the latest version of webelements from [here|http://www.sdn.sap.com/irj/boc/webelements] there's a "submit methods" report in the download that you can publish and have a look at the various options.
    cheers,
    jamie

  • Unresolved column when using presentation variable in Answers filter

    Hi all,
    I'm using a dashboard prompt that sets a presentation variable - pres_year. I'm using the presentation variable in a request's filter.
    In the 'Criteria' tab, in the filter for the request, I set a year column (YEAR) to the presentation variable via Variable Expr and enter the presentation variable name only. End up with:
    YEAR is equal to / is in @{pres_year}
    When using the dashboard, the prompt and request all work fine. The problem is when I'm in the request in Answers and I click on 'Display Results' button. I get the following error:
    'NQSError: 27005 unresolved column pres_year'
    Any suggestions?
    Thanks.

    I got same error, if i'm using SQL Expression, instead of variable expression in filter section.
    make sure that you followed this:
    filter on year > Add > Variable > Presentation. Then, give the presentation variable name (which you defined in dashboard prompt) in Variable Expr field , click OK
    getting same error when using:
    Filter on year column > Add > SQL Expression > presentation variable. This is not right place to give presentation variable.
    and, error i got:
    *State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27005]* Unresolved column: "var_Year". (HY000)
    so, make sure that you are suing the right one..

  • Commenting a Line in ABAP Editor when using SAP GUI for java

    Hi,
    In ABAP editor we can highlight the line which are to be comment and use cmd+< sign to comment those lines. What will be the command to be used to achieve the same functionality when using SAP GUI for JAVA on an iMac.

    Hello Kedar,
    please check with SAP GUI for Java 7.20 rev 5 before submitting a bug report.
    Also please verify, that cmd-< and cmd-> are not assigned as "Keyboard Shortcuts" in the "Keyboard" control panel of "System Preferences".
    Bug reports can be submitted with the [SAP Message Wizard|http://service.sap.com/message], for SAP GUI for Java please use component BC-FES-JAV.
    Best regards
    Rolf-Martin

  • Detecting transform errors when using org.xml.sax.XMLFilter

    I am using javax.xml.transform.sax.SAXTransformerFactory.newXMLFilter to transform xml against a pipeline of stylesheets (See function testPipelineTransform in the example below). The process works okay, excepting that I cannot figure out how to detect errors in the transformation process.
    I would like to achieve the same result for the pipeline process as I would for a single transformation using javax.xml.transform.Transformer.setErrorListener. The example below demonstrates how the call to javax.xml.transform.Transformer.setErrorListener does not generate the same result when using org.xml.sax.XMLFilter as it does when using a single transformation.
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.SAXException;
    import org.xml.sax.InputSource;
    import org.xml.sax.XMLReader;
    import org.xml.sax.XMLFilter;
    import javax.xml.transform.ErrorListener;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.sax.SAXTransformerFactory;
    import javax.xml.transform.sax.SAXSource;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.stream.StreamResult;
    import java.io.*;
    public class FilterChain {
        static private final String newline = System.getProperty("line.separator");
         public static void main(String argv[]) {
              System.out.println("Testing pipeline transform");
              testPipelineTransform();
              System.out.println("Testing single transform");
              testXsltSingleTransform();
         } // main
         static private void testPipelineTransform() {
              try {
                   // Set up the input stream
                   BufferedInputStream bis = new BufferedInputStream(
                             new ByteArrayInputStream(getExample().getBytes()));
                   InputSource input = new InputSource(bis);
                   // Set up to read the input file
                   SAXParserFactory spf = SAXParserFactory.newInstance();
                   SAXParser parser = spf.newSAXParser();
                   XMLReader reader = parser.getXMLReader();
                   // Create the filters
                   SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory
                             .newInstance();
                   XMLFilter filter1 = stf.newXMLFilter(new StreamSource(new StringReader(getStylesheet1())));
                   XMLFilter filter2 = stf.newXMLFilter(new StreamSource(new StringReader(getStylesheet2())));
                   // Wire the output of the reader to filter1
                   // and the output of filter1 to filter2
                   filter1.setParent(reader);
                   filter2.setParent(filter1);
                   // Set up the output stream
                   StreamResult result = new StreamResult(System.out);
                   // Set up the transformer to process the SAX events generated
                   // by the last filter in the chain
                   Transformer transformer = stf.newTransformer();
                   transformer.setErrorListener(new ErrorListener() {
                        public void error(TransformerException te)
                                  throws TransformerException {
                             System.out.println("Transform generated Transform Error");
                             System.out.println(te.getMessage());
                        public void fatalError(TransformerException te)
                                  throws TransformerException {
                             System.out
                                       .println("Transform generated Transform Fatal Error");
                             System.out.println(te.getMessage());
                        public void warning(TransformerException te)
                                  throws TransformerException {
                             System.out.println("Transform generated Transform Warning");
                             System.out.println(te.getMessage());
                   SAXSource transformSource = new SAXSource(filter2, input);
                   transformer.transform(transformSource, result);
              } catch (TransformerConfigurationException tce) {
                   // Error generated by the parser
                   System.out.println("\n** Transformer Factory error");
                   System.out.println("   " + tce.getMessage());
                   // Use the contained exception, if any
                   Throwable x = tce;
                   if (tce.getException() != null)
                        x = tce.getException();
                   x.printStackTrace();
              } catch (TransformerException te) {
                   // Error generated by the parser
                   System.out.println("\n** Transformation error");
                   System.out.println("   " + te.getMessage());
                   // Use the contained exception, if any
                   Throwable x = te;
                   if (te.getException() != null)
                        x = te.getException();
                   x.printStackTrace();
              } catch (SAXException sxe) {
                   // Error generated by this application
                   // (or a parser-initialization error)
                   Exception x = sxe;
                   if (sxe.getException() != null)
                        x = sxe.getException();
                   x.printStackTrace();
              } catch (ParserConfigurationException pce) {
                   // Parser with specified options can't be built
                   pce.printStackTrace();
         static private void testXsltSingleTransform() {
              try {
                   BufferedInputStream bis = new BufferedInputStream(
                             new ByteArrayInputStream(getExample().getBytes()));
                   // Set up the output stream
                   StreamResult result = new StreamResult(System.out);
                   InputSource input = new InputSource(bis);
                   TransformerFactory factory = TransformerFactory.newInstance();
                   Source source = new StreamSource(new StringReader(getStylesheet2()));
                   Transformer stylesheet = factory.newTransformer(source);
                   stylesheet.setErrorListener(new ErrorListener() {
                        public void error(TransformerException te)
                                  throws TransformerException {
                             System.out.println("Transform generated Transform Error");
                             System.out.println(te.getMessage());
                        public void fatalError(TransformerException te)
                                  throws TransformerException {
                             System.out
                                       .println("Transform generated Transform Fatal Error");
                             System.out.println(te.getMessage());
                        public void warning(TransformerException te)
                                  throws TransformerException {
                             System.out.println("Transform generated Transform Warning");
                             System.out.println(te.getMessage());
                   SAXSource transformSource = new SAXSource(input);
                   stylesheet.transform(transformSource, result);
              } catch (Exception exc) {
                   exc.printStackTrace();
         private static String getStylesheet1() {
              return
                     "<?xml version='1.0' encoding='ISO-8859-1'?>" + newline
                   + "<xsl:stylesheet" + newline
                   + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" + newline
                   + "version='1.0'>" + newline
                   + "<xsl:output method='xml'/>" + newline
                   + "<xsl:template match='/'>" + newline
                   + "<DontCareAboutContent></DontCareAboutContent>" + newline
                   + "</xsl:template>" + newline
                   + "</xsl:stylesheet>" + newline;
         private static String getStylesheet2() {
              return
                     "<?xml version='1.0' encoding='ISO-8859-1'?>" + newline
                   + "<xsl:stylesheet" + newline
                   + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" + newline
                   + "version='1.0'>" + newline
                   + "<xsl:output method='html'/>" + newline
                   + "<xsl:template match='/'>" + newline
                  + "<html><body>" + newline
                 + "<xsl:message>" + newline
                 + "Error Message for the xslt processor" + newline
                 + "</xsl:message>" + newline
                 + "Dont care about the xslt content," + newline
                 + "The only significant part is the xsl:message element" + newline
                 + "which results in a error to be handled by the xslt" + newline
                 + "processor" + newline
                   + "</body></html>" + newline
                   + "</xsl:template>" + newline
                   + "</xsl:stylesheet>" + newline;
         private static String getExample() {
              return
                     "<?xml version='1.0' encoding='ISO-8859-1'?>" + newline
                   + "<DontCareAboutContent>" + newline
                   + "</DontCareAboutContent>" + newline;
    }

    I made the following change which solves the problem but the sollution is tightly coupled to Xalan. If anyone has any ideas, I would still like to find a way to achieve the desired result using JAXP API's.
                   XMLFilter filter1 = stf.newXMLFilter(new StreamSource(new StringReader(getStylesheet1())));
                   if (filter1 instanceof org.apache.xalan.transformer.TrAXFilter) {
                        ((org.apache.xalan.transformer.TrAXFilter)filter1).getTransformer().setErrorListener(...);
    ...

  • Slow(er) startup when using captive runtime on windows

    I  just converted two AIR apps from native exe installers (requiring AIR installed) to Captive Runtime relases (just a folder structure).
    One difference i see is that my applications now load a little slower (because of the packaged instead of installed runtime?).
    When using flex 4 sdk the white and centered flex4-loadbar now appears for a few seconds before the splash screen of the app. appears. The same happens when using flex 3 sdk (in compatibility mode) but instead the "initializing" text appears.
    Is this slowdown a known effect of the captive runtime packaging?

    I responded to your other thread in the bugs forum but wanted to also respond here.
    I'm not aware of any slower performance implications when using the captive runtime but I'm going to investigate further.  In the meantime, would you mind opening a new bug over at bugbase.adobe.com regarding the startup performance hit?  It would be great if you could also provide us with a sample application that illustrates the slower startup time.  If you'd like to keep it private, please email me directly at [email protected]
    Thanks,
    Chris

  • WMI InvokeMethod for StartService does not work when used with ManagementOperationObserver on IIS

    Hi,
    I am using .net 4.5 and C# to remotely restart the services. I am using WMI to do this task.  This code works when called from windows application on the machine, but same code when used inside web application it gives exception of invalid parameter.
    We saw it log error in System Event log 
    The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID
    {49BD2028-1523-11D1-AD79-00C04FD8FDFF}
     and APPID
    {49BD2028-1523-11D1-AD79-00C04FD8FDFF}
     to the user IIS APPPOOL\<app pool user> SID (S-1-5-82-634865507-143429395-1373251082-3464226226-3883016302) from address LocalHost (Using LRPC). This security
    permission can be modified using the Component Services administrative tool.
    I am pasting below code for reference.
    m.InvokeMethod(observer, "Startservice", null, null);
    //wait until invoke method is complete or 30 sec timeout
    int intCount = 0;
    while
    (!completionHandlerObj.IsComplete)
    if (intCount > 60)
    MessageBox.Show("Inside 30 seconds");
    break;
    //wait 1 sec.
    System.Threading.Thread.Sleep(1000);
    //increment counter
    intCount++;
    //see if call was successful.
    if (HandlerObj.ReturnObject.
    Properties["returnValue"].Value.ToString() == "0")
    isStarted = true;
    Dhanaji

    For web apps the context will be the context of the app pool.  Unless you set the app pool to run as a user account that has admin privileges on the remote machine then you won't be able to control the services on a remote machine.  If you have
    enabled Win auth such that the app runs in the context of the remote user then you might need to turn on delegation otherwise the hop won't work.
    Note that if you are using Win auth then consider using ServiceController instead which provides the same functionality as WMI but with a cleaner syntax.  This wouldn't work if you need to impersonate a user though.
    Michael Taylor
    http://blogs.msmvps.com/p3net

Maybe you are looking for