cmd

System.Diagnostics.Process - Del Command

I'm trying to start the del command using System.Diagnostic.Process. Basically I want to delete everything from the C:\ drive that has the filename of *.bat System.Diagnostics.Process proc = new System.Diagnostics.Process(); string args = string.Empty; args += "*.bat"; proc.StartInfo.FileName = "del"; proc.StartInfo.WorkingDirectory =...

What is the proper way to test is variable is empty in a batch file, If NOT "%1" == "" GOTO SomeLabel, fails if %1 has quotes.

I need to test if a variable is set or not. I've tried several techniques but they seem to fail whenever %1 is surrounded by quotes such as the case when %1 = "c:\some path with spaces". IF NOT %1 GOTO MyLabel // This is invalid syntax IF "%1" == "" GOTO MyLabel // Works unless %1 has double quotes which fatally kills bat execution IF ...

Cant run application (C#) through cmd

Hey, I can't execute my application through cmd, when the application is trying to read the argument which was sent to it (text file), it fails... When I'm trying to execute it through the IDE (vs2008), it works ok... That's what I did in the main method: static void Main(string[] args) { int choice = 0; if (args.Length == 0...

How do I execute a cmd in C#, then in the same window execute another command that follows?

Hey Guys, Right what im trying to accomplish is a program that basically sets the active partition in 1 click, saving the effort time and skill of using cmd prompt etc. I have looked into the System.Management name space but couldn't work out how to use it :( So i have resorted to using CMD, i have got a module application written in...

Replacing "," with a "." in cmd on all files in a directory

The title pretty much says it all. What would be the easiest way to replace commas in all files it can find in the current directory with dots? (preferably, without installing some extra tools, but I'll settle for something small .... cygwin's not small :) ...

How do I launch a WPF app from command.com. I'm getting a FontCache error.

I know this is not ideal, but my constraint is that I have a legacy application written in Clipper. I want to launch a new, WinForms/WPF application from inside the application (to ease transition). This legacy application written in Clipper launches using: SwpRunCmd("C:\MyApp\MyBat.bat",0) The batch file contains something like thi...

Windows Batch Scripting Issue - Quoting Variables containing spaces

So here's my issue: I want to use %cd% so a user can execute a script anywhere they want to place it, but if %cd% contains spaces, then it will fail (regardless of quotes). If I hardcode the path, it will function with quotes, but if it is a variable, it will fail. Fails: (if %cd% contains spaces) "%cd%\Testing.bat" Works: "C:\Program...

Why does findstr not handle case properly (in some circumstances)?

While writing some recent scripts in cmd.exe, I had a need to use findstr with regular expressions - customer required standard cmd.exe commands (no GnuWin32 nor Cygwin nor VBS nor Powershell). I just wanted to know if a variable contained any upper-case characters and attempted to use: > set myvar=abc > echo %myvar%|findstr /r "[A-Z]"...

Android: failing in cmd when locating debug.keystore, what is the problem!?

Hi there, I'm trying to generate the MD5 fingerprint from the debug.keystore file using keytool.exe in my jdk so I can use google maps in my android project. I've located the keystore file and have moved it into C:\android just to make things easier. Then in command I type c:\Program Files\Java\jdk1.5.0_13\bin>keytool -list -alias and...

How can we stop a running java process through windows cmd?

I am a newbie in cmd, so please allow me to ask a stupid question: How can we stop a running java process through windows cmd? For example, if we start jetty(a mini web server) with the following cmd: start javaw -jar start.jar How do we find the process and stop it later? Obviously the following cmd does not work: stop javaw -jar ...

Batch commands execution order

I'm looking to run a second batch command from .bat but after the first command has been done. REN "myfile.txt" "my_file.txt" start "title" "path" Here, I want the rename command to be executed before the process I wanted to start that has been terminated or executed. why it doesn't work in sequence order? Update: Both commands work...

Making Swedish characters show properly in Windows Command Prompt using Python in Notepad++

The title explains it well. I have set up Notepad++ to open the Python script in the command prompt when I press F8 but all Swedish characters looks messed up when opening in CMD but perfectly fine in e.g IDLE. This simple example code: #!/usr/bin/env python #-*- coding: UTF-8 -*- print "åäö" Looks like this. As you can see the outp...

How to find cmd.exe process id from which app is started?

I have simple win application(writen using .net C#) that needs to be started from cmd.exe, and then write to that console, but problem is that i need process id from that cmd.exe process. I can get all running process, Process[] procList = Process.GetProcessesByName("cmd"); but how to find my? :) Maybe to read input, and check is "Ap...

How to call System commands from a java program

I want to use system commands like mkdir and remdir running a java program. How can I do that? ...

How to handle carriage return with windows batch script?

Hi, I want to use bat to automate some of my work. It should first look up the value of a certain registry key, and then copy some files to the directory that included in the registry key value. I used reg query command to look up registry, such as: REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROCE...

How do I understand the 3 lines batch script?

ECHO @ECHO OFF ^& (IF EXIST "%%~dp0%~n1.swf" (DEL "%%~dp0%~n1.swf")) ^& %mxmlcPath% %opts% -file-specs "%%~dp0%~nx1" ^& (IF EXIST "%%~dp0%~n1.swf" (CALL "%%~dp0%~n1.swf") ELSE (PAUSE)) > "%~dpn1.bat" REM Immediately execute the generated bat @ECHO on CALL "%~dpn1.bat" It's really a mess for me(like ECHO @ECHO OFF,what's that intended f...

C equivalent to Perl "system()" or Python subprocess

How do I execute another program from within a C program in Windows 32 - in a similar way as Perl's system() function or Python's sub-process module - such as DEL, REG, or other cmd.exe programs? ...

How can I pass more than one command line argument via c#

I need to pass more than one command line argument via c# for a process called handle.exe: http://www.google.com.mt/search?sourceid=chrome&ie=UTF-8&q=handle.exe First, I need to run the executable file via ADMINISTRATOR permissions. This post has helped me achieve just that: http://stackoverflow.com/questions/667381/programatic...

Oracle SQL CMD Line

Whenever I perform select statements in the command line tool it doesn't use all of the space. I've modified buffer size and window size and it just doesn't work. Here is the screenshot: ...

In Windows shell scripting (cmd.exe) how do you assign the stdout of a program to an environment variable?

In UNIX you can assign the output of a script to an environment variable using the technique explained here - but what is the Windows equivalent? I have a python utility which is intended to correct an environment variable. This script simply writes a sequence of chars to stdout. For the purposes of this question, the fact that my utili...