在 Windows 2008 上设置强制配置文件时,文件关联不会保留

在 Windows 2008 上设置强制配置文件时,文件关联不会保留

我目前有 3 个用户在我的 Windows 2008 远程桌面服务器上使用强制配置文件。我已设法通过更改注册表权限、设置配置文件文件夹的权限以及设置初始用户的配置文件(然后使用 .man 扩展名将其锁定)来使一切正常运行。我的问题/疑问与远程桌面上的关联有关。

通常我会执行以下操作...

1) Get all three users to log out
2) Change the profile from .man to .dat
3) Get the "profile template user" (a title I have given the first user I set up with the profile for) to log on.
4) Get that user to create a shortcut or set up a file association, etc.
5) Get that user to log off.
6) Rename the profile from .dat to .man

由于某种原因,我的所有更改似乎都适用于不同的用户,但文件关联除外。我无法让这一点保留下来!

有想法吗?

答案1

我最终创建了一个注册表文件,供用户登录时在组策略中使用。在这种情况下,下面有一个示例,说明我如何利用注册表中的环境变量。

这有点棘手,但做起来却很容易。此示例允许您使用位于用户特定目录中的程序 (Notepad++) 打开某种类型的文件 (*.test)。我在运行远程桌面(又称终端服务器)的 Windows 2008 服务器上使用了这个方案,以允许每个用户使用每个用户帐户安装的程序,以便每个用户可以使用不同的设置(例如:位于应用程序目录中的 *.ini 文件)。注意:这并不重要,但文件夹“programs”是隐藏的,因此用户看不到它。

Paths:
Application (notepad++): Y:\%username%\programs\Notepad++\notepad++.exe
File To Open (File.test): Y:\%username%\TestFiles\File.test

步骤1。 如果您使用强制配置文件,请确保将 NTUSER.MAN 文件更改回 NTUSER.DAT。

第2步。 使用远程桌面客户端登录您想要编辑的配置文件。

步骤3. 打开 regedit 并删除以下键(如果存在)。

HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.test

步骤4。 创建一个新的文本文件并将其命名为“original.reg”。在其中填写以下内容...

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=""

步骤5. 刷新注册表 (F5) 并查找新键。应该看到“command”键的“(Default)”值为空白。在“command”键中添加一个名为“New Value #1”的新“Expandable String Value”。将值设置为应用程序的路径“Y:\%用户名%\programs\Notepad++\notepad++.exe” “%1”.然后将“command”键导出到桌面作为“expanded.reg”。

步骤6. 在记事本中编辑“expanded.reg”文件,并将以下所有数据复制“新价值 #1”例如:=hex(2):22...

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=""
"New Value #1"=hex(2):22,00,59,00,3a,00,5c,00,25,00,75,00,73,00,65,00,72,00,6e,00,\
61,00,6d,00,65,00,25,00,5c,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,\
00,5c,00,4e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,5c,00,6e,00,\
6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,2e,00,65,00,78,00,65,00,22,\
00,20,00,22,00,25,00,31,00,22,00,00,00

步骤7。 关闭expanded.reg文件并打开“original.reg”文件,然后用剪贴板中的新十六进制值替换默认命令(即空“”)。文件“original.reg”现在应该如下所示...

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=hex(2):22,00,59,00,3a,00,5c,00,25,00,75,00,73,00,65,00,72,00,6e,00,\
61,00,6d,00,65,00,25,00,5c,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,\
00,5c,00,4e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,5c,00,6e,00,\
6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,2e,00,65,00,78,00,65,00,22,\
00,20,00,22,00,25,00,31,00,22,00,00,00

步骤8. 现在我们已经准备好了扩展变量,只需添加一个与应用程序关联的扩展即可。将以下内容添加到“original.reg”文件中,使其看起来像以下内容...

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open]

[HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe\shell\open\command]
@=hex(2):22,00,59,00,3a,00,5c,00,25,00,75,00,73,00,65,00,72,00,6e,00,\
61,00,6d,00,65,00,25,00,5c,00,70,00,72,00,6f,00,67,00,72,00,61,00,6d,00,73,\
00,5c,00,4e,00,6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,5c,00,6e,00,\
6f,00,74,00,65,00,70,00,61,00,64,00,2b,00,2b,00,2e,00,65,00,78,00,65,00,22,\
00,20,00,22,00,25,00,31,00,22,00,00,00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test\OpenWithList]
"a"="notepad++.exe"
"MRUList"="a"

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test\OpenWithProgids]
"Notepad++_file"=hex(0):

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.test\UserChoice]
"Progid"="Applications\\notepad++.exe"

步骤9。 打开 regedit 并删除以下项(如果存在)。(是的,再做一次)...现在注册表就像我们从未做过任何事情一样,我们有一个可插入注册表的注册表文件!

HKEY_CURRENT_USER\Software\Classes\Applications\notepad++.exe HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.test

第十步。 如果您想将其应用到当前配置文件,请运行注册表文件“original.reg”并将其插入注册表。

就是这样!现在所有 *.test 文件都将以“Y:\%username%\programs\Notepad++\notepad++.exe”打开。检查注册表并查看新的默认条目。

相关内容