简体   繁体   English

如何将 C# 控制台应用程序设置为使用默认控制台设置 (Windows Server 2012)?

[英]How to set C# Console Application to use default console settings (Windows Server 2012)?

Created a console application using C#/Visual Studio 2017. When I run the console application from VS or on a Windows 10 machine, it uses the default settings for my console application (Options/Font/Layout/Colors) which is perfect.使用 C#/Visual Studio 2017 创建了一个控制台应用程序。当我从 VS 或 Windows 10 机器上运行控制台应用程序时,它使用我的控制台应用程序的默认设置(选项/字体/布局/颜色),这是完美的。 However when I try to run it on a Test Server using Windows Server 2012 R2, it uses random settings (small buffer size/large font/odd shaped window).但是,当我尝试在使用 Windows Server 2012 R2 的测试服务器上运行它时,它使用随机设置(小缓冲区大小/大字体/奇形窗口)。 I've tried:我试过了:

  • Setting Defaults on Server(2012) to same defaults on Local (Windows 10/VS)将服务器(2012)上的默认值设置为本地(Windows 10/VS)上的相同默认值
  • Programmatically setting features of console window以编程方式设置控制台窗口的功能
  • Running from Command Line从命令行运行

When I run the application from command line(program.exe), it uses the default settings.当我从命令行(program.exe)运行应用程序时,它使用默认设置。 But when I click on the executable it does not.但是当我点击可执行文件时,它没有。 What am I missing here?我在这里缺少什么?

Apparently there's two different settings for the console.显然,控制台有两种不同的设置。 One for the User Account and another for initial console window title(in this case my application).一个用于用户帐户,另一个用于初始控制台窗口标题(在本例中为我的应用程序)。 I was able to look at the settings within Regedit.exe, HCKU/Console key and remove the settings for my initial console window title and then ran application (as admin) and changed the defaults there.我能够查看 Regedit.exe、HCKU/Console 键中的设置并删除初始控制台窗口标题的设置,然后运行应用程序(以管理员身份)并更改那里的默认设置。 Thank you for the comments!谢谢你的意见!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从控制台应用程序Visual C#2012中的应用程序在Windows中创建(.exe) - How to Create (.exe) in Windows from application from Console application Visual C# 2012 如何在C#控制台应用程序中使用IsolatedStorage - How to use IsolatedStorage in a C# Console Application 如何在控制台应用程序中使用 ShowFileDialog c# - How to use ShowFileDialog in Console Application c# 如何在 c# .net core 3.1 控制台应用程序中保存设置? - how to save settings in c# .net core 3.1 console application? Powerwise:在C#(。NET)中使用控制台或Windows GUI应用程序更好吗? - Powerwise: Is it better to use console or windows GUI application in C#(.NET)? 在Windows窗体应用程序项目中使用C#控制台引用 - C# console reference use on windows form application project C#:Windows控制台应用程序到Windows服务 - C#: Windows Console Application to Windows Service 如何连接控制台应用程序和Windows窗体应用程序C# - How to connect console application and Windows form application C# Windows 2012 R2中的管理员DOS / CMD窗口不接受C#控制台应用程序中预期的ESC键 - Administrator DOS/CMD window, in Windows 2012 R2, is not accepting ESC key expected in C# console application 从C#控制台应用程序终止Windows进程:如何设置权限? - Killing a Windows process from a C# console application: how do I set permissions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM