LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

System Exec returns Windows error 193 on command requiring UAC, where it works on Windows CMD

I am trying to get a VI to create a scheduled task in Windows and having trouble with System Exec returning error 193 (Not valid Win32 application). If I copy and paste the same command as the error output says I executed to a Windows cmd prompt it executes fine, although it does pop up a UAC window for me to click Yes. This is in Windows 7. When I run the code in LabVIEW, it doesn't pop up the UAC and just gives the error. Here is the command I am trying to execute. The reason I am executing an .exe.lnk is because schtasks needs to be run as Administrator so I have created a shortcut with the property set "Run as Administrator" to call from System Exec since it doesn't seem to support running as Administrator on its own.

 

"C:\Users\britehappy\Documents\Projects\My Project\Source Code\schtasks.exe.lnk" /Create /tn ATU_Reports /tr C:\Windows\System32\calc.exe /sc WEEKLY /d MON /st 10:37 /f

0 Kudos
Message 1 of 5
(5,494 Views)

I decided to just give up and use the .NET process library instead to execute the command and it works just fine. I would still be interested in seeing any replies on how to get the LabVIEW system exec to handle this type of situation, however.

0 Kudos
Message 2 of 5
(5,485 Views)

Hey, if the comand works from the windows side, maybe some of your set up could be sending something different, how is your VI doing this?

 

0 Kudos
Message 3 of 5
(5,442 Views)

@britehappy wrote:

"C:\Users\britehappy\Documents\Projects\My Project\Source Code\schtasks.exe.lnk" /Create /tn ATU_Reports /tr C:\Windows\System32\calc.exe /sc WEEKLY /d MON /st 10:37 /f


Is that the full command-line string you're calling/passing into System Exec? You would normally put a cmd /c "my command" (escaping the quotes from your command above) in front of it when running shell commands.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 5
(5,425 Views)

It may help to run the actual EXE and not the shortcut to the EXE.

0 Kudos
Message 5 of 5
(5,423 Views)