How-to
WinCC Unified HMIRuntime.FileSystem.Browse for file lists
Short answer
HMIRuntime.FileSystem.Browse() lists the entries of a WinCC Unified panel folder and IsDirectory() sorts folders from files; take the display name from the text after the last slash. Trigger any file write from a screen object: Task Scheduler tasks run as user scs, which has no write access to the industrial home folder, so scheduled CSV writes do nothing.

On this page
WinCC Unified has no Visual Basic Script FileSystem objects, and with them the familiar folder listing disappears from JavaScript. The runtime object model fills the gap with the HMIRuntime.FileSystem branch: HMIRuntime.FileSystem.Browse() returns the path names of a folder's entries, and HMIRuntime.FileSystem.IsDirectory() tells you which of those entries are subfolders. Take each display name from the text after the last slash of the returned path. Before you write anything, keep the trigger rule in mind: file creation and writes work when a screen object fires the script, and they do nothing when the Task Scheduler fires it, because scheduler tasks run as user scs, which has no write access to the industrial home folder. This article gives the listing steps with code, the name extraction with the arithmetic shown, and the decision for each case.
What replaces the VBS FileSystem objects #
On Windows CE panels, VBS listed a folder through the Dir method of the FileSystem object; on Windows, through the Files collection of the Folder object. Neither object exists in JavaScript, so the WinCC Unified runtime object model was extended with HMIRuntime.FileSystem, and those methods are documented for Unified Comfort Panels and for Unified PC Runtime alike.
Browse() takes a folder path and returns the path names of its entries — files and subdirectories together. It enumerates a directory from script; it is not a file-selection dialog and it does not read file contents. IsDirectory() answers, for one returned path name, whether that entry is a directory. The method documentation notes exactly this pairing: the path names Browse returns are the inputs IsDirectory expects.
List a folder from a screen script #
- Attach the script to a screen object — a button event on an HMI screen — so the runtime executes it in screen context. The section below on writes explains why the Task Scheduler is excluded.
- Call Browse() on the exact folder the files live in, for example
C:/Data/temp/on a Windows-style host or the internal folder your project uses. - Call IsDirectory() on every returned path and keep the result beside the path.
- While you develop, send the requested folder, each returned path and its classification to the Trace Tool; the trace shows the folder the runtime actually read.
- Fill the on-screen list from the classified entries and keep the full path in every row, because the next file operation needs the path, not the label.
// Illustrative pattern. Browse and IsDirectory are the documented
// HMIRuntime.FileSystem methods; the variable names are examples.
const folder = "/home/industrial/mydatadir"; // directory to list
const entries = HMIRuntime.FileSystem.Browse(folder); // entry path names
for (const entry of entries) {
const isDir = HMIRuntime.FileSystem.IsDirectory(entry); // true: subfolder
const name = entry.substring(entry.lastIndexOf("/") + 1); // display name
// while testing, write folder, entry and isDir to the Trace Tool;
// show name in the list and keep entry for the later file work
}
The loop is the illustrative shape, not a copy of the reference page. Take the exact signature and result handling for Browse from the RT Unified JavaScript object model documentation of your TIA Portal version, inspect the operation result rather than assuming success because the next statement ran, and continue dependent work only once the operation has completed.
Cut the display name from the full path #
Operators should read names, not paths. The display name is the final path component — everything right of the last slash:
const displayName = entryPath.substring(entryPath.lastIndexOf("/") + 1);
Worked example, using the entry path /home/industrial/mydatadir/mysubdir/log1.csv: the string is 44 characters long and its last slash sits at index 35, so substring(36) returns the remaining 44 − 36 = 8 characters, log1.csv. The same arithmetic on the directory entry /home/industrial/mydatadir/mysubdir — 35 characters, last slash at index 26 — gives substring(27) and the remaining 35 − 27 = 8 characters, mysubdir.
Two rules keep this safe. If a directory entry arrives with a trailing slash, remove that separator before extracting, while the operational value keeps the original path. And a display name is not a unique identifier — two folders can hold files with the same name — so every row stores its full path for the actual file work. The string operation changes presentation only; it neither validates the file nor grants access to it.
Write files from a screen trigger, not the Task Scheduler #
A listing proves visibility, not write permission. The verified sequence on a Unified Comfort Panel ran CreateDirectory for the subfolder, WriteFile for the CSV and AppendFile for later additions, all from a button on an HMI screen, and it created both the folder and the file. Triggered from the Task Scheduler instead, the same work does nothing: scheduler tasks execute as user scs, and scs has no write access to industrial's home folder (/home/industrial). The trigger is the difference, not the path syntax.
The rule follows: any script that creates folders or writes files on the panel is called from a screen object. Seeing the folder in the Toolbox FileBrowser proves only that the directory exists and is enumerable — it says nothing about whether the calling account may create a file there. A script that runs but skips its file work is a known failure shape on the PC line as well; the article on why a WinCC Runtime Advanced VBScript runs but does not copy a CSV documents the same pattern.
Create the parent folder before the subfolder #
One CreateDirectory call creates one level. A call for the two-level example path fails when the parent does not exist yet, the same way mkdir without the -p option fails on Linux. Create the parent first and the subfolder second; that two-step order is part of the verified Comfort Panel sequence. When the parent already exists, a single call for the subfolder is enough.
File selection stays inside the runtime #
An operator who should pick a file inside the visualization cannot use Windows File Explorer for it. Explorer is a standalone application: it can run alongside the browser, but it cannot be embedded in the web page that WinCC Unified Runtime serves, and no mechanism returns a selection from it to the runtime. The supported routes are a list screen you fill from Browse(), or the FileBrowser faceplate from the SIMATIC WinCC Unified Toolbox application example — a complete faceplate-based implementation, comparable in function to the OpenFileBrowser system function. A file that lives on the operator's browser PC stays out of reach either way; design a transfer step that copies it into storage the runtime can read before any listing or file method touches it.
The decision for each case #
| Case | Decision |
|---|---|
| List a folder's files and subfolders | HMIRuntime.FileSystem.Browse() from a screen script, IsDirectory() on every returned path |
| Show names without paths | Substring after the last slash; the row keeps the full path |
| Create a folder or write a CSV | Screen-object trigger; parent folder created before the subfolder |
| Automate the write | Not from the Task Scheduler: its scs tasks cannot write the industrial home folder; move the trigger into a screen event |
| Operator selects a file | Toolbox FileBrowser faceplate or a Browse-built list screen, never Windows File Explorer |
| Unified Basic Panel | Methods documented for Comfort Panels and PC Runtime; run a one-button create-and-write test on the Basic panel first and keep the USB stick path as the fallback |
Verify each decision on the exact runtime target with your TIA Portal version before the pattern is copied across a project: the engineering tool version, the target model and the runtime build are separate checks.
Questions asked
Does the listing also work on a Unified Basic Panel?
The FileSystem methods are documented for Unified Comfort Panels and Unified PC Runtime. A reported Basic Panel case on TIA V19 Update 3 wrote to the USB stick path (X61) from a screen button but created nothing in the internal folder, even though the Toolbox FileBrowser showed that folder. Before building on a Basic Panel, run a one-button test that creates one folder and one file, and keep the USB stick as the fallback destination.
Does Browse list files on the operator's browser computer?
No. HMIRuntime.FileSystem addresses the storage of the runtime host, the panel or the PC Runtime machine. When the visualization runs in a web browser, the calls still execute on the runtime, so a file on the operator's PC is invisible to Browse and to the write methods. Such a file first needs a transfer into storage the runtime can read; only then can the script list and process it.
How do I tell an empty folder from a failed Browse call?
Inspect the operation result instead of trusting the absence of output. A completed call that returns no entries means the folder exists and is empty; a failed call means the path or access did not resolve. While developing, write the requested folder and every returned path to the Trace Tool, so the trace shows the folder the runtime actually read rather than the one you meant to ask for.


