Executescript not executing...

Hi all,

I have written a procedure which controls the writing of a batch file and executes it through executescript
here is the command:
executeScriptText/Z/B "C:\\hysplit4\\cluster\\working\\batch_CCONTROL.bat"

Although the batch with this command is launched on my computer, it is not the case on other PCs.... is there any known reason why this should happen?


some hints:
- tried to run Igor in Administrator mode, but doesn't work.
- removed the /Z flag, but didn't get an error message.
- here is the function that writes the batch file
Function CCONTROL_batch()
    SetDataFolder root:ZeFir:data2use:
    NVAR/Z Hours2Cluster=root:ZeFir:Traj_A:variables:Hours2Cluster
    NVAR/Z SkipTraj=root:ZeFir:Traj_A:variables:SkipTraj
    NVAR/Z SkipEndpoints=root:ZeFir:Traj_A:variables:SkipEndpoints
    string Batch_str=""
    Batch_str+="cd C:/hysplit4/cluster/working/;"
    Batch_str+="echo "+num2str(Hours2Cluster)+"  >>CCONTROL;"
    Batch_str+="echo "+num2str(SkipTraj)+"  >>CCONTROL;"
    Batch_str+="echo "+num2str(SkipEndpoints)+"  >>CCONTROL;"
    Batch_str+="echo C:/hysplit4/cluster/working/  >>CCONTROL;"
    Batch_str+="echo 0  >>CCONTROL;"
    Batch_str+=";"
    Batch_str+="/hysplit4/exec/cluster;"
    Make/T/O/N=(ItemsInList(batch_str, ";")) batch_txt
    batch_txt = StringFromList(p, batch_str, ";")
   
    Newpath/O/Q BatchPath, "C:hysplit4:cluster:working:"
    sleep/s 1
    Save/T/G/O/M="\r\n"/P=BatchPath Batch_txt as "batch_CCONTROL.bat"

    Killwaves batch_txt

End Function



Thanks!
J-E
I recently found that you need to use /C with cmd.exe to execute a DOS batch file. This led me to add this example to the Igor 7.04 help:

//  Windows: Execute a DOS command and get output, if any
// ExecuteDOSCommand(command, maxSecondsToWait)
// Executes a DOS command and returns any output text as the function result.
// Returns "" if the DOS command returns no text.
// maxSecondsToWait is the maximum number of seconds to wait for DOS to finish
// the command. If it takes longer than that, an error is generated.
// This function creates files in the Igor Pro User Folder:
//      igorBatch.bat   Holds command that DOS is to execute
//      igorBatchOutput.txt Holds output generated by DOS command, if any
// Example:
//      Print ExecuteDOSCommand("echo %PATH%", 3)
Function/S ExecuteDOSCommand(command, maxSecondsToWait)
    String command  // e.g., "echo %PATH%"
    Variable maxSecondsToWait   // Error if DOS takes longer than this
   
    String quoteStr = "\""
   
    // Get path to batch file in "Igor Pro User Files"
    String dirPath = SpecialDirPath("Igor Pro User Files", 0, 0, 0)
    dirPath = ParseFilePath(5, dirPath, "\\", 0, 0) // Convert to Windows path
    String batchFilePath = dirPath + "igorBatch.bat"
    String batchOutputFilePath = dirPath + "igorBatchOutput.txt"
   
    DeleteFile/Z batchOutputFilePath

    // Write DOS command to batch file
    String dosCommand = command + " > " + quoteStr + batchOutputFilePath + quoteStr
    Variable refNum
    Open refNum as batchFilePath
    FBinWrite refNum, dosCommand
    Close refNum
   
    // Execute batch file
    // The DOS command must complete in the number of seconds specified via /W
    // /C means cmd.exe quits after executing the command
    String text
    sprintf text, "cmd.exe /C \"%s\"", batchFilePath
    ExecuteScriptText/W=(maxSecondsToWait) text
   
    // Get output
    String result = ""
    Open/R/Z refNum as batchOutputFilePath
    if (V_flag != 0)
        result = ""
        // result = "<No output was generated by batch file>"   // For debugging
    else
        // Read contents of batch file into string
        FStatus refNum
        Variable numBytesInFile = V_logEOF
        result = PadString("", numBytesInFile, 0x20)
        FBinRead refNum, result
        Close refNum
    endif
   
    return result
End