--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -409,6 +409,7 @@ static bool epmapper_shutdown_cb(void *p
 	return true;
 }
 
+#ifdef WINREG_SUPPORT
 static bool winreg_init_cb(void *ptr)
 {
 	struct dcesrv_ep_context *ep_ctx =
@@ -456,6 +457,7 @@ static bool winreg_init_cb(void *ptr)
 
 	return true;
 }
+#endif
 
 static bool srvsvc_init_cb(void *ptr)
 {
@@ -710,10 +712,12 @@ static bool svcctl_init_cb(void *ptr)
 					   "epmapper",
 					   "none");
 
+#ifdef WINREG_SUPPORT
 	ok = svcctl_init_winreg(ep_ctx->msg_ctx);
 	if (!ok) {
 		return false;
 	}
+#endif
 
 	/* initialize the control hooks */
 	init_service_op_table();
@@ -785,10 +789,12 @@ static bool eventlog_init_cb(void *ptr)
 					   "epmapper",
 					   "none");
 
+#ifdef WINREG_SUPPORT
 	ok = eventlog_init_winreg(ep_ctx->msg_ctx);
 	if (!ok) {
 		return false;
 	}
+#endif
 
 	if (StrCaseCmp(rpcsrv_type, "embedded") == 0 ||
 	    StrCaseCmp(rpcsrv_type, "daemon") == 0) {
@@ -1077,12 +1083,14 @@ bool dcesrv_ep_setup(struct tevent_conte
 		}
 	}
 
+#ifdef WINREG_SUPPORT
 	winreg_cb.init         = winreg_init_cb;
 	winreg_cb.shutdown     = NULL;
 	winreg_cb.private_data = ep_ctx;
 	if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
 		return false;
 	}
+#endif
 
 	srvsvc_cb.init         = srvsvc_init_cb;
 	srvsvc_cb.shutdown     = NULL;
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -150,7 +150,9 @@ static void exit_server_common(enum serv
 #endif
 
 		rpc_srvsvc_shutdown();
+#ifdef WINREG_SUPPORT
 		rpc_winreg_shutdown();
+#endif
 
 		rpc_netlogon_shutdown();
 		rpc_samr_shutdown();
--- a/source3/librpc/rpc/rpc_common.c
+++ b/source3/librpc/rpc/rpc_common.c
@@ -112,9 +112,11 @@ static bool initialize_interfaces(void)
 	if (!smb_register_ndr_interface(&ndr_table_wkssvc)) {
 		return false;
 	}
+#ifdef WINREG_SUPPORT
 	if (!smb_register_ndr_interface(&ndr_table_winreg)) {
 		return false;
 	}
+#endif
 #ifdef PRINTER_SUPPORT
 	if (!smb_register_ndr_interface(&ndr_table_spoolss)) {
 		return false;
--- a/source3/rpc_server/svcctl/srv_svcctl_nt.c
+++ b/source3/rpc_server/svcctl/srv_svcctl_nt.c
@@ -95,9 +95,11 @@ bool init_service_op_table( void )
 	svcctl_ops[i].ops  = &netlogon_svc_ops;
 	i++;
 
+#ifdef WINREG_SUPPORT
 	svcctl_ops[i].name = talloc_strdup( svcctl_ops, "RemoteRegistry" );
 	svcctl_ops[i].ops  = &winreg_svc_ops;
 	i++;
+#endif
 
 	svcctl_ops[i].name = talloc_strdup( svcctl_ops, "WINS" );
 	svcctl_ops[i].ops  = &wins_svc_ops;
--- a/source3/services/svc_winreg_glue.c
+++ b/source3/services/svc_winreg_glue.c
@@ -88,6 +88,10 @@ struct security_descriptor *svcctl_get_s
 	NTSTATUS status;
 	WERROR result = WERR_OK;
 
+#ifndef WINREG_SUPPORT
+	return NULL;
+#endif
+
 	key = talloc_asprintf(mem_ctx,
 			      "%s\\%s\\Security",
 			      TOP_LEVEL_SERVICES_KEY, name);
@@ -161,6 +165,10 @@ bool svcctl_set_secdesc(struct messaging
 	NTSTATUS status;
 	WERROR result = WERR_OK;
 
+#ifndef WINREG_SUPPORT
+	return false;
+#endif
+
 	tmp_ctx = talloc_stackframe();
 	if (tmp_ctx == NULL) {
 		return false;
@@ -272,6 +280,10 @@ const char *svcctl_get_string_value(TALL
 	NTSTATUS status;
 	WERROR result = WERR_OK;
 
+#ifndef WINREG_SUPPORT
+	return NULL;
+#endif
+
 	tmp_ctx = talloc_stackframe();
 	if (tmp_ctx == NULL) {
 		return NULL;
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -642,7 +642,9 @@ static struct cmd_set *rpcclient_command
 	drsuapi_commands,
 	eventlog_commands,
 #endif
+#ifdef WINREG_SUPPORT
 	winreg_commands,
+#endif
 	NULL
 };
 
