Visual Studio 2010: Opening a file using command line resets window layout - visual-studio

The following command works fine. It opens a new instance of Visual Studio 2010:
devenv
But if I specify a file name, Visual Studio's window layout will be reset.
devenv "D:\Temp\test.txt"
Any ideas? Thanks.
Update:
This command works:
devenv /command "open D:\Temp\test.txt"
But the file path cannot contain spaces. The following command gives an error: "The operation cannot be completed. The system cannot find the file specified":
devenv /command "open D:\Temp\test 2.txt"
I tried:
devenv /command "open 'D:\Temp\test 2.txt'"
But got the same error.

OK I think understand now.
Visual Studio uses different layouts for different situations. It uses a special layout when it is opened from command line with a specified file name.
I have never custom this layout so it looks like the default one, made me thought the layout was reset.

Related

How to open a file using Visual Studio debugger commands

Is it possible to open a file using debugger commands options of Visual Studio?
For example I want to run my program (with some command arguments) and then open a file.
The cmd equivalent would be:
app.exe args & file.png
Can I do the same thing in visual studio using projects settings or any other way?
You can use dev command prompt inside Visual Studio to achieve the same result
You can open Developer Command Prompt from Tools > Command Line menu
Then just type in whatever command you use in cmd

Loading multiple solutions into Visual Studio 2015 on start

I have multiple solutions generated by script from cMake and I want to open all at once in a Visual Studio instance.
I found /command as parameter of devenv.exe when running from command line.
There are commands like File.OpenProject and File.AddExistingProject, but I can only pass one of them to /command at the start.
As I see so far there is no character to separarate the commands in one string.
Thanks in advance

Change directory in visual studio command prompt

I want to know what is the command I should execute in the command window of the visual studio 2013, to change directory to:
C/:Users/user/Documents/Visual Studio 2013/Projects/OutlookAddin/publish/<Most_Recent_Version>/OutlookAddin_TemporaryKey.pfx
What is the command I must execute?
Actually, cd cmd works, but in a bit diff like this:
syntax:
cd /d c: or e: etc..
where /d stands for drive
for instance:
cd /d C/:Users/user/Documents/Visual Studio 2013/Projects/OutlookAddin/publish//OutlookAddin_TemporaryKey.pfx
No need for the single or double quote in this case.
Now to execute any type of files for instance simply add '.\' before the executed one.
syntax:
.\OutlookAddin_TemporaryKey.pfx or .\example.exe what so ever
cd does work. However, keep in mind that if the path you're trying to get to has spaces, you need quotes around it (the path). E.g.:
cd "C:\Program Files\Microsoft Visual Studio 10.0" Also, note that the
"Visual Studio command prompt" that is mentioned in Step 6 is not the
"Visual Studio Command Window" - I think this is where the problem
comes from. The command prompt is a separate executable that you can
start by clicking Start, point to All Programs, point to Microsoft
Visual Studio, point to Visual Studio Tools, and then click Visual
Studio Command Prompt. Alternatively, just search "Visual Studio" in
the search bar in the Start menu, and it should show up
Source: Using the Command Window in Visual Studio
First create a file on CMD (COMMAND PROMPT)
1.cd desktop
2.mkdir filename
3.cd filename
4. code .
(It has to be a space between code and the dot to open up the file in visual studio code)
Note: If you just want to open visual studio, then go to CMD and just type in 'code' without the dot.

Change Default Visual Studio Command Prompt Location

