I have a console application (.bat file) which starts in a console window. I have a shortcut to this app on my desktop, which contains several properties which I need to change programmatically (in example font of this specific window).
How can I do this? The best option for me would be to do it using cmd.exe commands, or using .net environment, is that even possible?
Related
Is it possible to embed a Powershell screen in my application?
I want to see the screen itself, just like Visual Studio does. I cannot use a console redirect as that option would not allow me to interact with programs or view programs displaying colors and the like.
Capture both standard input and standard output is not a possible solution. I am using programs that use colors and progress bars.
It would be something similar to being able to implement a Windows Terminal, or https://github.com/dwmkerr/consolecontrol
I also tried this code, but it does not allow me to embed to Terminal server although I can use it with Notepad Run extended programs GUI on my own c# form
Looking for information, I found a project that apparently could be what I am looking for but it does not work with Winforms and I cannot find a simple example of use. https://github.com/PowerShell/PowerShellEditorServices
I want to create two shortcuts on Desktop after publishing the app, both of them should pass different args to the Main method of the Program class:
How can I achieve this? Or is it even possible?
Do you already use any sort of installer for your application? One example how you could do this would be to use an installer like InnoSetup for creating the desktop icons (example: How to create a desktop icon with Inno Setup).
Of course you can also do this programmatically but without knowing how you publish your app I cannot give you any specific answer for your way of publishing.
I am trying to develope a windows application to display console window as output.
If i changed output type in properties to "console Application" both the console window and form showing. But i need to show only form window first, when i click a button then only the console window need to display the output value.
Please guide me...
Thanks in advance.
Each process can have only at most one console associated with it. There are several paths you can take: either you hide the console window immediately on startup and show it later (via ShowWindow), or you leave the project as a window application, and create the console manually using AllocConsole later.
In the case you wanted multiple consoles, you can e.g. create a dummy process (cmd) and attach your process to its console, using AttachConsole. The managed way would be to use remoting or other techniques to communicate with the dummy process (with your own implementation), and print texts through that.
Use NativeMethods.AllocConsole(); to allocate a console and I/O with it.
Use NativeMethods.FreeConsole(); to close and free this console.
You wanna output the Console.WriteLines of a Windows Forms app inside the form?
In that case just use Console.SetOut(Stream) and pass in something you're wrapping so you can also output it somewhere else.
Another option is to switch all your Console.WriteLines to Trace.WriteLine and add a TraceListener somewhere that does what you want.
This is based on C#. I am having a classlibrary in which I would like to know specifically if its being called from a windows based application
I searched a lot but all I found was code to know if it was called from a Console application.
I only want to know if its called from a windows based application or not
Please Help
If you want to know whether the application is running as a service or system app and thus cannot display a dialogue, test the state of Environment.UserInteractive.
There is no easy way to determine if the application is a windows or cmd-based application. For example, I might build a winforms-based application that doesn't create a window and instead runs as command-line style application by not opening a window.
Two (not necessarily reliable) ways of testing if it's a windows-based app would be to test Application.OpenForms (if it contains forms, then it's a windows app) or Environment.GetCommandLineArgs() (if 0 args, assume it's a windows app).
If you absolutely need to know whether the app is a console or windows one, then you need to step out of the world of managed code and start delving into the exe file using unmanaged C++ code. There is just one byte difference between the two in the PE header of the exe file: Subsystem is set to 2 for a windows app and 3 for a cmd app. See http://msdn.microsoft.com/en-us/library/ms809762.aspx and http://support.microsoft.com/kb/90493/en-us for details if you really want to do this.
I am new to .NET, I have made a small app. I want that this app should start when we start Windows, also how to make this app be present like a system tray icon if we minimize it. The app is a Windows form application.
As far as having it start automatically you can make it a windows service or you can simply place it in the windows startup folder and it will automatically launch it. For the System tray you should look into the NotifyIcon control.
For starting: couple of options..
1: Use scheduled tasks - accessed through control panel / adminstrative tasks
2: Make a shortcut to your exe in the startup folder in your start menu
For system tray: refer to this question: What's the proper way to minimize to tray a C# WinForms app?
in addition to what #Jesus said
you can also add a registry entry for start up. Windows service wouldn't do if your app is requiring the tray icon.
Best bet IMO is to make an installer project and configure the installer to have it start with windows when it's installed. Let the installer figure it out.