OS Commands
-
I seem to recall there was a way to execute operating system command - like file copy, but my old-person memory may be faulty....
and I cant find anything using the "search" facilities in the forum...
perhaps its this
File.startAsProcess(String parameters);
-- but I've no idea how this works...
-
@Lindon Yes that's it. File is a file object, this could be an exe or a PDF for example, the parameters is a string of parameters that you might want to pass to an executable, just like you would when running programs from the command line. If there are no parameters just use an empty string.
-
@d-healey said in OS Commands:
@Lindon Yes that's it. File is a file object, this could be an exe or a PDF for example, the parameters is a string of parameters that you might want to pass to an executable, just like you would when running programs from the command line. If there are no parameters just use an empty string.
OK so I've tried putting the entire string I want executing inside the file with writeString so:
"copy c:/myfile.txt c:/users/lindon/documents/"
and then executing .startAsProcess();
-- this gives me an error of 0 params expecting 1
so I tried writeString "copy" and then
.startAsProcess(c:/myfile.txt c:/users/lindon/documents/")that opens the file for editing...
So I assume I need to find the copy "file" somewhere, unless I dont understand what Im supposed to do to copy 1 file from a location a to location b.
So next I tried creating a file for the command prompt:
var commandPrompt = FileSystem.fromAbsolutePath("C:\Users\lindon\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\CommandPrompt");
and sending it the string I want executing:
commandPrompt.startAsProcess("copy c:/myfile.txt c:/users/lindon/documents/")
this doesnt report an error, doesnt try to start an editor, but doenst execute the command...
-
There is a File.copy command already - unless Christoph hasn't merged my pull request yet
-
@d-healey syntax?
tried
myFile.copy(myDestinationString)
LoopPlayers.js (83): function not found :-(
-
@d-healey -- when did you make the pull request - last I can see from you was the tablelaf stuff on June 14
Hang on found it Aug 14.... dont think its been merged...
https://github.com/christophhart/HISE/pull/352
@Christoph-Hart any chance??
-
@Lindon I think I've already used that function... I'll take a look when I'm back home
-
@Lindon Ah, the only one I used was startAsProcess. (no copy)
const appData = FileSystem.getFolder(FileSystem.AppData); const manual = appData.getChildFile("MyProduct.pdf"); inline function onbtnManualControl(component, value) { if (value) manual.startAsProcess(""); }; Content.getComponent("btnManual").setControlCallback(onbtnManualControl);
My mistake...
-
@Lindon To follow up on your commandPrompt thing.
When you use the
copy
command in the terminal you're actually running a program calledcopy
(on MacOS and Linux it'scp
).So instead of getting a file object that references the command prompt program you'd want to get a reference to the
copy
program. -
@d-healey said in OS Commands:
@Lindon To follow up on your commandPrompt thing.
When you use the
copy
command in the terminal you're actually running a program calledcopy
(on MacOS and Linux it'scp
).So instead of getting a file object that references the command prompt program you'd want to get a reference to the
copy
program.yes I get that - its just finding "copy.exe" on windows...
-
@Lindon ok found --- but not good news....
xcopy = FileSystem.fromAbsolutePath("C:\Windows\System32\xcopy.exe"); Console.print("Is file:" + xcopy.isFile());
Tells me this is not a real file as far as HISE is concerned
-
@Lindon Maybe it's a permission thing. Just use my fork, or merge that pull request into your own fork.
-
@d-healey --yeah thats what im thinking I will have to do when I get to that part of the process... unless @Christoph-Hart has done the pull by then...