cmd

batch script print the command that would be executed rather than executing

你说的曾经没有我的故事 提交于 2020-01-05 08:51:37
问题 Is it possible to set a cmd.exe shell / batch file to print what would be executed but not actually execute it? For example, given a batch file that takes some arguments, based on those arguments selects some other batch files to run, those batch files execute some commands, may or may not call other files/commands etc. I would like to be able to run the top level batch file with all possible combinations of it's input arguments and capture what each arg combination would execute - without

using cmd's Start command to run exe. Works locally, but not remotely

孤人 提交于 2020-01-05 08:22:44
问题 Some background: We are trying to automate installation of an agent on servers. The automated workflow will check for servers that need this install. If so, the workflow copies the necessary install files as well as a .cmd batch file. When calling this .cmd script locally, the install works fine. But when trying to call this script remotely from the workflow server, it hangs on a certain line in the batch. Snippet from the script se_install.cmd: echo Installing SE 9.4 Agent start "" /wait

Renaming files with spaces and dots in the filename

折月煮酒 提交于 2020-01-05 08:01:02
问题 I'm making a simple *bat file with drag/drop ability for replacing white spaces( ) and dots(.) for underscores(_). I think this should work, but it doesn't: @ECHO OFF setlocal enabledelayedexpansion FOR %%f IN (%*) DO ( set filename=%%~nj set filename=!filename:.=_! set filename=!filename: =_! if not "!filename!"=="%%~nf" RENAME "%%f" "!filename!%%~xf" ) Do you know what is going on? 回答1: try this: @ECHO OFF &setlocal FOR %%f IN (%*) DO ( set "oldname=%%~ff" set "oldfname=%%~nf" set

Renaming files with spaces and dots in the filename

拥有回忆 提交于 2020-01-05 07:59:08
问题 I'm making a simple *bat file with drag/drop ability for replacing white spaces( ) and dots(.) for underscores(_). I think this should work, but it doesn't: @ECHO OFF setlocal enabledelayedexpansion FOR %%f IN (%*) DO ( set filename=%%~nj set filename=!filename:.=_! set filename=!filename: =_! if not "!filename!"=="%%~nf" RENAME "%%f" "!filename!%%~xf" ) Do you know what is going on? 回答1: try this: @ECHO OFF &setlocal FOR %%f IN (%*) DO ( set "oldname=%%~ff" set "oldfname=%%~nf" set

How to execute cmd command in Java class?

久未见 提交于 2020-01-05 07:17:27
问题 I want to call cmd command in java code. I say: String str ="C:/uploaded_files/111.txt"; Process process = Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c",str}); System.out.println(str); And dont get 111.txt . Its strange because when this code was in jsp all works fine. What can be wrong? 回答1: what's the problem with this code. It's perfectly working. opens and shows content of the file 111.txt try { String str ="C:/uploaded_files/111.txt"; Process process = Runtime.getRuntime().exec

In vbscript, how do I run a batch file or command, with the environment of the current cmd prompt window?

天涯浪子 提交于 2020-01-05 07:11:48
问题 In vbscript, how do I run a batch file or command, in the current cmd prompt window, without starting a new process. For example. According to script56.chm (the vbscript help apparently) Windows Script Host Run Method (Windows Script Host) "Runs a program in a new process" So if I have code that uses that e.g. a VBS file, and a BAT file. An environment variable g has the value abc g=abc from that command window, The VBS file calls the BAT file with windows scripting host Run. The bat process

Setting an environment variable

社会主义新天地 提交于 2020-01-05 07:09:10
问题 I am using xp. I am facing problem in using Variables. I am using following code @echo off set var = "srting" When i check the value of var using % set %var% Environment variable %var% not defined Anyone help ... 回答1: If you want to execute different code path based on file content, this should work for you: @echo off set FILE_CONTENT=string for /f %%a in (file.txt) do set var=%%a if %var%==%FILE_CONTENT% ( goto MATCHED ) else ( goto NOT_MATCHED ) :MATCHED echo "matched" goto:EOF :NOT_MATCHED

change to directory after searching for the file via DIR

為{幸葍}努か 提交于 2020-01-05 06:45:26
问题 Outcome is to change to directory after searching for the file via DIR through cmd Location of file is C:\Folder is the following code possible? set /a variable= dir document.doc /s /p cd %%variable%% Change directory to C:\Folder 回答1: try this: for /f "delims=" %%# in ('dir document.doc /s /b') do ( set "new_dir=%%~dp#" ) cd /d "%new_dir%" 回答2: Run in a command prompt window set /? and read the output help carefully from first to last page. set /A is for evaluating an arithmetic expression .

Batch rename file using for loop

让人想犯罪 __ 提交于 2020-01-05 06:44:05
问题 I am trying to use a for loop to rename a file ::@Echo Off setlocal enableDelayedExpansion ::Set Date set mydate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2% ::Rename file for %%F in (D:\Data\*.bak) do ( ren %%F D:\Data\prod_live_Full_%mydate%0000.Lts.bak ) I keep getting invalid command error. Any help is appreciated. 回答1: When modifying files in a directory use a static file list from dir instead of a dynamic file list from for . Otherwise, you will get stuck in an infinite loop. @echo Off setlocal

gradle windows java.io.IOException: CreateProcess error=206, filename is too long

大城市里の小女人 提交于 2020-01-05 06:38:58
问题 A couple of solutions to the problem of the windows path being too long are present for gradle: Add classpath in manifest using Gradle "The filename or extension is too long error" using gradle However, it is unclear to me how to handle this in a multi project setup. Would all sub-projects with the application plugin require these changes? Could this also be specified in the init.gradle file? Also is there a better workaround? Apparently https://github.com/viswaramamoorthy/gradle-util-plugins