Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Batch Files - Not a Valid Win32 Application
#1
I am trying to run a batch file from a triggered event and when I test it I get the following error

Could not start external process: c:\CQCDataFiles\testlog.bat

%1 is not a valid Win32 application.

This is the action

System::ExecApp
P1=c:\\CQCDataFiles\\testlog.bat
P2="Test Run of script"
P3=
P4=Show

So I don't understand what is going wrong. It runs fine when executed from the command line.

I tried to search for this issue but did not find anything so I have to ask unfortunately.

Mick
Mykel Koblenz
Illawarra Smart Home
Reply
#2
When you run a batch file from the command line, what actually happens is that the command line interpreter runs another program and passes that batch file to it as a parameter, so you have to do the same.

So you would do either:

C:\Windows\system32\cmd.exe /k whatever.bat

or

C:\Windows\system32\cmd.exe /c whatever.bat

/k means keep the window open after it's done, and /c means close the window after it's done. If running from the background then use /c always.
Dean Roddey
Explorans limites defectum
Reply
#3
Is that documented anywhere (and I missed it)?

Does that mean then that P2 will be the parameter to the cmd.exe file being run and what about passing in parameters to the batch file.

i.e. which of the following is correct.

System::ExecApp
P1=C:\\Windows\\system32\\cmd.exe /c c:\\CQCDataFiles\\testlog.bat
P2="Test Run of script"
P3=
P4=Show

System::ExecApp
P1=C:\\Windows\\system32\\cmd.exe
P2=/c c:\\CQCDataFiles\\testlog.bat "Test Run of script"
P3=
P4=Show

or neither.

The batch file has parameters are pssed to it that are used for doing different tasks
Mykel Koblenz
Illawarra Smart Home
Reply
#4
The second one would be correct.
Dean Roddey
Explorans limites defectum
Reply
#5
It does not work.

Well it partially works. The batch file executes but in the batch file is a line to echo to a file and this file is not created.

If I run the same command from the command line the file is created with the passed in parameter as expected. When I run it from a scheduled event CQC return a successful result and the echo is sent to the screen.

cmd /? return quite a number of pages to read, but considering that it works at the command line tells me that I have the syntax right and that CQC might be doing something funky.

Edit
I removed the last parameter that was supposed to be passed into the batch file and the execution was as expected with the file created, but obviously without the value that needs to be passed in causing issues the execution is pointless
Mykel Koblenz
Illawarra Smart Home
Reply
#6
Are you running the app shell service as a regular admin account? If not, you might not have the rights to create the file, depending on where you are running it.

Oh, and you might actually need to include the batch file parameters in the same invocation parameter as the batch file itself, so it all gets run as one thing, i.e:

"c:\\CQCDataFiles\\testlog.bat 'Test Run of script'"

Not sure if that will work, but try it. Using the single quotes on the parameter allows the batch file name and the parameter to be quoted.

If that doesn't work, just for sanity's sake, do something like:

"c:\\CQCDataFiles\\testlog.bat TestRunOfScript"

I.e. no spaces so it doesn't need the internal quotes, and see how that does. But I'm guessing that the command line interpreter just passes the whole thing to Cmd.exe as a single parameter and let's it parse it out.
Dean Roddey
Explorans limites defectum
Reply
#7
service runs as my account so it has the right security priv's to write.

The quotes dont work. It tries to run a file named testlog.bat TestRunOfScript i.e. a file by the name of whatever is inside the double quotes.
Mykel Koblenz
Illawarra Smart Home
Reply
#8
You'll probably have to do some spelunking to see how what you are sending in is coming out. Go to the Admin Interface and do a simple key mapped action. Have it use /c instead /k so that it leaves the window open. Take out any ECHO OFF from the command line so you can see what is happening.

It may be that the file doesn't get created because the actual value to the command file has the quotes on it, and would need to be stripped off. You'll be able to tell if you do it like above and just ECHO of the parameters sent in and see what they show up as.
Dean Roddey
Explorans limites defectum
Reply
#9
last test yielded a result closer to the desired outcome, but still issues

/c is being used, that is how I was able to report on what I was seeing.

I ran with a parameter "c:\cqcdata\testlog.bat" testrun and the parameter testrun was passed to the batchfile

Tried "c:\cqcdata\testlog.bat" "test run" and no parameter was passed.

Something about the quotes is obviously the key to getting the last parameter to be passed in correctly.
Mykel Koblenz
Illawarra Smart Home
Reply
#10
I don't see why there would be any difference between the two from CQC's point of view. Ultimately, when it's invoked testrun will become "testrun" anyway. However, it may be that "test run" becomes ""test run"". That would ultimately turn out to be maybe an empty parm, test, run, and an empty parm. Print out %1, %2, %3, and %4 and see if that is what is happening.
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Audio files not loading dman000000 17 7,674 07-12-2013, 05:38 PM
Last Post: dman000000
  Load personal video files into repository? brathnach 7 4,154 05-14-2013, 02:06 PM
Last Post: wuench
  Load existing ripped files into CQSL Repository? kcl 14 4,601 12-23-2012, 12:11 AM
Last Post: Dean Roddey
  UltraEdit CML and PDL Syntax files batwater 6 3,224 08-22-2012, 01:45 PM
Last Post: batwater
  Help with error of "is not valid IP end point address" Sendero 5 1,745 07-18-2009, 06:00 PM
Last Post: Dean Roddey
  Playing WAV Files gacevich 3 1,754 06-15-2009, 07:39 AM
Last Post: Dean Roddey
  Problems with File Tag Repository and Zune files CalypsoCowboy 4 2,128 03-19-2009, 07:35 AM
Last Post: CalypsoCowboy
  Adding MP3 files to CQC Repository flik 4 1,802 03-14-2009, 04:44 PM
Last Post: Dean Roddey
  Html files not showing Trioxide 4 1,813 01-07-2009, 09:56 AM
Last Post: Trioxide
  Problem with Displaying html Files in htmlroot kblagron 7 2,432 09-12-2008, 03:23 PM
Last Post: Dean Roddey

Forum Jump:


Users browsing this thread: 1 Guest(s)