batch-file

How can I get batch files to run through the new Windows Terminal?

廉价感情. 提交于 2020-06-09 18:18:25
问题 I tend to have a lot of cmd prompts open at a time from running multiple batch files at once, so I figured the new Windows Terminal would be a neat way to tidy things up with tabs. Problem is, I can't quite figure out how to change the default behavior of running batch files through a cmd instance to the desired running batch files through a cmd instance that is inside of a Windows Terminal instance. I'm able to easily open Windows Terminal, start a cmd instance, cd to the correct dir, and

change directory in batch file using variable

喜夏-厌秋 提交于 2020-06-09 08:39:34
问题 Here's the question: set Pathname = C:\Program Files cd %Pathname% pause The above doesn't change the directory, as I would expect. Can anybody please tell me why? 回答1: The set statement doesn't treat spaces the way you expect; your variable is really named Pathname[space] and is equal to [space]C:\Program Files . Remove the spaces from both sides of the = sign, and put the value in double quotes: set Pathname="C:\Program Files" Also, if your command prompt is not open to C:\, then using cd

How can I execute a set of .SQL files from within SSMS?

梦想的初衷 提交于 2020-06-09 08:36:27
问题 How could I execute a set of .SQL files (each does some data transformations) from within SQL Server Management Studio? What other alternative are there for executing .SQL files in batch? 回答1: While SQLCMD.exe is the best way, SSMS also has a SQLCMD mode where you can execute a SQLCMD script. To enable this mode click Query in menu bar then select SQLCMD Mode . The ":r filename.sql" command is the SQLCMD script command to import and execute a sql script file. You know you are in SQLCMD mode

How can I execute a set of .SQL files from within SSMS?

丶灬走出姿态 提交于 2020-06-09 08:36:27
问题 How could I execute a set of .SQL files (each does some data transformations) from within SQL Server Management Studio? What other alternative are there for executing .SQL files in batch? 回答1: While SQLCMD.exe is the best way, SSMS also has a SQLCMD mode where you can execute a SQLCMD script. To enable this mode click Query in menu bar then select SQLCMD Mode . The ":r filename.sql" command is the SQLCMD script command to import and execute a sql script file. You know you are in SQLCMD mode

How to write a batch script to loop through logfiles in directory and generate a “filename.found” if i find the string “found” in the log file?

别来无恙 提交于 2020-06-09 05:31:25
问题 I have a directory "D:\logs" consisting of many log files eg: HRS.log, SRM.log, KRT.log, PSM.log etc. Each of this log file may or may not have a string "found" inside them. If the log file contains the string "found", then i have to generate "fileName.found" eg: "SRM.found" file in "D:\flags"folder. i have written the following script but not able to proceed further: @echo off setlocal ENABLEDELAYEDEXPANSION for %%f IN ("D:\logs\*.log") do ( findstr /i "found" "%%f" >NUL if "!ERRORLEVEL!"==

Python to .bat conversion

谁说我不能喝 提交于 2020-06-08 20:40:11
问题 I would like a user on Windows to be able to run my Python program, so I want to convert it to a .bat file. Is there a way to convert it? I've tried searching, but didn't find anything. 回答1: Unless your script is trivial it will not be possible to 'translate' it into a batch file. However two options exist: Create a batch file to run the python script Attempt to compile the script into an executable The first option is trivial. Simply create a batch file as so: @ECHO OFF PATH_TO_PYTHON\python

Can't enter a variable in DOS

a 夏天 提交于 2020-06-08 20:00:12
问题 I'm trying to run a batch file in vDOS (DOS emulator), where I want the user to input two variables. Every time I run the file, it doesn't let me enter the variables. SET /P in=Input: SET /P out=Output: What I expected to happen was that It'd let me enter the input for the variables. Instead, it executes both of the commands as they are (without letting me enter the input). 回答1: Windows cmd and MS-DOS are very different things and one of the differences is the set command. In MS-DOS the only

Why setlocal interferes with chdir in windows batch files?

孤街醉人 提交于 2020-06-08 16:50:10
问题 If I run the batch file setlocal chdir .. the directory is not changed, but if I run setlocal endlocal chdir .. it works normally. This must be exactly what is expected with setlocal. However, it is not entirely obvious when you read the definition of setlocal, which is related to how the environment variables are seen. I am hoping that this is a good occasion to explain what setlocal actually does and why it interferes with chdir. 回答1: The HELP documentation for SETLOCAL ( help setlocal or

Batch .txt processing with multiple columns [closed]

谁说胖子不能爱 提交于 2020-06-07 06:14:50
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 11 days ago . I have a little problem, I would like to edit data with the following batch script. @echo off set "txt=C:\Users\Desktop\test-batch\input.txt" set "temp=C:\Users\Desktop\test-batch\output.txt" for /f "tokens=1-43 delims=; " %%a in (%txt%) do echo %%a;%%ac;%%ad;%%ae;%%af;%%ag;%%ah;%%ai;%%aj;%%ak;%%al;%