When scripting workflows in VMware vCenter Orchestrator (vCO) it is often desirable to read or write to local files on the vCO server whether this is a .conf, .txt, .cmd, .bat, .xml, or any other text file. In order to do so, you must be sure to either work with files in a pre-approved folder or add your custom folder to a configuration file.

For full details on the following information, please see page 64 of the vCenter Orchestrator Administration guide, section "Setting Server File System Access from Workflows and JavaScript". In order to read/write to files on your server, you must edit the js-io-rights.conf file and restart your vCO service. Otherwise, you must read/write to the temp folder or a folder that already has rights assigned. You can get the temp folder using the following:

var tempFolder = System.getTempDirectory();

The default contents of the js-io-rights.conf file are as follows:

-rwx C:/

+rwx C:/orchestrator
+rx ../../configuration/jetty/logs/
+rx ../server/vmo/log/
+rx ../bin/
+rx ./boot.properties
+rx ../server/vmo/conf/
+rx ../server/vmo/conf/plugins/
+rx ../server/vmo/deploy/vmo-server/vmo-ds.xml
+rx ../../apps/
+r ../../version.txt

So, based on the file contents above, without editing or restarting the service, if you update your script to write your text file to the c:\orchestrator folder (you will need to create this folder on your vCO server, the script should work.

Now, as a quick example, create a new workflow with a single scriptable task in it. Inside the scriptable task, insert the following code (I'm assuming a WINDOWS based vCO server here):

var fw = new FileWriter("c:/orchestrator/test.txt");
fw.open();
fw.write("Hello there, is this working?");
fw.close();

Save and close your worklow after validating.

Now try running it.

Check the C:/orchestrator folder and confirm there is now a test.txt file with the content specified in the script.

Hope this helps :)