diff --git a/Docs/src/misc.but b/Docs/src/misc.but
index ed3b823e..a42eb97a 100644
--- a/Docs/src/misc.but
+++ b/Docs/src/misc.but
@@ -67,7 +67,7 @@ Sets the error level of the installer or uninstaller to \e{error_level}. See \R{
\S2{setregview} SetRegView
-\c \\32\\|64
+\c \\32\\|64|lastused
Sets the registry view affected by \R{registry}{registry commands}. On Windows x64 there are two views. One for 32-bit applications and one for x64 applications. By default, 32-bit applications running on x64 systems under WOW64 have access only to the 32-bit view. Using \c{SetRegView 64} allows the installer to access keys in the x64 view of the registry.
diff --git a/Source/script.cpp b/Source/script.cpp
index 3ef4c774..f2ad0a83 100644
--- a/Source/script.cpp
+++ b/Source/script.cpp
@@ -3573,12 +3573,14 @@ int CEXEBuild::doCommand(int which_token, LineParser &line)
ent.which=EW_SETFLAG;
ent.offsets[0]=FLAG_OFFSET(alter_reg_view);
// "64" results in setting the flag to 1 which alters the view
- int k=line.gettoken_enum(1,"32\0" "64\0");
+ int k=line.gettoken_enum(1,"32\0" "64\0lastused");
if (k<0) PRINTHELP()
if (k == 0) // 32
ent.offsets[1]=add_intstring(0);
else if (k == 1) // 64
ent.offsets[1]=add_intstring(KEY_WOW64_64KEY);
+ else if (k == 2) // last used
+ ent.offsets[2]=1;
SCRIPT_MSG("SetRegView: %s\n",line.gettoken_str(1));
}
return add_entry(&ent);
diff --git a/Source/tokens.cpp b/Source/tokens.cpp
index fce95d54..7d9ee4b8 100644
--- a/Source/tokens.cpp
+++ b/Source/tokens.cpp
@@ -194,7 +194,7 @@ static tokenType tokenlist[TOK__LAST] =
{TOK_SETOVERWRITE,"SetOverwrite",1,0,"on|off|try|ifnewer|ifdiff",TP_ALL},
{TOK_SETPLUGINUNLOAD,"SetPluginUnload",1,0,"(manual|alwaysoff)",TP_ALL},
{TOK_SETREBOOTFLAG,"SetRebootFlag",1,0,"true|false",TP_CODE},
-{TOK_SETREGVIEW,"SetRegView",1,0,"32|64",TP_CODE},
+{TOK_SETREGVIEW,"SetRegView",1,0,"32|64|lastused",TP_CODE},
{TOK_SETSHELLVARCONTEXT,"SetShellVarContext",1,0,"all|current",TP_CODE},
{TOK_SETSILENT,"SetSilent",1,0,"silent|normal",TP_CODE},
{TOK_SHOWDETAILS,"ShowInstDetails",1,0,"(hide|show|nevershow)",TP_GLOBAL},