LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Launch an application from a Windows service created by LabVIEW

If I lauch Excel from a Windows service (created by LabVIEW), does Excel run as current user?  Does Excel visible to the current user?  Has anyone does this before?

TIA.

 

OS: WinXP.

George Zou
0 Kudos
Message 1 of 4
(2,825 Views)

That depends on a lot of things. You can configure a service to be started in a certain account. Typically services are started under the LocalSystem account and do not allow any desktop interactions. But you can install the service to run under a different account and also allow it to have desktop interaction (but only if it is started under LocalSystem and only before Windows Vista).

 

Any executable started by a LabVIEW application through System Exe will simply inherit the account settings and permissions of the LabVIEW application. For anything else you'll have to dig into CreateProcess() and setup your own access permissions values to be passed to CreateProcess() or you can use CreateProcessAsUser() but it still requires the according user handle that you somehow have to determine and open.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 4
(2,810 Views)

> But you can install the service to run under a different account and also allow it to have desktop interaction

> (but only if it is started under LocalSystem and only before Windows Vista).

Don't understand.  I need to show a dialog window to user.  So should I use the LocalSystem or a different account?

 

> Any executable started by a LabVIEW application through System Exe will simply inherit the account settings and

> permissions of the LabVIEW application.

That's what I thought.

 

> For anything else you'll have to dig into CreateProcess() and setup your own access permissions values to be passed

> to CreateProcess() or you can use CreateProcessAsUser() but it still requires the according user handle that you somehow

> have to determine and open.

The problem is that the "current user" has no password.

BTW, the "current user" has admin privilege.

 

 

 

George Zou
0 Kudos
Message 3 of 4
(2,799 Views)

Only services logged in as LocalSystem can be set to interact with the desktop. For others it is ignored. The MSDN documentation is also not completely consistent as they say at some point that interaction under Vista and later is not possible anymore, but later describe how a registry setting does disable that option by default in XP and earlier and is set to enable it by default in Windows 7 and later. Go figure.

 

If you want to gain access rights for a specific user you have to do impersonation. For that you need either a connection like a pipe that is connected to an application running under that user and can then temporarely gain the access right of that user or you need all the authentification credentials to do an LogonUser() and use the returned handle to do an ImpersonateLoggedOnUser(). However if a message bos is all that you need, you may try WTSSendMessage().

 

Take a look here about the topic and decide yourself if the information is consistent: http://msdn.microsoft.com/en-us/library/windows/desktop/ms683502%28v=vs.85%29.aspx

 

One thing you should be aware of, is that there might and often is no user logged in on a machine, especially if it is a server oriented machine and then you can not display a message box at all since there is no active desktop to do so.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 4 of 4
(2,776 Views)