AIR doesn't permit launching .bat files as a native process directly, so apparently i'm suppose to set CMD.exe as my startupInfo executable and pass my .bat file and it's arguments.
i can't get it to work, so i'm hoping it's a syntax problem. here is my code:
var testStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
testStartupInfo.executable = new File("C:\\WINDOWS\\system32\\cmd.exe");
var processArguments:Vector.<String> = new Vector.<String>();
processArguments[0] = "/c";
processArguments[1] = "\"C:\\Documents and Settings\\Administrator\\Desktop\\Test\\Test.bat\"";
processArguments[2] = "-testBatPeram1";
processArguments[3] = "-testBatPeram2";
processArguments[4] = "Peram3";
processArguments[5] = "C:\\Documents and Settings\\Administrator\\Desktop\\SaveText.txt";
testStartupInfo.arguments = processArguments;
var test:NativeProcess = new NativeProcess();
test.start(testStartupInfo);
the batch file and its parameters work fine if i manually write them in the command line prompt, so i don't know why nothing is happening when launched from AIR.
Ok i think that by now (3 months later) you have realized that this doesn't work because your bat file path contains spaces.
Have you find any workaround or solution or something?
I have a good approximation that could be enough for you:
Instead of passing parameters to your bat try writing to it through its stdinput.
I mean, instead of passing parameters when calling your bat, treat that info as a variable read in execution.
Related
I heard that you can't merge to .exe files to gether so I thought what will happen if i stored the executable app as binary inside my app and then built it.
In python I did it:
myappBinary =
with open("sample.exe", 'wb') as outf:
outf.write(b'''3\xb4\xcb^\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x''') # for example
but in Vb.net I can't even store the binary data, any help?
I tried:
Dim content() As Byte = <![CDATA[3\xb4\xcb^\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x]]>.Value
And I tried to call the cmd to run echo BINARYDATA > sample.exe and it's not working
Then I tried:
Dim content As Byte = "3\xb4\xcb^\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x"
every time it shows me this msg Value of type 'String' cannot be converted to 'Byte()' or something realted to it
THE PROBLEM WILL SOLVED IF I CAN STORE A BINARIES DATA AND WRITE THEM.
I know that i can simply read an .exe file using Dim data2() As Byte = File.ReadAllBytes("myApp.exe") but i want to store the data in a variable.
Any help?
I'd like to write a macro with SE MTF Nyquist plugin in fiji for a stack or many images in a directory. But I have to set some parameter for every image in a setting window. Any ideas?
macro "TD2"{
inputFolder = getDirectory('');
outputFolder = gerDirectory('');
setBatchMode(true);
images = getFileList(inputFolder);
for ( i=0; i <images.length;i++){
inputPath = inputFolder + images[i];
open(inputPath);
makeRectangle(1632, 568, 684, 296);
run("SE MTF Nyquist");
outputPath = outputFolder + images[i];
save(outputPath);
close();
}
}
setBatchMode(false);
exit();
It depends if you want to use the same parameters, or different ones, for every image.
But before you tackle that question, you need to know if the macro can pass the parameters to the plugin. Some plugins are macro-recordable and some are not.
Try recording the command in the Macro Recorder and see if the parameters show up in the recorder window. If so, then you can replace them in your macro with the desired numbers or variables as needed.
If the plugin is not macro-friendly (that is, you just get the "run" command with no arguments as shown in your code), you could try to modify it following the guidelines in section 11 "Designing macro-aware plugins" in the macro programming guide.
I have written some code which runs a script using wscript.exe.
Set oShell = CreateObject("Shell.Application")
oShell.ShellExecute "wscript.exe", strPath2Script, , "runas", 1
Key to this is the "runas" which allows us to run as an admin. This all works fine, but I also have to have additional code elsewhere to create a script file. This seems like a waste, and I would prefer to just send in the code in the file located at strPath2Script as a parameter to wscript.
It doesn't seem like that is possible, and if I have to generate the script, so be it, but is it possible to just send code as a string into wscript.exe rather than have to provide a path to a text file which has the script code?
Thanks for any insights.
Chris
No, you can't just pass code into wscript.exe or cscript.exe. You'll have to write it to a file and pass the filename to wscript.exe or cscript.exe.
Here is my code to set upload path:
FileManager fm = new FileManager();
String srcPath = fm.directoryPath("ownOIPath");
MultipartRequest multi = new MultipartRequest(req, srcPath,
50 *90000 * 90000, new com.oreilly.servlet.multipart.DefaultFileRenamePolicy());
"srcPath" is read from *.properties file.
Path I provided in properties file is:
ownOIPath = /var/www/vhosts/globalsteelweb.com/httpdocs/UploadedFiles/ownOI/
I changed this path and set in windows environment then its working fine
but why its (adding /var/java/aache-tomcat-7.0.47/webapps/gsw) extra on the linux server:
java.lang.IllegalArgumentException: Not a directory:
/var/java/apache-tomcat-7.0.47/webapps/gsw/var/www/vhosts/domain.com/httpdocs/UploadedFiles/ownOI
Please advise
Best regards
I checked everything but that was really strange fix. At the end of the path that I written in my properties file there was a white space. When I removed it everything started to work perfectly
I have a program written in swift and I was wondering how I could reference a variable (String) in my terminal command.
This is what I have tried but I am not having any success.
var clientUsed : String = "Safari"
var killApp: NSAppleScript?
let killCommand = "do shell script \"killall " + clientUsed\"
killApp = NSAppleScript(source:killCommand)
How do I structure this correctly?
The command should say the following:
killall Safari
Where safari is a variable chosen by the user.
I assume anyone with swift or obj-c knowledge will be able to help me with this.
The easiest way is via string interpolation. Inside your string literal, enclose a variable in \() to have it’s string representation inserted at that point:
let killCommand = "do shell script \"killall \(clientUsed)\""
Your original idea of using + would also work (less neat though), but you needed to add an additional string literal on the end:
let killCommand = "do shell script \"killall " + clientUsed + "\""