Is there a way to use the popular Console2 cmd.exe replacement for Visual Studio debugging? In other words, when I debug a console app under VS, I want it to use Console2 instead of cmd.exe.
Interesting question. I looked into it, there are some options but none are pretty.
Console.exe takes arguments, so it's possible to start it with a specific tab and execute an arbitrary process. However, this process will always be run within it's own cmd.exe; for example if your program is c:\my.exe and you launch Console as console.exe -t tabname -r c:\myexe Console2 internally calls CreateProcess( ... cmd.exe c:\my.exe ... ), as a result you can't even see the output of my.exe. This is easily solved though: launch it as console.exe -t tabname -r "/k c:\myexe": the /k switch makes the cmd.exe stay active and you can see your program's standard output. (I looked through the source but couldn't find a way to 'attach' a tab to a currently running Console instance, so launching with arguments will always create a new instance, not sure this is what you are looking for?
You can easily modify the project's debugging properties to reflect the above:
Command: /path/to/console.exe
Command Arguments: -t tabname -r "/k $(TargetPath)"
When starting your exe from within VS, it will launch your exe witin a Console session. However the debugging won't work as VS will try to debug console.exe, not my.exe since that is now a different process. Putting a DebugBreak(); as first line in your exe's main() will sort of solve this, as it will present you the option to debug your exe. All in all, this may a bit too much of a hassle to achieve what you want, but i don't think there's another way: Console always spawns a new process, so the only way to get it debugged is to attach the debugger to it after that process started.
Scott Hanselman blogged about this.
He suggests using this value for Console Settings > tabs > Main > Shell :
%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
Sadly for me, This does not appear to work for Visual Studio Express 2010, which lacks a vcvarsall.bat file.
Related
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
I have a process in UiPath to automate PyCharm, a really simple one like just running a Python script and copying the run message into a text file. Now I want to convert it into a binary file to be executed on a windows machine.
I came to know that UiPath did have an option for exporting projects into executable files but sadly it was also removed.
I also reviewed the orchestrator for UiPath but that does seem meaningful to me. I didn't understand why a company would remove such a crucial feature (conversion to executable) and provide a messy solution like this. May be I'm missing something.
My question is....
Is there any workaround, any third party trick that can convert an UiPath project into windows executable file.
UiPath does not want users to be able to run executables directly. They are forcing users to use Orchestrator. So they always have the full control about the users and their licensing model. If they would still offer the executable way, someone could easily create a Task with UiPath and send this to any other PC without using a UiPath account. So this is mainly the reason they stopped offering this method. But you still have some other options to run your process so don't worry.
Those ways are:
Use Orchestrator. Run process from your Orchestrator dashboard (via Jobs manually or time triggered or even another starting trigger).
Use Orchestrator and use UiPath Robot (comes already with the UiPath installation). Now you can simply start it from tray icon.
Use UiPath Studio and start process from here.
Create a batch file that runs the start command script for your process. This line UiRobot.exe_Path /file:"Main.xaml" will run your process.
Create a Visual Studio application (exe) that runs the batch file from #4.
Use REST API to run the process.
As you can see you have several options but unfortunately the exe workaround is just a wrapper for the batch file.
I would recommend you to use Orchestrator, as it gives you so many possibilities and control on your processes and a good logging.
The simplest way to do this would be to call the UiPath Robot Command Line Interface within a batch file. I suggest that you package the process first and then refer to that package in the batch file using the UiPath.exe execute command with the --process {Package_ID} argument. You can add UiPath.exe to your PATH environment variable so you don't need to use an absolute path to the exe in your batch file. The batch file will be able to run on your Windows VM just like an executable. Alternatively, you could add a shortcut to UiPath.exe and add the arguments to the target of the shortcut in the properties menu of the shortcut.
I'm using AutoHotkey script for this purpose and thought I'd share my method,
Create a *.ahk script using below code,
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode,2
DetectHiddenWindows, On
; you don't need to modify below code unless UiPath Studio changes its shortcut name
EnvGet, LocalFolder, LocalAppData ;use windows Env variable to get local appdata folder
UiPath=%LocalFolder%\UiPath
UiPath_ShrtCut=%A_Programs%\UiPath Studio.lnk
UiPath_Prcss:="UiPath.Studio.exe"
UiPath_Asstnt:="UiPath.Assistant.exe"
FileGetShortcut, %UiPath_ShrtCut%, , OutDir ;get parent directory of shortcut.lnk
;modify your_script_path\Main as per your script and its path
Script=""%OutDir%\UiRobot.exe" "-file" "your_script_path\Main.xaml"" ;script folder and script name
; you can add additional clause in here
If (FileExist(UiPath) "D")
{
Process, Exist, %UiPath_Asstnt%
if ErrorLevel = 0
{
Runwait, %UiPath_ShrtCut%
WinWait, ahk_exe %UiPath_Asstnt% ;wait for UiPath.Assistant to load
Sleep, 2500
Runwait, %comspec% /c TASKKILL /im %UiPath_Prcss% /f ,,Hide ;now kill UiPath main window
;Run, %A_AHKPath% %Rec_Script% ;run record
Run, %comspec% /c %Script%,,Hide
}
else
{
;Run, %A_AHKPath% %Rec_Script% ;run record
Run, %comspec% /c %Script%,,Hide
}
}
return
Then create a task schedule as per your desired trigger and use following in action tab,
Program/Script: "C:\Program Files\AutoHotkey\AutoHotkey.exe"
Add Arguments (optional): "Script_path\Script_name.ahk"
I can't figure out how to start the OneNote UWA from Windows command-line. The best I could do is find where it's installed. However, I don't know how to actually start it up from the command-line; as, the executables in that directory don't start OneNote UWA.
C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11901.20096.0_x64__8wekyb3d8bbwe
PS: I tried to use the same command-line that's in Windows TaskManager (below). However, the app doesn't startup nor does it give an error; even with elevated privileges.
"C:\Program Files\WindowsApps\Microsoft.Office.OneNote_16001.11901.20096.0_x64__8wekyb3d8bbwe\onenoteim.exe" -ServerName:microsoft.onenoteim.AppXxqb9ypsz6cs1w07e1pmjy4ww4dy9tpqr.mca
I'd really appreciate any help suggestions to do this. If this is not possible (or nobody knows the answer, I would also be happy if someone knows how to associate a global hotkey to OneNote UWA.
I followed this tutorial and it worked great for me:
Launch Metro app from command line
my resultant command was this:
explorer.exe shell:AppsFolder\Microsoft.Office.OneNote_8wekyb3d8bbwe!microsoft.onenoteim
which launched into OneNote (metro/winrt/uwa version and not the desktop version)
There is a shortcut you can do that would have worked in my case. When you look at the target of the shortcut you create... instead use this command line tool to get the full target (since you can't copy from the target box in the shortcut properties window) and then use this instead:
explorer.exe shell:<target value>
get the command line tool here:
LNK file parser
careful though because the value wraps when you use the LNK file parser in a command window. You can output the result text from lnk_parser_cmd to a text file to ensure you get the correct value. Their example is:
lnk_parser_cmd.exe shortcut.lnk
you would simply use:
lnk_parser_cmd.exe shortcut.lnk > result.txt
and then you can easily copy and paste the non-wrapped text from result.txt.
I hope this is an easy fix, but I couldn't find any documentation or other posts on the matter. I'm trying to write a script (cmd or pwsh) that will launch vscode with my preferences on a portable install.
When trying to execute vscode's code.exe with any arguments, it ignores them and just launches the program as if I had typed nothing else. I'm following this doc in my testing. Using alias switches doesn't work, either. The only argument that does seem to process is if I include a path.
code.exe --help
code.exe --version
Additionally, after launching code.exe, the console kind of hangs, then vscode status messages are sent to that console (even without use of the --wait switch). If I close the console, vscode shuts down. Is there a way to work around this?
When using Code via shell (cmd or pwsh), it does not use Code.exe, but the script/batch files located under Bin folder (code.cmd). These are the applications which really recognizes the command line switches.
This is not entirely clear in the Command Line Documentation page, but looking closer at the Note you will see that it does say the Program Files\Microsoft VS Code\bin folder.
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.