cmd

What is the windows equivalent of Linux command wc -l?

人走茶凉 提交于 2020-01-21 15:02:06
问题 I have a piece of code that is meant to send the following to the linux command line: wc -l C:/inputdirectory/P* However, I need to run this script in Windows, and am trying to find the equivalent command. I have tried find /c /v C:/inputdirectory/P* But this throws an error, that /v is not a valid command. Can you please tell me why this isn't working? *note, the command itself doesn't say "inputdirectory", it has the correct directory, it's just too tedious and private to type out 回答1: How

How to get the output of “wmic process call create”

我是研究僧i 提交于 2020-01-21 12:47:29
问题 I'm trying to get the output of wmic process call create so I can get the ProcessId of the newly created process. If I just run: wmic process call create "notepad.exe a.txt","d:\" It works just fine (it opens the file a.txt under folder d:\ with notepad ). Now, if I try: for /f "usebackq delims==; tokens=1,2" %i in (`wmic process call create "notepad.exe a.txt","d:\"^|findstr ProcessId`) do @echo pid = %j It doesn't, and shows me the error: Formato incorrecto. Sugerencia: <lista_parámetros> =

run two commands in one windows cmd line, one command is SET command

不羁岁月 提交于 2020-01-21 03:16:09
问题 [purpose] This simple command sequence runs expected in the Windows' CMD shell: dir & echo hello will list the files and directories and echo the string. However, the following command sequence does not run as expected (at least by me): C:\Users\Administrator>set name=value & echo %name% %name% C:\Users\Administrator>echo %name% value C:\Users\Administrator> As we can see, the first echo cannot get the environment. Could you help to comment? Any comment will be appreciated! PS: OS:Windows 7

How to decode cmd output correctly?

空扰寡人 提交于 2020-01-21 03:03:25
问题 ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe"); startInfo.Arguments = "/c " + URL; Process p = new Process(); startInfo.RedirectStandardInput = true; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.CreateNoWindow = true; p = Process.Start(startInfo); string original = p.StandardOutput.ReadToEnd(); string result1 = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(original)); string result2 = Encoding

single line for statement: %%i 'unexpected at this time'

寵の児 提交于 2020-01-20 17:15:38
问题 for /r %%i in (*) do (echo %%i) Results in %%i was unexpected at this time Why? 回答1: You must be trying to run the command from the command line and not from within a batch file. Use a single % instead of two when running from the command line. for /r %i in (*) do (echo %i) Type HELP FOR from the command line and read the 3rd paragraph. 回答2: Syntax: FOR /R [[drive:]path] %%parameter IN (set) DO command Need the path before %%i... which is why it's Unexpected If you want to do * for current

Change output of pause command in batch script

二次信任 提交于 2020-01-20 17:14:28
问题 I'm writing a Windows batch script. By default, the pause command will pause the script and display the text "Press any key to continue..." . How do I modify this text to display my own text to the user? Thanks. :) 回答1: You could hide the text from the pause command by using this: pause >nul Then you could echo your own message to tell the user it has paused: echo The batch file has paused So the full script might look like this: @echo off echo Hello World! echo The batch file has paused

Change output of pause command in batch script

点点圈 提交于 2020-01-20 17:11:57
问题 I'm writing a Windows batch script. By default, the pause command will pause the script and display the text "Press any key to continue..." . How do I modify this text to display my own text to the user? Thanks. :) 回答1: You could hide the text from the pause command by using this: pause >nul Then you could echo your own message to tell the user it has paused: echo The batch file has paused So the full script might look like this: @echo off echo Hello World! echo The batch file has paused

How to input a string from user into environment variable from batch file

荒凉一梦 提交于 2020-01-20 00:30:16
问题 I want to prompt the user for some input detail, and then use it later as a command line argument. 回答1: You can use set with the /p argument: SET /P variable=[promptString] The /P switch allows you to set the value of a variable to a line of input entered by the user. Displays the specified promptString before reading the line of input. The promptString can be empty. So, simply use something like set /p Input=Enter some text: Later you can use that variable as argument to a command: myCommand

How to run Java when C drive is not the default in CMD prompt? [closed]

二次信任 提交于 2020-01-17 16:35:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am facing following scenario: Win XP Machine, 2003 SP, jre7 No admin rights to even set class path via my computer properties CMD prompt shows a local drive as user drive instead of C Thus unable to execute following command:- c:\program files\Java\jre7\bin It says C:\program files isn't recognized as an

Excluding a directory in for loop's search

风格不统一 提交于 2020-01-17 10:17:13
问题 I have the following line of code: FOR /R D:\1_FOLDER %f IN (*.jpg,*.png) DO XCOPY %f D:\2_FOLDER /H /C The first problem what i have, the command doesn't run, i get the error Invalid numbers of parametres The second problem in directory 1_FOLDER i have 2 more folders X_FOLDER and Y_FOLDER, i want the for loop to search only in X_FOLDER, and copy only files of the X_FOLDER. I have the second problem same when i want to copy from C:\ , i want to exclude the Windows folder from for loop's