LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
srdfrn

Run as Administrator Option for System Exec VI

Status: New

It would be nice to add another dimension to the system exec.vi that gives the user the option to open up the “Run as Administrator” command prompt in Windows 7.  This would enable a system administrator to use LabVIEW to make certain, currently restricted, changes to the computer.  I don’t believe it would create a security risk because you have to be logged in as an administrator anyway to have the access rights

 

As far as I’ve seen, there really is no string that you can enter into the command line that will instruct an elevated command prompt to open.   With this added functionality in the system exec vi, however, you will be given more flexibility with what you can do through your LabVIEW program.

 

Elevated?

Stephanie R.
National Instruments
8 Comments
Intaris
Proven Zealot

You can do this already using the "runas" command at the command prompt.

 

Look HERE.

 

PS whilke the reference is for windows XP, the command line utility seems to be still there in Win7.

srdfrn
NI Employee (retired)

Thanks for the suggestion, but I have been having trouble doing this in Windows 7.  The issue arises when you have to enter your admin password directly into the command prompt.  What I am looking for is a way to open up the elevated command prompt from the get-go, as you do, for example, when you right-click the command prompt .exe and select "Run as Administrator".


Have you tried doing this in Windows 7?  If you can figure out a way to execute it properly, please let me know!

Stephanie R.
National Instruments
Intaris
Proven Zealot

I haven't tried in Win7 but it always prompted me in WinXP.  Maybe I'll get around to trying it....

 

Intaris
Proven Zealot

I might have a workaround.

 

Try "cmd.exe start runas /user:USER Program.exe"

 

This should start a second command prompt window to prompt you for the password.  I don't have LV on my WIn7 machine so I can't test it myself but it works from a batch file.

Joe_Gerhardstein
Member

The following link also shows a method to do this where you create a shortcut to the application you want to run (such as c:\windows\system32\cmd.exe"), then you can click the "Run as Administrator" option for the shortcut.  Calling the shortcut then runs as Administrator.

 

http://www.howtogeek.com/forum/topic/run-cmd-as-administrator

 

 

Joe Gerhardstein
Viasat
Certified LabVIEW Architect
Certified TestStand Developer
Certified Professional Instructor
http://www.viasat.com
MichaelAivaliotis
Active Participant

I think this is a great idea.



Michael Aivaliotis
VI Shots LLC
nelg87
Member

This is exactly what I need right now!  I'm trying to disable one of my NIC cards on a test PC at work and I need to do it programatically at a certain point in my program.  Well in Windows 7 this is not working because the system exec vi does not come up as an administrator window and it's not letting me use "netsh" commands! 😞  This idea will be very convenient to have!

BlueNoser
Member

I needed to execute an 'arp -d' command from LabVIEW and hit this requirement to elevate to administrator.

 

When I launched my development environment using right click>Run as administrator, the call to the cmd line (System Exec.vi) appears to inherit the "Run as administrator" option.  The 'arp -d' executes as administrator and clears the arp table and there is no error message.

When I build my executable and set the properties on it so it always runs as administrator it still works.  If I turn off the "Run as administrator" it goes back to generating the error message.