How Can I Make XPerf Write To Alternative Disk - c#

Last time I used XPerf it killed my SSD, too much disk activity.
Is there an easy way to make XPerf write its trace data to an alternative hard drive?
I am using the script HeapMonitor.cmd to start up XPerf, so I am guessing there are some command line options for XPerf that will do what I need?

I haven't tried this but maybe you can work it out with a combination of absolute paths for ProfileFileName in -start and MergedETL in -stop -d ?
Here's a link to the command line parameter help.

OK, so the answer is simply to move the HeapMonitor.cmd file to the other hard drive (non SSD) and it will just work.
There are command line options which look like this,
-f heap.etl
which could be changed to
-f f:\blah\heap.etl
I have done some of them, but not all of them, and it still seems to work.

Related

Sorting video files based on whether they contain sound or not

I have never done any programming until now, so I am open to any language. How do I start on a script to sort videos into those with sound and those without sound? I have hundreds of short mp4/avi clips that are randomly named. Is it possible to write a piece of code that automatically sorts them based on whether they have audio?
Can anyone write me the script? I would be eternally grateful. If not, can anyone point me to some easy to understand tutorials? I was told to use ffprobe and a script but I have no idea how to start.
Thanks
On Windows, you can run directly at the command line,
for %i in (*.mp4 *.avi) do ffmpeg -i "%i" -v 0 -map a -t 0.1 -f null - && move "%i" with-audio || move "%i" no-audio
where with-audio and no-audio are sub-folders you created in the location where you ran the command. You can, of course, replace these with absolute paths to a central set of folders. If using within a batch file, replace %i with %%i
Basic logic is that the given ffmpeg command will report success if a given file has audio and failure otherwise. In the former case, the command after the && gets executed, In the latter, the command after the || gets executed.

Automate commands in git cmd?

Is there a way to automate input in git-cmd without actually typing in the input command? Let's say write the input to a script to run automatically?
start git.cmd
connect to git server.
clone git repository.
input password.
I have this exact same situation and I automated it using expect
#!/usr/bin/expect
set timeout 600
log_user 0
spawn git clone http://myuser#myserver/group/repo.git tmp/repo
expect "Password for 'http://myuser#myserver':"
send "mypassword\r"
expect eof
Key was setting timeout appropriately.
I see that expect for Windows is available.
Assuming "git-cmd" is the Windows command shell setup for Git then all you need to do is write a command script (or batch file). You can find general instructions here. It is worth noting that the Git bin folder will need to be in your path. The Git command to clone a repository is described here. As was mentioned in another answer you could write a program to spawn a command shell and run the command script, but that seems the long way around.
Hope that helps.

Non-Terminating Process Git Bash (C#)

As a fun little project, I am trying to use C# to operate the bash.exe provided by Git. I want the process to behave just as if I ran it in the Git Bash Application. By this, I mean I want to be able to execute command and get the output of said commands (i.e. if I enter the command "curl --version", I want to get the same output as the image here and be able to store it in a variable)
I have come very close to accomplishing this with the code here. However, with some commands, I find that the Process in C# never terminates. For example, if I try to execute the command "curl --help", I find the the Process never exits where "curl --version" did. As a quick hack, I figured out that I could fix this by changing the command to
curl --help >> output.txt
and then reading the .txt file. This does cause the command to exit and to write the correct output to the file, however, I don't like having to do this and I am sure there is a better solution to make commands of this sort exit properly. Thanks for the help!

Include a batch file in a batch file

I have a problem calling a batch file from another batch file when trying to run everything by using Process.Start. Basically I call the execution of a batch file from my c# program that looks like this:
call include.bat
//execute the rest of the batch file here
The include.bat file sets up paths and can be used by a number of other batch files. When I run the Process.Start sometimes this works and sometimes I get ERROR: cannot find include.bat. First of all any idea why this happens? And ideas on how to fix this from the batch file?
To switch to the directory your batch file is located in, use this:
cd %~dp0
I do this in almost all of my batch scripts. That way relative paths should always work.
I know this is an old question but I thought it would be worth noting that the approach promoted by the accepted answer (i.e. changing the working directory) may not always be appropriate.
A better general approach is to refer to dependencies by full path:
call "%~dp0include.bat"
(Since %~dp0 already ends with a backslash, we don't need to add another one.)
Here are some benefits of not changing the working directory:
The rest of the batch file can still use the original working directory.
The original working directory in the command prompt is preserved, even without "SETLOCAL".
If the first batch file is run via a UNC path (such as "\\server\share\file.bat"), the full-path call will succeed while changing the directory (even with "cd /d") will fail. (Using pushd/popd would handle this point, but they have their own set of problems.)
These benefits are particularly important for alias-type batch files, even if they are not as important for the specific situation that motivated this question.
Before the script, try CD /D %~dp0
First thing I'd try is to use full path information in the call statement for include.bat. If that fixes it, you probably are just not running the batch file from the proper location. I'm sure there's a "working directory" capability in C#, I'm just not sure what it is.
Do you set ProcessStartInfo.WorkingDirectory ( http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.workingdirectory.aspx ) on the ProcessStartInfo that you pass to Process.Start?
Since include.bat sometimes cannot be found, working directory may be wrong (not the folder where include.bat is located).

Unlock a file with unlocker from a WinForms App?

I am trying to unlock a file from a C# program, using unlocker.
In my UI, I put a button to unlock the file the app couldn't delete. When the user pushes the button, I want unlocker (the famous app) to be opened.
I have read about in the Unlocker web, and there is some explanations about the commandline to use but nothing works.
I write the following code but nothing happens:
"c:\Program Files\unlocker\unlocker.exe" -L "PATHFORTHEFILE.doc"
Nothing happens. I have tried without parameters and with -LU.
Any idea?
Something more efficient than unlocker to integrate it with software?
If unlocker comes with parameters -L and -U, I don't think L would be the one you want to unlock with. Probably U is for unlocking ;)
If you have any control of the application that is locking the file, it would be a better solution to have that program free the file rather than a third party app rip it away like this.
Look at the documentation for the System.Diagnostics.Process class and the related ProcessStartInfo class.
unnlocker.exe c:\song.mp3 -s -d
-s unlock
-d delete

Categories