diff --git a/pd/nw/index.js b/pd/nw/index.js
index ade8c18500964743bd6c90f81d660dcfbf0a941c..b852054c0b56cd793d3af171933927df7cd76086 100644
--- a/pd/nw/index.js
+++ b/pd/nw/index.js
@@ -313,7 +313,7 @@ function add_events() {
                 argv_string = argv_string.slice(0, -pd_engine_id.length).trim();
                 // strip off the gui dir
                 argv_string = argv_string.slice(0,
-                    -nw.App.argv[3].length).trim();
+                    -nw.App.argv[4].length).trim();
                 if (process.platform === "win32") {
                     // windows quotes this string, so let's remove the two
                     // quotation marks