How to set the default visual studio command prompt location so that I can go straight to my project's directory instead of using the usual navigation.
For Visual Studio 2017 Command Prompt, you need to set environment variable VSCMD_START_DIR to the directory where you want to end up after the command prompt initializes.
I use this script:
set VSCMD_START_DIR=%1
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
It accepts the directory as the first (and only) argument.
Add it as an external tool to Visual Studio (2008 shown here, should be similar in other versions):
Select "Tools", "External Tools...".
Click Add
Title: &Cmd
Command: cmd.exe
Arguments: /k "c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
Initial Directory: $(SolutionDir)
Note the arguments come from the "Visual Studio 2008 Command Prompt" shortcut. Yours may vary.
You can can customize the toolbar and add a button for this command as well using "Tools", "Customize...". Open the Tools menu and locate the last External Tool you created and drag it onto the toolbar.
When you click the button, it will open a command prompt in the current solution's root directory.
In Visual Studio 2013,
Right click on "Developer Command Prompt for VS2013" shortcut (which you can find in the "Common7\Tools\Shortcuts" folder from where you installed your VS2013) and choose "Properties",
Change the: "Start in: " directory to your desired location.
Navigate to the "vcvarsall.bat" file. For me the path is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
Add this line to the bottom of the script:
cd /d "D:\WhereverYouWant"
skol
For Developer Command Prompt for VS 2019 you can set VSCMD_START_DIR environment variable with the following command:
setx VSCMD_START_DIR C:\your-folder
You can put these lines in a batch script (vcvar.bat) located in the directory you want to start with:
#echo off
set VCDIR=%ProgramFiles%\Microsoft Visual Studio 10.0\VC
if not exist "%VCDIR%" set VCDIR=%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC
call "%VCDIR%\bin\vcvars32.bat"
Fire a command prompt in this directory, and call vcvar.bat. You now have the VS environment in the command prompt.
Copy Windows Command Processor from "C:\Windows\System32\cmd.exe" and paste to "C:\Your\Project\Directory\cmd.exe"
Edit Visual Studio Command Prompt shortcut by replacing %comspec% with "C:\Your\Project\Directory\cmd.exe" in the Target field.
So the shortcut's Target should look something like: "C:\Your\Project\Directory\cmd.exe" /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" amd64
this will add a menu entry "my compiler " to each directory giving you access to the command prompt in the directory.
save it as something.reg
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\My Compiler]
[HKEY_CLASSES_ROOT\Directory\shell\My Compiler\command]
#="cmd.exe /k \"C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\vcvarsall.bat\""

Is there a command line option like devenv.exe /Edit for Sql Server Management Studio

I'm using visual studio's external tools to open .sql scripts in Sql Server Management Studio (SSMS). The problem is, each time I use the external tools command to open a .sql file from visual studio, it opens a new instance of SSMS.
Visual Studio has a switch /Edit that will do this, is there one for SQL Server Management Studio?
Choose to open the file with Explorer[1] instead of SSMS. That way the system will search for any existing instances of SSMS first.
[1] %windir%\explorer.exe
I don't think the problem is with Visual Studio external tool command. Look at SSMS command line options - maybe there is a way to force reusing existing SSMS instance.
The following works for me ( I am SQL Server 2008 though) :
So the real answer I quess is to use cmdow
Edit: After more testing I realized the following :
First open the files with connenction with: ( remove any enters while copying, this is one liner )
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\
Common7\IDE\Ssms.exe" "C:\Users\yordgeor\Desktop\Trigger.sql"
"C:\Users\yordgeor\Desktop\Trigger1.sql" -S ysg -d poc_dev -E -nosplash
In this example it opens two files ( but you could open less of course ; )
after which , No matter how many times I run
cmdow /Run "C:\Users\yordgeor\Desktop\Trigger1.sql"
cmdow /Run "C:\Users\yordgeor\Desktop\Trigger2.sql"
cmdow /Run "C:\Users\yordgeor\Desktop\Trigger3.sql"
it opens the same instance of the Microsoft Sql Server Management Studio with the same connection
you could open at once at the command line many files , but I quess you asked for the upper answer.
So you could find the path to the Ssms.exe by:
cd %ProgramFiles%
dir *ssms.exe /s /b
so the syntax of the command is:
pathToTheExe pathToFile1 pathToFile2 -S serverName -d DatabaseToConnectTo -E (toUseWindowsAuthentication) -nosplash
After 20 seconds of googling I cheated from here:
The correct answer is no. The SSMS has a limited set of options, and although it uses the VS framework, does not support the edit command. This could be an interesting feature to add.
I am assuming you need to open these scripts in SSMS to be able to run them as well, otherwise I would suggest pointing them to Visual Studio directly since it does support syntax highlighting. However it will not solve your problem.
If you associate that file extension with Visual Studio, then VS should open it.
If you're finding that VS starts a new instance every time, then you need to specify the /edit command line option.
Take a look at http://stevedunns.blogspot.com/2009/03/programs-that-launch-or-should-launch.html for more information.

Resources