diff --git a/Allwmake b/Allwmake
index 515d1cdf9af0dbfd784597a9a095de8509caa2bc..749c60fc89db7731f3098bb8c576b94c12f2f4fb 100755
--- a/Allwmake
+++ b/Allwmake
@@ -1,10 +1,13 @@
 #!/bin/sh
 set -x
 
+# run from this directory only
+cd ${0%/*} || exit 1
+
 # wmake is required for subsequent targets
 (cd wmake/src && make)
 
-(cd $WM_PROJECT_INST_DIR/ThirdParty && ./Allwmake)
+(cd $WM_THIRD_PARTY_DIR && ./Allwmake)
 
 (cd src && ./Allwmake)
 
diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake
index 95f041dd612d0864327b5afa3e50f5377f618a03..31617e3b12578fff89727d64fbc924c8fd09a65d 100755
--- a/applications/utilities/mesh/conversion/Optional/Allwmake
+++ b/applications/utilities/mesh/conversion/Optional/Allwmake
@@ -2,6 +2,9 @@
 # Build optional components (eg, may depend on third-party libraries)
 set -x
 
+# run from this directory only
+cd ${0%/*} || exit 1
+
 # build libccmio if required
 if [ ! -e $FOAM_LIBBIN/libccmio.so ]
 then