From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

system exec not executing windows restart properly

When I enter "shutdown /f /t 0" into the input, system exec just won't execute this command and returns a generic error.   This command is used to restart the operating system and it's located in %windir%\system32\ folder.  Other commands from this folder works fine, e.g., taskkill, ipconfig, etc.. But why not "shutdown /f /t 0"?  Anyone have any suggestion?  A screenshot will do just fine.  Thanks.

0 Kudos
Message 1 of 7
(3,513 Views)

And that generic error that you get would be?

 

Have you tried prepending "cmd /c" to the command?

0 Kudos
Message 2 of 7
(3,506 Views)

When wiring "shutdown /f /t 0" into the input and get a generic error of code 2 msg: system exec.vi command "shutdown /f /t 0".

 

When wiring "cmd /c "shutdown /f /t 0" into the input, I get no error but a msg of shutdown is not recognized as an external or internal program.

 

When wiring "cmd /c "%windir%\system32\shutdown.exe /f /t 0" into the input, I get no error but a msg of c:\windows\system32\shutdown.exe is not recognized as an external or internal program.  But that's not true because that file exists.

 

system exec.vi is always a struggle for me because it's never working too accurately.  Some windows command works some don't.  For example, ipconfig & taskkill goes through just fine.

 

If you would like to see how the restart command works, just go to your command prompt, type in "cmd /c "shutdown /f /t 0"" or "shutdown /f /t 0""and you'll see it works.

0 Kudos
Message 3 of 7
(3,499 Views)

I know what the shutdown command is - I use it all the time for remote connections.

 

That error code is what Windows is returning, not LabVIEW. Windows is telling you it can't find the file. Remember that System Exec is basically equivalent to entering a command in the Start -> Run window, not a command window. Thus, do you get the same issue if you do it there? Another question: are you wiring it to the "command line" input? Are you setting the "working directory"? If so, don't set the working directory. Have you checked your PATH environment variable?

0 Kudos
Message 4 of 7
(3,487 Views)

If you are using a 64-bit OS, the problem this user had may be your problem.

Message 5 of 7
(3,476 Views)

Hey lavalava,

 

I second Matthew, and Kudos to him for beating me to the post! This sort of system exec issue, especially one dealing with a primitive command like shutdown, is almost always due to a 32-bit application being called in a 64-bit OS. Here is a link to the Microsoft information on how to properly format the command, and the reason for the error. Let us know if that doesn't work for you. Have a great evening!

John B.
Embedded Networks R&D
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 6 of 7
(3,451 Views)

 


@Matthew Kelton wrote:

If you are using a 64-bit OS, the problem this user had may be your problem.


Ooooh... good point.

 

0 Kudos
Message 7 of 7
(3,446 Views)