I run my application from cmd using dotnet command but after application started, I cant use cmd window. It does not allow me to type further commands. It sits the state shown below.
How can i prevent this?
Also as a second question, when I closed this cmd window, my dotnet application stops. How can I also prevent this?
Related
I am trying to call tpmvscmgr.exe located in C:\Windows\System32
from my c# application.
I found this code:
string strCmdText;
strCmdText = #"/C Robocopy C:\Users\Johannes\test1 C:\Users\Johannes\test2";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
here Run Command Prompt Commands
and it works good.
However when I try to change it to
strCmdText = "/C Tpmvscmgr.exe create /name tpmvsc /pin default /adminkey random /generate ";
This does not work.
In fact when I debug and look around in the command prompt opened by the code I can not find the tpmvscmgr.exe in windows/system32.
Im guessing it is opened as a different user or with other priviledges or something but can this be fixed?
I really would need to run a tpmvscmgr.exe command from code.
OK I figured something out.
In my visual studio c# project I had "Any CPU" marked for the project. Apparently this means the console opens as win32.
When I changed the c# project to x86 I could run tpmvscmgr.exe
Pretty tricky stuff.
C# cmd prompt cannot see telnet.exe
I opened the command window in Visual Studio 2015 CTP and given the following command
>k ef migration add [migration name]
>k ef migration apply
It is giving the response message as Unable to set the current stack frame.
How to solve the above issue.
I am Scaffolding a new migration for the pending model changes and applying them to the database from the command line.
I am following on View components and Inject in ASP.NET MVC 6
In an administrator command window, change the directory to the project directory. The project directory contains the project.json file.
Then run the commands from there.
So in short, don't use the visual command window, but an actual windows command window.
You should follow these steps to install the K command:
Install the K Version Manager (KVM)
Open a command prompt with Run as administrator.
Run the following command:
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.ps1'))"
The script installs KVM for the current user.
Exit the command prompt window and start another as an administrator (you need to start a new command prompt to get the updated path environment).
Upgrade KVM with the following command:
KVM upgrade
You are now ready to run EF migrations.
The source is your shared link "View components and Inject in ASP.NET MVC 6"
Than you need to run commands at cmd.exe
I have an installation package (Visual studio installer). During the installation process i attach a database to MS Sql server using SMO.
When the uninstallation process is started the dialog "The following applications ("SQL server(MSSQLServer)") should be closed before continuing the install" appears. The dialog has two options "Automatically close applications and attempt to restart them after setup is complete" and "Do not close applications(A Reboot may be required)". if i select first one option, i see the error "cannot connect at server". With the second option all works correctly.
In the unistall method of my custom action i use SqlCommand (command text: DROP DATABASE [baseName]) for deleting database.
Uninstall method code:
using(var con=new SqlConnection(_server.ConnectionContext.ConnectionString))
{
con.Open();
string sqlCommandText = string.Format("DROP DATABASE [{0}]", DATABASE_NAME);
var sqlCommand = new SqlCommand(sqlCommandText, con);
sqlCommand.ExecuteNonQuery();
}
How can i avoid the dialog "The following applications ..." and always use the second option? Or maybe there i some other way for deleting db?
OK, so here's the scenario.
CruiseControl.NET (Version : 1.5.7256.1) runs a project to rebuild a database. The CruiseControl.NET windows service is running as a windows user we created for CC.NET. There are several tasks in the project but they all run fine. However, one of the tasks that runs is a console based utility I wrote in C# that generates a batch file and then runs it via an instance of the .NET Process class.
The batch file is generated properly and the process runs fine in C#. However the batch file that runs, runs the sqlcmd command line utility for SQLServer (Version 2005 SP3). sqlcmd runs as expected, but one of the options for sqlcmd never gets applied... -I (turning quoted identifiers on).
e.g.
sqlcmd -U %1 -P %2 -S %3 -d %4 -i someScript.sql -k -b -I >> %LogFileName%
The odd thing is if I run this from a command prompt on the continuous integration server, it runs with -I being applied.
I'm very confused. I'd understand if the sqlcmd failed because the user executing the process didn't have enough privileges and I'd understand if something went wrong on the SQLServer side if the SQLServer authentication failed, but for it to work but not apply an option to sqlcmd is mystifying.
Could it be it's because -I is the last parameter? Perhaps there's a missing space there or something.. have you tried switching parameter order?
(also, why are you running a C# console app that create a batch file and the invokes it? Can't cc.net run this file itself?)
I going to get the command prompt from my C# application to compile some C++ files. Code is like this.
private void button1_Click(object sender, EventArgs e)
{
string filePath = #"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe";
System.Diagnostics.Process.Start(filePath);
}
But After i click the button it suddenly comes and disappear. Even its opening two command prompts. I need to Hold it and only one command prompt should appear. Can some one provide me the necessary codes. Thank you.
You could also do this:
Process.Start("cmd /k cl.exe");
This will launch cmd.exe, running the specified command, and keeping the window open after it's done.
You could change the command from:
<command>
to:
cmd /k <command>
That will cause the command to be run, and then the window will stay open with the command prompt.
The simplest way would probably be something like so:
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = "cmd",
Arguments = #"/k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\cl.exe"""
};
Process.Start(psi);
You could write your own command prompt program that acts as a container and runs the required EXE files. After running, it can use "cin" (c input) to wait for a keypress and this will stop it closing.
You're not opening a command prompt as such, you're just starting a command line app that opens, have nothing to do and then closes.
If you want to open a command prompt you can call System.Diagnostics.Process.Start("cmd");.