cmd

How to remove newlines from a text file with batch or PowerShell

左心房为你撑大大i 提交于 2020-01-24 07:49:14
问题 Essentially, I want to read from file.txt with contents apple banana carrot and write to newfile.txt so that it will have contents apple banana carrot I need to do this on a Windows computer on which I do not have install permissions. I tried set row= for /f %%x in (file.txt) do set row=%row% %%x echo row > newfile.txt and I tried using PowerShell statements (I cannot run PowerShell scripts) instead of the CMD-style for loop. powershell -Command "(Gc file.txt) | Foreach-Object -Process {set

Why clearfsimport command adds file to source control with a size zero?

非 Y 不嫁゛ 提交于 2020-01-23 18:00:38
问题 I use clearfsimport command the file is added to source control but: the file size becomes zero and keep files are created. In the version tree of ClearCase, the version number of that file is zero. How can I fix this in order for the clearfsimport to work properly? 回答1: You need to make sure, when using clearfsimport (as in "How can I use ClearCase to “add to source control …” recursively?") that your source is different from your destination clearfsimport -preview -rec -nset c:\sourceDir\*

How to check if current drive is on a local disk (cmd)?

醉酒当歌 提交于 2020-01-23 11:49:09
问题 To get the drive the current batch resides in is easy using set batchdrive=%~d0 But how is it possible to check if %batchdrive% is on a local drive and not on a (mapped) network share? Checking for %SYSTEMDRIVE% or a fixed list "C:" "D:" ... is not reliable. 回答1: To check whether a drive ( %~d0 ) is a local one, you could use a wmic query: wmic LogicalDisk where(DeviceID="%~d0" AND DriveType=3) get Description,DeviceID,DriveType Given that %~d0 expands to the local drive C: , the output looks

Is it possible to output the current color code on the command prompt using batch programming?

好久不见. 提交于 2020-01-23 09:25:56
问题 I am making a tutorial program for a friend of mine using batching programming. I would like to know if it is possible if there is code I can write in the file that will display the current color code. Example being the color is currently set to 0A and I want be displayed on the line saying: echo The color is currently set to 0A . I want my file to read the code that is set to and display it to help them remember what changes they have made as this is an example program for color codes in the

Create/run command file programmatically

情到浓时终转凉″ 提交于 2020-01-23 08:33:15
问题 I'm trying to create a cmd file that will install a .msi and then execute that cmd file via C# code. The code works perfectly if I run it using f5 or control + f5 from visual studio. However, once I package up the code in a .msi file and install it (it's a wpf app), when it executes the relevant code, it opens the command window but it doesn't execute the command. Instead it says: "C:\Program is not recognized as an internal or external command..." I know this error means that there aren't

Zip command without including the compressed dir itself

ⅰ亾dé卋堺 提交于 2020-01-23 07:22:34
问题 Suppose the structure: /foo/bar/ --file1 --file2 --file3 --folder1 --file4 --folder2 --file5 I want to run the unix zip utility, compressing the bar folder and all of it's files and subfolders, from foo folder, but not have the bar folder inside the zip, using only command line. If I try to use the -j argument, it doesn't create the bar folder inside the zip as I want, but doesn't create folder1 and folder2 . Doing -rj doesn't work. (I know I can enter inside bar and do zip -r bar.zip . I

Convert Text to Table (Space Delimited or Fixed length)

╄→尐↘猪︶ㄣ 提交于 2020-01-23 04:10:32
问题 I have a text file with tab delimited data (150 lines) that i want to convert to space delimited or fixed length columns. I have tried to export the file using Excel's .prn format but when opened in MS Notepad it loses all formatting. Let us consider the file as: Product Name Product Key Autodesk 3ds Max 2019 128K1 Autodesk 3ds Max 2019 with Softimage 978K1 Autodesk Advance Steel 2019 959K1 Autodesk Alias AutoStudio 2019 966K1 Autodesk Alias Concept 2019 A63K1 Autodesk Alias Design 2019 712K1

Best way to set date and time on windows machine by java application

徘徊边缘 提交于 2020-01-23 03:14:45
问题 I'm working with an agent java application and it is installed on several Windows machines in different places of the world. I would like periodically synchronize windows clock (Date and Time). I have already found the native command to set time in windows by java code: Runtime.getRuntime().exec("cmd /C date " + strDateToSet); // dd-MM-yy Runtime.getRuntime().exec("cmd /C time " + strTimeToSet); // hh:mm:ss or to execute Runtime.getRuntime().exec("cmd /C date " + strDateToSet + "& time " +

How to detect if input is quote?

♀尐吖头ヾ 提交于 2020-01-23 02:03:30
问题 I have the following code if "%userInput%"==""" ( do_something ) I would like it to detect if the %userInput% is a quote( " ). However, this code throws an error. How to detect if input is a quote? 回答1: Here is a solution without delayed expansion that should work with any input, including spaces and poison characters. My test code is in a loop. When you are ready to quit, simply press <Enter> without typing anything. @echo off setlocal :loop set "var=" set /p "var=enter a string: " if not

enable Win10 inbuild hotspot by cmd/batch/powershell

怎甘沉沦 提交于 2020-01-22 12:43:11
问题 as the title says I search for a way to enable/disable the Hotspot inbuild in Win10 via the command prompt/powershell/a batch file. In the GUI it can be easily done with the third button in the network panel (see image below), but I want to automate it. I already found some hundred tutorials how to create a new hotspot via netsh, but as I understand it this would create another, different hotspot. Instead I want to use the already configured one. Or does Win10 the same and everytime creates a