GVKun编程网logo

Dism 命令 启用或关闭 Windows 功能(dism命令使用)

2

这篇文章主要围绕Dism命令启用或关闭Windows功能和dism命令使用展开,旨在为您提供一份详细的参考资料。我们将全面介绍Dism命令启用或关闭Windows功能的优缺点,解答dism命令使用的相

这篇文章主要围绕Dism 命令 启用或关闭 Windows 功能dism命令使用展开,旨在为您提供一份详细的参考资料。我们将全面介绍Dism 命令 启用或关闭 Windows 功能的优缺点,解答dism命令使用的相关问题,同时也会为您带来C# windows 窗体应用程序 Word Interop 适用于 Windows 7 但不适用于 Windows 10、c盘爆满清理解决方案----Dism、dism /online /cleanup-image /scanhealth Error: 740、Dism 离线修复系统的实用方法。

本文目录一览:

Dism 命令 启用或关闭 Windows 功能(dism命令使用)

Dism 命令 启用或关闭 Windows 功能(dism命令使用)

以管理员身份运行 CMD

Dism /online /Get-Features

获取所有组件名称,比如 IIS,.Net 等

举例,启用或关闭 SMB 1.0/CIFS 文件共享支持

Dism /online /Enable-Feature /FeatureName:SMB1Protocol
Dism /online /Disable-Feature /FeatureName:SMB1Protocol

 

C# windows 窗体应用程序 Word Interop 适用于 Windows 7 但不适用于 Windows 10

C# windows 窗体应用程序 Word Interop 适用于 Windows 7 但不适用于 Windows 10

如何解决C# windows 窗体应用程序 Word Interop 适用于 Windows 7 但不适用于 Windows 10

我编写了一个应用程序来帮助用户使用 C# 生成字母。我创建了以富文本格式保存在 sql Server 数据库中的模板。我的开发机器是 Windows 7,我使用 Visual Studio 2019 来编写应用程序。我使用 NuGet 添加 Word 的互操作引用。该应用程序配置为面向 x86 的 Release、平台 Active(Any cpu)。它是一个 ClickOnce 应用程序,从共享驱动器安装在一个单独的目录中,但与保存字母的驱动器相同。

该应用程序在我的机器上正常运行,但在 Windows 10 用户机器上运行不正常。当它尝试保存文件时,她收到一条错误消息,提示“抱歉,我们找不到该文件”。我们都有 Word 2016。两台机器都是 64 位。我将这封信保存为 Word 中的备份,然后导出为 PDF。在导出为 PDF 之前,代码无法保存 Word 文档。请参阅下面的代码片段:

  1. public static void SavetoWord2(string CoverLetter,string LetterText,string FileSave,string BackUpSave,ref string ErrorString)
  2. {
  3. try
  4. {
  5. Microsoft.Office.Interop.Word.Application oWord = new Microsoft.Office.Interop.Word.Application();
  6. string headerfooterFile = Properties.FileResources.headerfooterTemplate;
  7. Document odoc = new Document();
  8. odoc = oWord.Documents.Add(@headerfooterFile);
  9. odoc.Activate();
  10. try
  11. {
  12. Clipboard.Clear();
  13. Clipboard.SetText(CoverLetter,TextDataFormat.Rtf);
  14. odoc.ActiveWindow.Selection.Paste();
  15. Clipboard.Clear();
  16. Clipboard.SetText(LetterText,TextDataFormat.Rtf);
  17. odoc.ActiveWindow.Selection.Paste();
  18. //01/26/2021 JS having trouble with the save on Pam''s machine so going to try to capture the correct error.
  19. try
  20. {
  21. odoc.SaveAs(@BackUpSave);
  22. }
  23. catch (Exception exBU)
  24. {
  25. ErrorString = "Error trying to save " + @BackUpSave + ": " + exBU.Message;
  26. }
  27. try
  28. {
  29. odoc.ExportAsFixedFormat(@FileSave,WdExportFormat.wdExportFormatPDF);
  30. }
  31. catch (Exception exPDF)
  32. {
  33. if (string.IsNullOrEmpty(ErrorString))
  34. {
  35. ErrorString = "Error trying to save " + @FileSave + " PDF: " + exPDF.Message;
  36. }
  37. else
  38. {
  39. ErrorString += " and Error trying to save " + @FileSave + " PDF: " + exPDF.Message;
  40. }
  41. }
  42. }
  43. catch (Exception exInner)
  44. {
  45. ErrorString = exInner.Message;
  46. MessageBox.Show(exInner.Message,Properties.LetterResources.SavetoWord,MessageBoxButtons.OK,MessageBoxIcon.Error);
  47. }
  48. Clipboard.Clear();
  49. oWord.Quit(SaveChanges: 0);
  50. Marshal.FinalReleaseComObject(oWord);
  51. //oWord.Visible = true;
  52. }
  53. catch (Exception ex)
  54. {
  55. ErrorString = ex.Message;
  56. MessageBox.Show(ex.Message,MessageBoxIcon.Error);
  57. }
  58. }

