diff --git a/bin/kdm-autologin b/bin/kdm-autologin
index 887e4cb9fc7f6c38a691adfc96c1cf035ab072ed..3c4865f90cfa368692ee53e43f11f873592518fb 100755
--- a/bin/kdm-autologin
+++ b/bin/kdm-autologin
@@ -22,13 +22,13 @@ stop() {
 start() {
     echo "KDM AUTOLOGIN FOR ${ESAME_USER}"
 
-    sed -i '/AutoLoginEnable/s/.*/AutoLoginEnable=true/' /etc/kde/kdm/kdmrc
-    sed -i '/AutoLoginAgain/s/.*/AutoLoginAgain=true/' /etc/kde/kdm/kdmrc
+    sed -i '/#*AutoLoginEnable/s/.*/AutoLoginEnable=true/' /etc/kde/kdm/kdmrc
+    sed -i '/#*AutoLoginAgain/s/.*/AutoLoginAgain=true/' /etc/kde/kdm/kdmrc
     # 1) .* get expanded by the shell if in double quotes...
     # 2) $ESAME_USER does not get expanded if in single quotes...
     # 3) We want the former as is, and the latter expanded.
     # So, one solution is the following:
-    SEDCMD="/AutoLoginUser/s/"'.*'"/AutoLoginUser=$ESAME_USER/"
+    SEDCMD="/#*AutoLoginUser/s/"'.*'"/AutoLoginUser=$ESAME_USER/"
     sed -i "$SEDCMD" /etc/kde/kdm/kdmrc
 
     #sleep 5