cmd.exe

In a batch file, is it possible to replace this use of SED and TR with a for loop ?

the batch file: @echo. @set curdrive=%~d0 @path | %curdrive%\utils\sed -e "s/PATH=//" | %curdrive%\utils\tr ; \n @echo. Sample output (one path element on each line): C:\cheeso\bin C:\Perl\bin c:\utils C:\Windows\system32 C:\Windows C:\Windows\System32\Wbem c:\Program Files\Microsoft SQL Server\90\Tools\binn\ c:\.net3.5 c:\.net2.0 c...

How to extract numbers from text file using Windows batch file?

I need to do the following using cmd (Windows command line). I have one file named DDD.CLI026.WK0933.DDDMR45.001.head. The data in file is as follwing (in one long line) HEAD HEALTHDMD Weekly DDD.CLI026 Centocor W200908021012 TRAIL0101 000000000581 00000CKSUM00000223680 I need to extract 581 from 000000000581 and copy it in anoth...

Batch file encoding

I would like to deal with filename containing strange characters, like french é. Everything is working fine in the shell : C:\somedir\>ren -hélice hélice Know if I put this line in a .bat file, I obtain the following result : C:\somedir\>ren -hÚlice hÚlice See ? é have been replaced by Ú The same is true for command output. If I ...

How would you write a .bat or .cmd file to remove an element from the PATH?

Related: How to list the elements of the path in a batch file? How does FOR work? How would you write a batch file or CMD file to remove an element from the path? It should handle gracefully: differences in case shortnames and long names I've done this using tr.exe but it's slow and complicated and uses temporary files, which mak...

Which is better to use for a recurring job: Service or Scheduled Task?

I have a task that needs to run every 30 seconds. I can do one of two things: Write a command line app that runs the task once, waits 30 seconds, runs it again and then exits. I can schedule this task with Scheduled Tasks in Windows to run every minute Write a Service that runs a task repeatedly while waiting 30 seconds in between each...

Should I use Powershell or CMD.exe for this?

What should I use to accomplish this task? CMD.exe? Powershell powerscript? Windows Script Host with VBScript or JScript? Task: transverse into every sub-folder of a folder if the subfolder has a folder name XXX, invoke certain commands ...

Passing paths to cmd using ProcessStartInfo not working as intended

Im using Process and ProcessStartInfo to launch a cmd window with the usual redirected output etc. However i'm tring to launch a command line executable with arguments, and even though the string is correct when i echo it to the cmd, when i run it without echo i get "'C:\Program' is not a recognized as an interal or external command" as ...

How can I suppress the “terminate batch job” in Win7 cmd.exe

As discussed in another question, it's possible to patch cmd.exe to suppress the "Terminate batch job (Y/N)?" message. Patching instructions are available for Windows XP. Unfortunately, these patching directions are out of date for Windows 7, and I don't know enough assembly to update them. (I do know how to use a hex editor, and was a...

How to send backspace using sendmessage(C#) to cmd.exe

I am trying to send keystrokes to cmd.exe that I launch from my app. In doing so, I am able to send all the keyboard characters, but if I try to send Backspace, it doesnt seem to take effect. The following is the code snippet to send message to cmd.exe: SendMessage((int)shell.MainWindowHandle, WM_KEYDOWN, ((int)e.KeyCode), 0); SendMessa...

Make form active after returning from cmd.exe in c#?

I have a c# win forms program and after I click a button it launches a windows application and then when I'm done, I want to close the app and return to my win form. When I close the launched app, my win form always seems to get pushed all the way to the back and I have to hunt for it. Any ideas? var process1 = new System.Diagnostic...

How to compile .sln with cmd.exe

I tried to compile a .sln at windows cmd.exe with the following code: C:\absolutePath\devenv.com /Build /ProjectConfig "Release|Win32" I get following error message: Missing switch argument. Configuration name required for /Build switch. However, this works: C:\absolutePath\devenv.com /Build Release /ProjectConfig "Release|Win3...

How do I exit the command shell after it invokes a Perl script?

If I run a Perl script from a command prompt (c:\windows\system32\cmd.exe), how can I exit the command prompt after the script finishes executing. I tried system("exit 0") inside the Perl script but that doesn't exit the cmd prompt shell from where the Perl script is running. I also tried exit; command in the Perl script, but that does...

Spurious 'system\cmd.exe' in FOR /F loops

Hi folk, This is one of those requirements that seem to get more complicated, every time I find a Windows/cmd shell hack that need a 'work around'. Essentially ... I need to iterate through a specific list of folders in a DOS Shell FOR loop. Here is the loop I came up with: echo ^ [start for test] for /F "usebackq " %%f IN (`dir...

System.Diaganostics.Process - (When one process internally uses another)

This is a bit involved, but please help. I'm starting to fall way behind due to this problem. God bless you for your attention to this. I've been using C# System.Diagnostics.Process to monitor the output of a command line utility. The process I'm monitoring "internally" launches a second process, and as soon as it does, I receive no f...

C#: Redirect Standard Output of a Process that is Already Running

I've been having a hard time getting the output of a "sub-process" (one launched internally by a blackbox process that I'm monitoring via c# System.Diagnostics.Process) I took the advice given by the answer of my previous post: here. And there you can find the details of what I've been going through. At this point, although I'm able to...

Help me MAKE C# Monitor (Output) and Feed (Input) to SSH.exe

I've found that the more I refine a question, the better help I get. So, to make the question as complete as possible, I'm providing this C# WPF solution created in Visual Studio 2010 Beta 2. This solution exactly reproduces the problem I'm having, as I try to capture output from ssh.exe using the System.Diagnostics.Process object. To...

How can I set the size of the cmd.exe window from my Perl program?

I have a Perl script running in windows, that displays to screen very long lines. I don't want to fix my console size permanently. I just want it to be big in case this script is running. Is there a way to define the console's size from within the Perl script that runs inside this window? ...

link a batch scrript (.bat file) to a different console/shell on Windows XP?

Hi All, Is there any way to link batch script (.bat files) so that they run via another shell/console and not cmd.exe ? For instance, if one install powershell or others (a few are open-source projects are available on soureceforge), how to link it to your bat files ? I looked in the "file types" menu but it seems that the bat extensi...

Perl directory change from Windows cmd.exe

According to the manual, chdir, Changes the working directory to EXPR, if possible. This script, when executed from cmd.exe: my $path = 'C:\\some\\path\\'; print "$path\n"; chdir("$path") or die "fail $!"; results in this output: C:\some\path\ but when I am returned to the command prompt - I'm still at the original directory. Am I...

While in CMD shell, copying files from host OS to guest VM locks files (VMware Player/Workstation)

We're running the latest versions of VMWare Player and Workstation for Windows. The following behavior is identical across both products. Problem: We open a CMD prompt in our guest OS (XP, Vista, Windows 7) and copy files from our host OS using the standard CMD shell copy command: copy z:\C$\testfiles The copy completes successfully,...