@Override
	public void mountSharedFolder(VirtualMachine virtualMachine,
			String shareName, String hostPath, String guestPath)
					throws Exception {

		if (status(virtualMachine) == VirtualMachineStatus.POWERED_OFF) {
			throw new Exception("Unable to mount shared folder. Machine is not started.");
		}

		if (guestPath == null) {
			throw new IllegalArgumentException("Shared folder [" + shareName + "] does not exist.");
		}

		String password = virtualMachine.getProperty(VirtualMachineConstants.GUEST_PASSWORD);
		String user = virtualMachine.getProperty(VirtualMachineConstants.GUEST_USER);

		if (HypervisorUtils.isWindowsGuest(virtualMachine)) {

			HypervisorUtils.checkReturnValue(
					exec(virtualMachine, 
							"net use " + guestPath + " \\\\vboxsvr\\" + shareName));

		} else if (HypervisorUtils.isLinuxGuest(virtualMachine)) {

			File mountFile = File.createTempFile("mount-", ".sh");
			String mountScriptPathOnGuest = "/tmp/" + mountFile.getName();
			
			FileWriter mountFileWriter = new FileWriter(mountFile);
			mountFileWriter.write(
					"/bin/mkdir -p " + guestPath + "; " +
							"sudo mount -t vboxsf -o uid=" + user + ",gid=" + user + 
							" " + shareName + " " + guestPath + "; " +
							"rm " + mountScriptPathOnGuest);
			mountFileWriter.close();

			try {

				ProcessBuilder copyMountScriptBuilder = getProcessBuilder(
						"guestcontrol " + virtualMachine.getName() +  
						" copyto \"" + mountFile.getCanonicalPath() + "\" /tmp/" + 
						" --username " + user + " --password " + password);
				ExecutionResult executionResult = HypervisorUtils.runProcess(
						copyMountScriptBuilder);

				if (executionResult.getReturnValue() != ExecutionResult.OK && 
						!executionResult.getStdErr().toString().contains(VBoxStrategy.COPY_ERROR)) {
					//We are checking if COPY_ERROR was sent because of a bug where the copy is done
					//properly although it still spawns this error message with exit value different than 0
					throw new Exception(executionResult.getStdErr().toString());
				}

				HypervisorUtils.checkReturnValue(
						exec(virtualMachine, "/bin/bash " + mountScriptPathOnGuest));

			} finally {
				mountFile.delete();
			}

		} else {
			throw new Exception("Guest OS not supported");
		}
	}