diff --git a/wscript b/wscript
index 79cf614fa010af6bde72e24bee65f324b9022a36..dba26bcdcedc010ff479cc8574e3723b33342d1c 100644
--- a/wscript
+++ b/wscript
@@ -624,32 +624,38 @@ def register_ns3_script(bld, name, dependencies=('core',)):
 def add_examples_programs(bld):
     env = bld.env
     if env['ENABLE_EXAMPLES']:
-        for dir in os.listdir('examples'):
-            if dir.startswith('.') or dir == 'CVS':
-                continue
-            if os.path.isdir(os.path.join('examples', dir)):
-                bld.recurse(os.path.join('examples', dir))
+        try:
+            for dir in os.listdir('examples'):
+                if dir.startswith('.') or dir == 'CVS':
+                    continue
+                if os.path.isdir(os.path.join('examples', dir)):
+                    bld.recurse(os.path.join('examples', dir))
+        except OSError:
+            return
 
 def add_scratch_programs(bld):
     all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES']]
-    for filename in os.listdir("scratch"):
-        if filename.startswith('.') or filename == 'CVS':
-	    continue
-        if os.path.isdir(os.path.join("scratch", filename)):
-            obj = bld.create_ns3_program(filename, all_modules)
-            obj.path = obj.path.find_dir('scratch').find_dir(filename)
-            obj.source = obj.path.ant_glob('*.cc')
-            obj.target = filename
-            obj.name = obj.target
-            obj.install_path = None
-        elif filename.endswith(".cc"):
-            name = filename[:-len(".cc")]
-            obj = bld.create_ns3_program(name, all_modules)
-            obj.path = obj.path.find_dir('scratch')
-            obj.source = filename
-            obj.target = name
-            obj.name = obj.target
-            obj.install_path = None
+    try:
+        for filename in os.listdir("scratch"):
+            if filename.startswith('.') or filename == 'CVS':
+                continue
+            if os.path.isdir(os.path.join("scratch", filename)):
+                obj = bld.create_ns3_program(filename, all_modules)
+                obj.path = obj.path.find_dir('scratch').find_dir(filename)
+                obj.source = obj.path.ant_glob('*.cc')
+                obj.target = filename
+                obj.name = obj.target
+                obj.install_path = None
+            elif filename.endswith(".cc"):
+                name = filename[:-len(".cc")]
+                obj = bld.create_ns3_program(name, all_modules)
+                obj.path = obj.path.find_dir('scratch')
+                obj.source = filename
+                obj.target = name
+                obj.name = obj.target
+                obj.install_path = None
+    except OSError:
+        return
 
 def _get_all_task_gen(self):
     for group in self.groups: