diff --git a/core/setup.php b/core/setup.php
index 4758c23b045ea214bdb8048258cf4e3b024aee7f..d18b1d54c2b03ec883ec5c7ce0c3264b90bbdcc5 100644
--- a/core/setup.php
+++ b/core/setup.php
@@ -5,9 +5,18 @@ $autosetup_file = OC::$SERVERROOT."/config/autoconfig.php";
 if( file_exists( $autosetup_file )) {
 	OC_Log::write('core', 'Autoconfig file found, setting up owncloud...', OC_Log::INFO);
 	include $autosetup_file;
-	$_POST['install'] = 'true';
 	$_POST = array_merge ($_POST, $AUTOCONFIG);
-	unlink($autosetup_file);
+}
+
+$dbSet = isset($_POST['dbtype']);
+$directorySet = isset($_POST['directory']);
+$adminAccountSet = isset($_POST['adminlogin']);
+
+if ($dbSet AND $directorySet AND $adminAccountSet) {
+    $_POST['install'] = 'true';
+    if( file_exists( $autosetup_file )) {
+    	unlink($autosetup_file);
+    }
 }
 
 OC_Util::addScript('setup');
@@ -21,7 +30,7 @@ $datadir = OC_Config::getValue('datadirectory', OC::$SERVERROOT.'/data');
 $vulnerableToNullByte = false;
 if(@file_exists(__FILE__."\0Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
 	$vulnerableToNullByte = true;
-} 
+}
 
 // Protect data directory here, so we can test if the protection is working
 OC_Setup::protectDataDirectory();
@@ -37,6 +46,8 @@ $opts = array(
 	'htaccessWorking' => OC_Util::isHtAccessWorking(),
 	'vulnerableToNullByte' => $vulnerableToNullByte,
 	'errors' => array(),
+    'dbSet' => $dbSet,
+    'directorySet' => $directorySet
 );
 
 if(isset($_POST['install']) AND $_POST['install']=='true') {
diff --git a/core/templates/installation.php b/core/templates/installation.php
index 8b087706801d31b49a4a619ed470d46dcca0bb97..ed8057452bd27cb4e1ba2ad841aaeffa4ead5ff2 100644
--- a/core/templates/installation.php
+++ b/core/templates/installation.php
@@ -61,6 +61,7 @@
 		</p>
 	</fieldset>
 
+    <?php if(!$_['directorySet']): ?>
 	<fieldset id="datadirField">
 		<legend><a id="showAdvanced"><?php p($l->t( 'Advanced' )); ?> <img class="svg" src="<?php print_unescaped(image_path('', 'actions/caret.svg')); ?>" /></a></legend>
 		<div id="datadirContent">
@@ -70,7 +71,9 @@
 				value="<?php p(OC_Helper::init_var('directory', $_['directory'])); ?>" />
 		</div>
 	</fieldset>
+    <?php endif; ?>
 
+    <?php if(!$_['dbSet']): ?>
 	<fieldset id='databaseField'>
 		<?php if($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle'] or $_['hasMSSQL'])
 			$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite ?>
@@ -171,6 +174,7 @@
 		</div>
 		<?php endif; ?>
 	</fieldset>
+    <?php endif; ?>
 
 	<div class="buttons"><input type="submit" class="primary" value="<?php p($l->t( 'Finish setup' )); ?>" /></div>
 </form>