batch-file

Using a text file as input to a Powershell script

落花浮王杯 提交于 2020-02-14 21:06:12
问题 My group is moving to a new network where we can't directly copy from our computer in Network A to the new machine in Network B. After years on this machine in Network A, I've got project files interspersed all over the disk. I need to build a script to copy the folders and files to a backup disk. No problem there, but the network tech guy requires the total byte count to be known before copying. In CMD I've used dir /AD /S /B > C:\Users\r6540\Desktop\UserFiles.txt from C:\ to generate a huge

Using a text file as input to a Powershell script

前提是你 提交于 2020-02-14 21:05:09
问题 My group is moving to a new network where we can't directly copy from our computer in Network A to the new machine in Network B. After years on this machine in Network A, I've got project files interspersed all over the disk. I need to build a script to copy the folders and files to a backup disk. No problem there, but the network tech guy requires the total byte count to be known before copying. In CMD I've used dir /AD /S /B > C:\Users\r6540\Desktop\UserFiles.txt from C:\ to generate a huge

How to search and replace a string in environment variable PATH?

与世无争的帅哥 提交于 2020-02-09 04:41:49
问题 Is there any command in batch to search and replace a string in environment variable PATH ? For example the contents of environment variable PATH is: C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\AccuRev\bin;C:\Python24 I have to search for C:\Python24 in this variable and need to replace it by C:\Python27 . 回答1: Local PATH replacement The solution provided by wmz is perfect: set "PATH=%PATH:Python24=Python27%" For details

How do I echo and send console output to a file in a bat script?

孤街浪徒 提交于 2020-02-08 21:40:06
问题 I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well? For Example: c:\Windows>dir > windows-dir.txt Is there a way to have the output of dir display in the console window as well as put it into the text file? 回答1: No, you can't with pure redirection. But with some tricks (like tee.bat) you can. I try to explain the redirection a bit. You redirect one of the ten streams with > file or < file It is

How do I echo and send console output to a file in a bat script?

旧街凉风 提交于 2020-02-08 21:39:05
问题 I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well? For Example: c:\Windows>dir > windows-dir.txt Is there a way to have the output of dir display in the console window as well as put it into the text file? 回答1: No, you can't with pure redirection. But with some tricks (like tee.bat) you can. I try to explain the redirection a bit. You redirect one of the ten streams with > file or < file It is

Can I store the output of a command in a variable in batch scripting?

浪尽此生 提交于 2020-02-07 06:42:13
问题 I want to dir a folder and get in a variable all the names of the *.csv files. Does anyone know how can I do this? 回答1: Using Bash you can try: dirlist=`ls -1 *.csv` echo "$dirlist" Under windows you can read the following Q and A: Windows batch files: How to set a variable with the result of a command? Something like: for /f "delims=" %%a in ('dir') do @set foobar=%%a Change 'dir' to what you want. I have no windows machine close by, so cannot test. 回答2: I apologize for a duplicate response,

How do I pass a return code from an Oracle script back to the WINDOWS Batch script which called it?

我们两清 提交于 2020-02-07 02:37:12
问题 I'm running Windows 10-64 bit and Oracle 18.4 I have a Windows batch file (test1.bat) which calls a windows SQL script file. SQLPLUS -s (username)/(password) as sysdba @test1.sql Echo %errorlevel% I would then like to do some error checking on the %errorlevel% variable when I'm returned to Test1.bat from SQLPLUS. I'll create different processes depending on whether the return code is ORA-01940 (Cannot drop a user that is currently connected) or ORA-01918 (user 'MYUSER' does not exist), etc.

access denied using mkdir and rmdir in jenkins

喜欢而已 提交于 2020-02-07 02:36:14
问题 Jenkins is generating a build of a C++ project made in Visual Studio. During the process, some .bat s are called and in one of them, there is a structure like this: SET TEMPDIR=Temp rmdir %TEMPDIR% /S /Q echo Don't continue if there was an error above (except the not found error which is ok) and go hand delete the dir! :pause mkdir %TEMPDIR% I'm not very familiar to batch scripting, but when both rmdir and mkdir are called, Jenkins gives me access denied . I looked in the build configurations

Batch write text from file into local variable error [closed]

寵の児 提交于 2020-02-07 01:59:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 days ago . My scenario is the following: I have a huge file with 700.000+ lines. I have to work with this, I name this file now trc.txt The structure of each line of this file is like so: 20958 191014 07:43:57.08 CCComRPC DCMSGCFW_E PID:00000864.00001F40 Data:23 < PREP_FIXED::Process 0 I have a seconde file, I call it

Windows cmd simulate console input a command

删除回忆录丶 提交于 2020-02-06 07:56:16
问题 I need to write a batch script which connects to a vpn automatically when username and password is saved somewhere (Ex: in a file). VPN client is openconnect which provides a CLI but the problem is user input needs to be provided interactively to the command in order for it to complete. See the output below when I run : openconnect <serverhostname> OUTPUT POST https://<serverhostname>/ Connected to <serverhostname>:443 SSL negotiation with <serverhostname> Server certificate verify failed: