cmd

Adding text to start of each new line in a .txt file

I would like to add a predefined text to each new line on a text file and create a new text file with the added text. Please help. ...

Reading values from file and assigning it to variable in batch script

Hello to all, I want to read the file which contains the value of some variables which are used in my batch script. I have created a property file with format key=key_value key=key_value Now, I want to set environment variable's name as key and its value as key_value How can I assign? I have read the file but cannot separate the st...

How to identify if sql server 2005 express is installed using cmd

How to identify if sql server 2005 express is installed using cmd ...

Preprocessor to add functionality to Windows's CMD?

I need to do a fair bit of scripting in my job as a SQL Server DBA. Sometimes, I need to deploy a fix script to a very restricted environment, where the only option for scripting may be DOS Batch. In one such environment, even VBScript/WSH isn't a possibility, let alone PowerShell. Anyone who has written enough batch files on DOS and Win...

how to hide cmd shell window ?

on start up i have a bat file run routine things for me however, the black console pops up and stays open until everything is finished.... anyway to hide it and run it in background ? so it shouldn't appear minimized or system tray. ...

How to run a python script without specifying the file extension (cross platform solution)?

Let's say that we have a Python script do.py and we want to be able to call it without extension, like do or ./do. If we rename the file from do.py to do and assure we have a valid shebang line it will work for all platforms but Windows. On Windows there is no way of executing file without extension. On Windows, if we keep the origina...

literal usage of % in batch

I have a batch file containing a python script using the Output template> %(NAME)s when I ran it, cmd thinks its a var and igoners the % so youtube-dl.py -b -o %(uploader)s-%(title)s-%(id)s.%(ext)s turns into youtube-dl.py -b -o (uploader)s-(title)s-(id)s.(ext)s how do i convince cmd to not process it and pass it as is to py...

osql -S not giving me expected results

I'm trying to write a program in Java that uses osql to generate a list of databases on a server. My code is as follows: public Object[] findDataBases(String server, String user, String passwd){ str = new String[] {"cmd.exe", "/c", "osql", " -S ", server, " -U", user, "&&", "-P ", passwd, ...

Interactive cmd.exe in Windows

Is it possible to create an interactive cmd under Windows? I am looking for a scripting solution to login to a server remotely which prompts password entering. Take SSH as an example. A normal user will do the following at a command line window: C:>ssh2 user@server.com "echo Hello" user's password: ******** Hello The second line, wh...

Escape string for Process.Start

How can I escape an unknown string for passing to Process.Start as an argument? I currently escape basic quotes and backslashes, but recently my input has started to contain things like http://www.fileformat.info/info/unicode/char/ff02/index.htm (Fullwidth quotation mark). So my question is, what all do I need to escape to safely pass ...

Batch Scripting Question - Search and Replace a Variable in a Variable?

Hello all! I have a problem. I have a batch file which imitates the UNIX cd command. It takes a UNIX-style path inputted by the user, saves it as a var called upath2, converts it to a Windows-style path, and cd's to that directory (e.g. "/program files/7-zip" will become "C:\Program Files\7-Zip"). The Windows-like output will be saved a...

[ODBC Driver Manager] Data source name not found and no default driver specified

I am trying to connect to list the servers on my network using osql.exe -L. Instead of a list of servers, however, I get the following error: [ODBC Driver Manager] Data source name not found and no default driver specified I'm not sure what's causing this problem - any pointers leading in the right direction will be helpful. Thanks so ...

how to use ssh from Windows cmd

How can I use ssh & scp from the Windows cmd.exe? I remember I installed a program in the past that let me do this but can't remember now what it was. (I don't mean putty) ...

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,...

Parenthesis in Windows cmd-script variable values not allowed?

Why gives the following Windows 7 .cmd command script: set SUN_JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_17 if 3==3 ( set JAVA_HOME=%SUN_JAVA_HOME% ) echo ready The following error message instead of printing "ready" \Java\jdk1.6.0_17 was unexpected at this time. The error message disapears, if I remove the "(x86)" in the pa...

Windows: how can I run something in a new command window in such a way that the window closes when the process finishes or crashes?

I have a script that is supposed to sit there, happily running in a command window, spewing out data... but I want the window to close automatically when the script finishes or crashes. The script is auto-restarted by other processes and I don't want my processing machines to become polluted with unused terminals. In a pinch, I have co...

cmd: Find updated folder and delete it using cmd

Hi all, Using CMD line, in a given directory, i want to detect the most recently created/written folder and delete all the contents of that folder... Any help/suggestions would be helpful... Thanq in advance.. Regards, chandra ...

redirecting output of a cmd to a file

we are trying to re-direct the output of the list to a file using the below cmd(java) in ubuntu, Pls let us know if this works or not ? Process p = Runtime.getRuntime().exec("ls -l >/home/blah blah/new.txt") ...

Commit all folders and files in a directory using commandline

Hello everybody We are having trouble with having a generalized approach to committing with a batch file using commandline svn. We've got a backupscript that created a new folder with the current date containing the database dumps of our database. (Yes, we version control our database). Now how can I use the svn commit command to incl...

easy way to see dos command return code

Sometimes I run a command in cmd such as: fc /b file1 file2 and would like to see the return code from fc. Is there a simple way to do this? ...