cmd

Windows console width in environment variable

爱⌒轻易说出口 提交于 2020-01-27 08:17:27
问题 How can I get the current width of the windows console in an environment variable within a batch file? 回答1: I like the approach using the built-in mode command in Windows. Try the following batch-file: @echo off for /F "usebackq tokens=2* delims=: " %%W in (`mode con ^| findstr Columns`) do set CONSOLE_WIDTH=%%W echo Console is %CONSOLE_WIDTH% characters wide Note that this will return the size of the console buffer, and not the size of the window (which is scrollable). If you wanted the

Python file opens and immediately closes

喜夏-厌秋 提交于 2020-01-26 04:34:46
问题 Tried running this code first through powershell and then through cmd and even simply clicking it. I am typing "start python myfile.py" to run it. In each case, the file blinks on screen and immediately closes. The only way I can view it is to drag the file directly into cmd, in which case it looks perfect. I am doing the first exercise from "Learn Python the Hard Way". I'm doing everything to the letter as in the book, with one exception. See below*. I've read and re-read it. I don't think

Unable to install service using sc command

心不动则不痛 提交于 2020-01-26 03:33:49
问题 I have my service under this folder path C:\Users\Documents\Visual Studio 2012\TestServices\TestServices\InboundMessage.ServiceHost\bin\Debug --- > here is were all my dlls and .exe is I use this command to install to my local box sc create "Receiver Services" binPath= "C:\Users\Documents\Visual Studio 2012\TestServices\TestServices\InboundMessage.ServiceHost\InboundMessage.ServiceHost.exe" displayname= "*Receiver Services" sc description "Receiver Services" "Receiver Services." sc delete

how do I execute cmd.exe process only once and in foreach pass commandText?

扶醉桌前 提交于 2020-01-25 20:57:28
问题 I want to execute process of cmd.exe only once outside foreach and inside foreach want to send parameters to this process. I am currently doing this: var msbuildPath = (string) regKey.GetValue("MSBuildToolsPath"); foreach (var item in listBox1.Items) { var FilePath = item.ToString(); var startInfo = new ProcessStartInfo() { WindowStyle = ProcessWindowStyle.Hidden, Arguments = String.Format("\"{0}\" /nologo ", FilePath), FileName = Path.Combine(msbuildPath, "msbuild.exe") }; var proc = Process

cmd insert text into the middle of the file name

萝らか妹 提交于 2020-01-25 15:52:29
问题 I am moving files from one directory to a newly created directory. Currently the script inserts the id variable to the start of the file name for all the file names. I would like to insert the id variable after model name variable in all the file names. How do I do that? I have the following code in my cmd file. @echo off rem set 12d variables set modelname=dr network_ set id=10yr_ mkdir "%modelname%" rem move to new dir created move "%modelname%*.rpt" "%modelname%" rem change working

How to run multiple lines in cmd as administrator using C#?

大城市里の小女人 提交于 2020-01-25 13:12:08
问题 Is there a work around or a function that lets me run multiple commands in one elevated command prompt? I tried setting UseShellExecute=false and use StreamWriter, but I read that if I do that, I can't use an elevated command prompt. If I set UseShellExecute=true, I can use the elevate cmd but I need to use process.Argument() which only lets me run one command in one cmd process at a time. I have a loop that runs one command at a time in different cmd process and it works. But it just gets

Sort file name with delimiter in batch file

一曲冷凌霜 提交于 2020-01-25 13:05:48
问题 I need to sort the list of file names by their version number with least first, in windows batch script. The file names are like: 2_0_0to2_0_1 2_0_1_to2_0_2 ... 2_0_12_to2_0_13 ... I've tried dir and sort in Windows but it seems to only look at char positions which wouldn't work in the case of double digits. In Linux, I've done this with: ls *.txt | sort -n -t _ -k1 -k2 -k3. How to do this on Windows. Please help. Thanks! 回答1: Try this: @ECHO OFF &SETLOCAL ENABLEDELAYEDEXPANSION FOR %%x IN (*

I cant install a Specific version of Symfony using Composer

隐身守侯 提交于 2020-01-25 10:13:36
问题 I want to install Symfony 4.0.6 version! using composer with cmd when I write composer create-project Symfony/framework-standard-edition Stage_App "4.0.*" also tried composer create-project Symfony/skeleton Stage_App "4.0.*" and both install Symfony 5.0.2 note: I don't want to work with the last version! i just want to work with 4.0.6 how can I install that version? 回答1: since the 4.0.* of symfony version is deprecated, the symfony/skeleton creates a project on the 5.0 version. Since 4.4.*

How to copy only files(not directories) using batch file?

一世执手 提交于 2020-01-25 06:32:30
问题 The directory structure is: Images -Folder1 -image1.jpg -image2.jpg -Folder2 -image3.jpg -image4.png -Folder3 -image6.png -image7.jpg -Folder4 I want to copy all images(i.e *.jpg, *.png) files only (not the folders) into the parent directory("Images"). I have tried using "robocopy" as follows: robocopy /np ..\..\Exam\Images ..\..\Exam\Images *.jpg *.png /S Here all files as well as folders are copied :(. But I need only files to be copied. How to do this? Many many thanks in advance! 回答1: Try

How to add TXT file to the WAR archive using command-line in MS Windows

这一生的挚爱 提交于 2020-01-24 23:47:32
问题 I have key.txt file in E:/ drive and app.war file in C:/ drive. How to copy key.txt to the subfolder of the app.war file i.e WebContent/WEB-INF. Key should copy to the WEB-INF folder. I want result like(after unzipping war file) WebContent | |->META-INF |->WEB-INF | |->key.txt 回答1: Finally i got answer, for this i used. mkdir c:/WEB-INF cd WEB-INF xcopy D:/key.txt C:/WEB-INF jar uvf app.war /WEB-INF/key.txt No need of unzipping and again zipping. 回答2: You can use the jar command to extract