Command Prompt vs System() in Visual Studio? - visual-studio-2010

I'm attempting to use imagemagick to combine a bunch of .ppm files I create in Visual Studio, each a piece of an animation.
When I complete the program and get all of the output*.ppm files, I can go to my command prompt and say im-convert -delay 80 output*.ppm final.gif, it works perfect and creates the gif. However, using a system("im-convert -delay 80 output*.ppm final.gif"); call in my code, the result says that im-convert is not a recognized command.
I'm not sure how to go about fixing this. Does visual studio not use the same command prompt? Do I need to include the .dll for imagemagick somewhere else where that command prompt will find it?
Thanks :)

Related

Why does nothing changed to open a program in windows while using the assoc command to alter the specific extension to another different?

I use the windows 10 pro version and open the command prompt as the administrator to run the windows commands in my laptop. Using the assoc command to change the file extension file to another different (e.g. assoc .jpg=txtfile), I find nothing changed after running it and still that jpeg file opens with the regular program instead of notepad. In addition I can see the only change in by typing just the assoc and running it when a list of extensions belonging to different programs appears. Fo instance I have changed the .jpg file to txt file that it shows only as '.jpg=txtfile" in the list but tyat is still opened in jpeg program not notpad? Is anyone here to help me with clearly. Thanks
You need to use ftype as well. I have a link saved to MS docs that says it is up-to-date till Win8: https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/cc771394(v=ws.11).
Maybe nothing has changed in Win10, but you get the idea from the above and can Google it for Win10.

How do I execute OneNote UWA from Windows command-line?

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.

Configuring cl CMD compiling Windows

I have already read on MSDN.com that to enable command line compilation through the cl command you have to run the vcvarsall.bat file. I have run this file in CMD and compiled code using the cl command. The issue is that after I leave the CMD and reopen it, I no longer have the ability to use cl and have to rerun vcvarsall.bat every time I reopen CMD. Is there any way to avoid having to do this? Thanks.
Just create a shortcut on your desktop that calls
cmd /k "%VS140COMNTOOLS%\vsvars32.bat"
Adapt the environment variable and batch file name to fit your installed VS version number. In the example above, this will work with Visual Studio 2015.

Possible to Auto Open file in Visual Studio

I currently use the following cleartool command using Visual Studios External tool interface:
Command: \installationpath\cleartool.exe
Arguments: annotate -nheader $(ItemPath)
Initial directory: $(ItemDir)
I do use the output window. Which will let that command print out the location of the .ann file it produces. I'm wondering if there is a way for Visual studio to auto open that produced file?
In this case its not a huge hardship to copy the location and open the file. I'm just always looking for ways to make things easier.
Using just one external tool, you wouldn't be able to execute cleartool, and to open a file (generated from the cleartool command).
You can open a file from a Visual Studio External Tool as explained here, but that wouldn't execute cleartool.
So I would recommend executing a script (.bat, .cmd, .vbs) in order to:
do the cleartool command you want
open the generated file.
You would pass to this script no only $(ItemPath), but also, depending on where it is generated, $(ItemDir), or $(ProjectDir), or $(SolutionDir), or $(TargetDir).

Use Console2 for Visual Studio debugging?

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.

Resources