Passing Parameters to a Batch File from Javascript Inside Hyperion Interactive Reporting Studio

StackOverflow https://stackoverflow.com/questions/19989157

  •  30-07-2022
  •  | 
  •  

Question

Inside of Hyperion Reporting Studio I have a document level script where I wish to call a batch file and pass arguments to the batch file.

Here is the code I have:

var Path = "W:\\directory\\Reference_Files\\scripts\\vbs\\SendEmail.bat"
var Email = "my.email@xxx.com"
var Subject = "My Subject"
var Body = "My Body"
var Attach = "W:\Maughan.xls"

Application.Shell(Path + " " + Email + " " + Subject + " " + Body + " " + Attach)

This code does not open the file, but gives the error message The filename, directory name, or volume label syntax is incorrect.

If I pass Path by itself my bat file runs (giving me a warning because no parameters are passed) and I when I run the same code from the Shell Command, it works flawlessly.

Can anyone provide any insight into the correct syntax to pass into the Application.Shell method so that it reads my parameters and passes them to the batch file? I have been searching high and low online to no avail.

Was it helpful?

Solution

Because var Attach = "W:\Maughan.xls" should be var Attach = "W:\\Maughan.xls".

Within a string the escape character \ just escapes the next character so Attach will contain just W:Maughan.xls. To add \ you need to use \ twice.

Update:

It may have no difference in this particular case, because W:Maughan.xls means to look for Maughan.xls in the current directory on the drive W which is most likely \.

But what is definitely important are quotes around the parameters Subject and Body. In you code the constructed command is

W:\directory\Reference_Files\scripts\vbs\SendEmail.bat my.email@xxx.com My Subject My Body W:Maughan.xls

I sure that the bat file cannot distinguish between the subject and body (unless it expect exactly two words in each of them) so the right command most likely is

W:\directory\Reference_Files\scripts\vbs\SendEmail.bat my.email@xxx.com "My Subject" "My Body" W:\Maughan.xls

and you can check it by running the command above in cmd.

To construct it the parameters should be modified as follows:

var Path = "W:\\directory\\Reference_Files\\scripts\\vbs\\SendEmail.bat"
var Email = "my.email@xxx.com"
var Subject = "\"My Subject\""
var Body = "\"My Body\""
var Attach = "W:\\Maughan.xls"

(this correction was inspired by impinball's answer)

OTHER TIPS

Try putting an escaped quote on either side of the variable values. Depending on where the directory is, that may make a difference. The outside quotes in strings aren't included in the string values in JavaScript. Here's an example of what I'm talking about:

var Path = "\"W:\\directory\\Reference_Files\\scripts\\vbs\\SendEmail.bat\""

instead of

var Path = "W:\\directory\\Reference_Files\\scripts\\vbs\\SendEmail.bat"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top