LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

cmd /c and windows 10 protection

In the past I have successfully used cmd /c in my code with such example as

   LaunchExecutableEx (cmd /c format r: /fs:ntfs /q /y, LE_HIDE, &handle);

 

But now under windows 10, I get the error message:"access denied as you do not have sufficient privileges.  You have to invoke this utility running in elevated mode."

So how should I temporarily get to elevated mode to execute this in-line command, then subsequently exit elevated mode?

0 Kudos
Message 1 of 4
(4,047 Views)

Can you "Run as Administrator" or ask your server provider to allow you to have adminstrator privileges? 

0 Kudos
Message 2 of 4
(4,012 Views)

Roxanna,

 

I have found a solution to this issue.   Note that Win 10, 64 bit has become strict in requiring previleges with certain operations such as formating a drive.  In CVI the LaunchExecutableEx( ) function no longer works adequately in a quiet, hidden way with such example as:

   LaunchExecutableEx("cmd.exe /C format R: /fs:ntfs /q /y", LE_HIDE, &handle);

 

I came across a program called elevate.exe as referred to the link: https://jpassing.com/2007/12/08/launch-elevated-processes-from-the-command-line/  that places the command line in elevated mode prior to launching the format command.  Source code is provided at this link.  The elevate.exe accomplishes the elevation by doing a shell execution.  The expression now becomes:

   LaunchExecutableEx("elevate cmd.exe /C format.com R: /fs:ntfs /q /y:, LE_HIDE, &handle);

 

Conclusion:  For WIn 8, Wind 10, and onward the LaunchExcutableEx( ) function needs to be upgraded with an optioned ability to raise to elevated mode for the launch of an executable.  The development team should become aware of this.

 

Regards,

Steve Macha

Mikrokraft, Inc., c/o Cooper Consultaing Service, an alliance partner

smacha@windstream.net

0 Kudos
Message 3 of 4
(3,908 Views)

Hi Steve,

 

Thank you so much for the feedback. I will bring them in on the loop about this. 

 

 

0 Kudos
Message 4 of 4
(3,787 Views)