batch-file

top command first iteration always returns the same result

流过昼夜 提交于 2020-01-11 05:26:09
问题 When running top -b -n 1, the command always returns the same CPU values. Consider the following test run 5 times in succession: [user@server ~]$ top -b -n 5 -d.2 | grep "Cpu(s)" Cpu(s): 18.5%us, 10.0%sy, 0.0%ni, 67.0%id, 4.2%wa, 0.0%hi, 0.2%si, 0.1%st Cpu(s): 39.8%us, 27.7%sy, 0.0%ni, 31.3%id, 0.0%wa, 0.0%hi, 1.2%si, 0.0%st Cpu(s): 39.0%us, 35.4%sy, 0.0%ni, 23.2%id, 0.0%wa, 0.0%hi, 1.2%si, 1.2%st Cpu(s): 41.2%us, 34.1%sy, 0.0%ni, 15.3%id, 1.2%wa, 0.0%hi, 2.4%si, 5.9%st Cpu(s): 59.0%us, 30.1

How to create a Simple Build Script for Visual Studio from the Command Line?

那年仲夏 提交于 2020-01-11 05:13:10
问题 I have a lot of Visual Studio Project Solutions in multiple directories (all with the extension .sln) and I want to write a simple batch script that will automatically build all solutions listed in the batch file. I am able to manually build a solution by starting up the Visual Studio Command Prompt (which is just a command-line instance with the following command executed "%comspec%" /k "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 After which I then build the project

Batch - If, ElseIf, Else

ぃ、小莉子 提交于 2020-01-11 04:26:05
问题 Whats wrong with this code? IF "%language%" == "de" ( goto languageDE ) ELSE ( IF "%language%" == "en" ( goto languageEN ) ELSE ( echo Not found. ) I'm not really good in Batch.. 回答1: @echo off title Test echo Select a language. (de/en) set /p language= IF /i "%language%"=="de" goto languageDE IF /i "%language%"=="en" goto languageEN echo Not found. goto commonexit :languageDE echo German goto commonexit :languageEN echo English goto commonexit :commonexit pause The point is that batch simply

Unable to run R script through .bat files in Windows Server

北城余情 提交于 2020-01-11 04:08:16
问题 I'm trying to run a R script through a .bat file. When I run myself the commands line by line it works. But when I try to run the .bat file, it doesn't works. This is the .bat file cd "C:\Program Files\R\R-3.1.2\bin" R CMD BATCH "C:\Users\Administrator\Downloads\testa_vps.R" This is the R script setwd('C:\Users\Administrator\Documents') file.create('mycsv.csv') 回答1: I'm not an expert with Windows and generally try to stick to Unix-like systems for things like this, but I have found that using

Windows batch file to get C:\ drive total space and free space available

杀马特。学长 韩版系。学妹 提交于 2020-01-11 03:25:07
问题 I need a bat file to get C:\ drive total space and free space available in GB (giga bytes) in a Windows system and create a text file with the details. Note: i dont want to use any external utilities. 回答1: cut 9 digits of the size by bytes to get the size in GB: @echo off & setlocal ENABLEDELAYEDEXPANSION SET "volume=C:" FOR /f "tokens=1*delims=:" %%i IN ('fsutil volume diskfree %volume%') DO ( SET "diskfree=!disktotal!" SET "disktotal=!diskavail!" SET "diskavail=%%j" ) FOR /f "tokens=1,2" %

How to get a Part of the Directory path in a batch file

跟風遠走 提交于 2020-01-11 03:13:07
问题 I have a BAT file in a directory D:\dir1\dir2\getpath.bat when i run the bat with the below code it prints D:\dir1\dir2\ i want only the path D:\dir1\ The directory structure is not fixed , need the complete directory path other than the current directory in which BAT file resides. @echo off SET SUBDIR=%~dp0 ECHO %SUBDIR% tried using delims in a for loop but it didnt help. 回答1: If it's the parent directory of the directory your script resides in you want, then try this: @echo off SET batchdir

Extracting all lines from multiples files

喜夏-厌秋 提交于 2020-01-10 20:19:08
问题 I have 3 files: the first file is a list of IDs the second file is the source strings the third file is composed by target strings. Eg File 1 3952276-0-1 3952276-0-2 3952276-0-3 3952276-0-4 3952276-0-5 3952276-0-6 3952276-0-7 3952276-0-8 3952276-0-9 3952276-0-10 File 2 source-string1 source-string2 source-string3 source-string4 source-string5 source-string6 source-string7 source-string8 source-string9 source-string10 File 3 target-string1 target-string2 target-string3 target-string4 target

Extracting all lines from multiples files

爷,独闯天下 提交于 2020-01-10 20:19:05
问题 I have 3 files: the first file is a list of IDs the second file is the source strings the third file is composed by target strings. Eg File 1 3952276-0-1 3952276-0-2 3952276-0-3 3952276-0-4 3952276-0-5 3952276-0-6 3952276-0-7 3952276-0-8 3952276-0-9 3952276-0-10 File 2 source-string1 source-string2 source-string3 source-string4 source-string5 source-string6 source-string7 source-string8 source-string9 source-string10 File 3 target-string1 target-string2 target-string3 target-string4 target

Batch/CMD: Adding files to Startup list

半腔热情 提交于 2020-01-10 19:44:06
问题 How can a batch file lists itself in the startup list of Windows??? It doesn't matter if it goes from the registry or not. IF with the registry, please give also the command to DELETE the registry entry. This should work under all versions from ME to 7 please. Otherwise just XP/Vista/7. Thanks. 回答1: Not sure i understand you, but if what you want is an easy way to execute a command/batch on startup, why not just put it in the All Users\Startup folder? To do so programatically would just mean

Execute automatic change connected displays in Windows 8

本秂侑毒 提交于 2020-01-10 19:33:10
问题 Short version How do I automate changing multiple display settings? NVIDIA, 3x monitors (2x DVI and 1x HDMI), GPU only supports 2 active monitors. Long version So I have a NVIDIA GeForce GTX 560 Ti which can run two displays simultaneously. It has two DVI connections and one HDMI . I often swap from using my two desktop monitors and connect only one of the desktop monitors plus my TV using HDMI . I would like to automate the change back and forward using a batch script or other program