错误发生在 odoc.SaveAs 行上,但仅在从 Windows 10 计算机运行时发生。最初,我使用了我机器上的互操作,但后来将其更改为 NuGet 互操作,但这并没有解决问题。我尝试将 Embed Interop Types 更改为 False 但这并没有解决任何问题,因此我将其改回。互操作引用的别名属性是全局的,特定版本属性是 True。由于富文本,我担心更改文档编写器的类型。应用程序的其余部分对于 Windows 10 用户来说运行良好。有什么想法吗?

解决方法

OpenXML 没有成功,因为它不允许我正确添加标题或导出为 PDF。尽管我非常希望使用 OpenXML,但我最终还是回到了 Word Interop。我能够通过如下设置参考属性来解决这个问题:

嵌入互操作类型 = False 复制本地 = True

现在无论哪个操作系统运行程序,保存都有效。我有上面的部分答案,但忽略了 Copy Local = true 部分。

c盘爆满清理解决方案----Dism

c盘爆满清理解决方案----Dism

前言:在以前windons操作系统,很容易导致c盘爆满,原因了就那么几个,升级,app默认安装,打补丁等等。还有种蛇皮现象,就是无缘无故c盘就标红了,进去看看,又个c盘的系统文件,不敢删了,怕系统就崩溃,这就很烦了,找了app来清理------Dism

对于这个app我只想说----好东西

下面是云盘地址:

链接:https://pan.baidu.com/s/1MQBi_dF_brG8Z4Sg_3FRpA

提取码:uh1e

++++++++++++++++++++++++++++++++++++++++++++++++++++

操作如下:

1.点击我的电脑,右键属性,看自己是几位的系统


 

2.下载压缩包下来,打开选择64,打开直接用(无需安装)

点击扫描,点击清理(一般我是全选)


 

效果:


 

dism /online /cleanup-image /scanhealth Error: 740

dism /online /cleanup-image /scanhealth Error: 740


dism /online /cleanup-image /scanhealth

Error: 740

Elevated permissions are required to run DISM.
Use an elevated command prompt to complete these tasks.
 

这个错误的原因是运行权限不够,用管理员身份,在windows/System32目录下找到cmd.exe,用管理员身份运行,再执行 。

Dism 离线修复系统

Dism 离线修复系统

修复步骤

1. 网上下载Windows 11/10镜像文件,然后将镜像文件挂载到电脑中。

转到“此电脑”,查看已挂载的镜像文件的驱动器号。如果驱动器号为F:,则需要将源路径设置为F:\source。

2. 按下组合键“Win+X”,选择Windows PowerShell(管理员)。

3. 输入以下命令,每输入一条后按下“回车”。

Dism /Online /Cleanup-Image /StartComponentCleanup

Dism /Online /Cleanup-Image /AnalyzeComponentStore

4. Dism /Online /Cleanup-Image /RestoreHealth /source:F:\Sources\Install.wim:1/ LimitAccess

在线修复

DISM.exe /Online /Cleanup-image /Scanhealth
DISM.exe /Online /Cleanup-image /Restorehealth

 

关于Dism 命令 启用或关闭 Windows 功能dism命令使用的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于C# windows 窗体应用程序 Word Interop 适用于 Windows 7 但不适用于 Windows 10、c盘爆满清理解决方案----Dism、dism /online /cleanup-image /scanhealth Error: 740、Dism 离线修复系统的相关知识,请在本站寻找。

本文标签: