Capture output value from a shell command in VBA?

Based on Andrew Lessard’s answer, here’s a function to run a command and return the output as a string – Public Function ShellRun(sCmd As String) As String ‘Run a shell command, returning the output as a string Dim oShell As Object Set oShell = CreateObject(“WScript.Shell”) ‘run command Dim oExec As Object Dim oOutput As Object … Read more

Run cmd commands through Java

One way to run a process from a different directory to the working directory of your Java program is to change directory and then run the process in the same command line. You can do this by getting cmd.exe to run a command line such as cd some_directory && some_program. The following example changes to … Read more

How do I measure execution time of a command on the Windows command line?

PowerShell has a cmdlet for this called Measure-Command. You’ll have to ensure that PowerShell is available on the machine that runs it. PS> Measure-Command { echo hi } Days : 0 Hours : 0 Minutes : 0 Seconds : 0 Milliseconds : 0 Ticks : 1318 TotalDays : 1.52546296296296E-09 TotalHours : 3.66111111111111E-08 TotalMinutes : 2.19666666666667E-06 … Read more

Is there any sed like utility for cmd.exe? [closed]

Today powershell saved me. For grep there is: get-content somefile.txt | where { $_ -match “expression”} or select-string somefile.txt -pattern “expression” and for sed there is: get-content somefile.txt | %{$_ -replace “expression”,”replace”} For more detail about replace PowerShell function see this Microsoft article.