Jump to content
News about the LabVIEW Wiki! Read more... ×
BobbyCee

Running System Exec vi as Administrator in Win7

Recommended Posts

Has anyone been able to run the 'System Exec.vi' as Administrator using Win7?

I have a service that I need to start and stop and can do so with the following cmd line: cs start mxchange OR cs stop mxchange

The catch is, in Win7 I need to be running CMD as Adminstrator

Any suggestions?

Share this post


Link to post
Share on other sites

Looks like I found the solution to my problem.

After changing the User Account Control settings to 'Never Notify' and rebooting, I was able to run System_Exec.vi with my Start / Stop service commands successfully.

Share this post


Link to post
Share on other sites
Looks like I found the solution to my problem.

Hey Bob - would you mind adding that info to the LabVIEWiki ?

Share this post


Link to post
Share on other sites

OK, Wiki sounds like a good idea.

I am also experimenting with a .NET assembly to perform the same task as the System_Exec.vi. I think I may be able to write .NET code that will allow Win7 application control to maintain higher User Level Security and still Start and Stop my desired local service.

Share this post


Link to post
Share on other sites

OK, Wiki sounds like a good idea.

I am also experimenting with a .NET assembly to perform the same task as the System_Exec.vi. I think I may be able to write .NET code that will allow Win7 application control to maintain higher User Level Security and still Start and Stop my desired local service.

I believe that in order to start and stop a service you need to have administration privileges in Windows 2000 higher. Windows Vista and higher might even require specifically elevated privileges that an administrator account doesn't automatically grant to an executable, but requires an additional explicit User Authentification as administrator.

It would be strange that CMD.EXE itself is requiring elevated privileges but it is the service manager start and stop command you try to execute in CMD.EXE that is barking on the to low privileges you have as normal user. .Net can't circumvent the privilege level control for the service control manager but it might have extra support to allow temporary privilege elevation for the current executable for execution of service control manager commands which would require at least the according admin login credentials somehow (and if they care about security it won't be a programmatic login but an interactive login).

Share this post


Link to post
Share on other sites

I believe that in order to start and stop a service you need to have administration privileges in Windows 2000 higher. Windows Vista and higher might even require specifically elevated privileges that an administrator account doesn't automatically grant to an executable, but requires an additional explicit User Authentification as administrator.

It would be strange that CMD.EXE itself is requiring elevated privileges but it is the service manager start and stop command you try to execute in CMD.EXE that is barking on the to low privileges you have as normal user. .Net can't circumvent the privilege level control for the service control manager but it might have extra support to allow temporary privilege elevation for the current executable for execution of service control manager commands which would require at least the according admin login credentials somehow (and if they care about security it won't be a programmatic login but an interactive login).

You are correct, higher administrative privileges are needed to control services. I have found that the .NET architecture is more flexible than simply using System_Exec.vi with string commands and therefore I will be pursuing the .NET method to handle querying, starting, and stopping my local services. However, I will have to talk with the system owner regarding the removing the User Access Control level that prevents interaction at the service level. I am fortunate to have a number of in-house resources to offer expert advice on .NET coding and will share my findings with the LAVA community.

Share this post


Link to post
Share on other sites

OK... I got intrigued by this whilst waiting for an installer test to finish running and came up with a little something that works:

post-9667-126635704751_thumb.png

Hope this helps,

Shaun :)

Share this post


Link to post
Share on other sites

OK... I got intrigued by this whilst waiting for an installer test to finish running and came up with a little something that works:

post-9667-126635704751_thumb.png

Hope this helps,

Shaun smile.gif

Thanks for the code snipet, Shaun. I did try out your method and had a User Account Control popup appear. I did some futher MSDN reading and it looks like via impersonation I may be able to run my administrator account elevated so as to not need to acknowledge the UAC popup. This system will be used without a monitor and will not have user interaction. I need to keep standard permissions on the box because the system will be on a network and I want to limit people running scripts that could affect system operation.

I will post this code as soon as I get it tested successfully. Thanks again for showing me another way to access Process Start Info processes!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use.