batch-file

BATCH Script - Create a folder with a specific part of the filename

自古美人都是妖i 提交于 2020-06-29 04:12:11
问题 I need help from you guys, I have been writing a script in Batch where I need to create a folder by using a part of the name of the file. I need to have for example : for this file : 20200614_SAP_ZCMF_MB51_V1.csv I only need for the name of the folder SAP_ZCMF_MB51. I need to delete the date and the version from the name of the folder. Here is the code that allows me to create a folder : @echo off setlocal enabledelayedexpansion for %%A in (*.csv) do ( echo file found %%A for /f "delims=" %%B

Delete all files in a folder but skip files that cointain certain string

江枫思渺然 提交于 2020-06-29 03:46:46
问题 I'm trying to clean the temp files, but I want skip some files that cointain a certain name. No matter the extension it is. Tried this way: @echo off setlocal EnableDelayedExpansion for /f "eol=: delims=" %F in ('dir "%windir%/temp" /b /a-d * ') do find "TESTE" %F > nul || del "%F" pause Wanted all files that cointains TESTE in name got skipped from deletation. But my script not even run. Can someone explain me what is wrong? 回答1: It is not absolutely clear whether you want to exclude files

Executing commands one with a loop with cmd

跟風遠走 提交于 2020-06-29 03:45:50
问题 I want to create a batch file that both executes a command once, and do a loop at the same time. When the loop occurs again, the command won't be executed anymore. Here is the code for the loop: @echo off setlocal EnableDelayedExpansion for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a" FOR /L %%n in (1,1,10) DO ( call :spinner ping localhost -n 2 > nul ) exit /b :spinner set /a "spinner=(spinner + 1) %% 4" set "spinChars=\|/-" <nul set /p ".=Rebuilding, please wait... !spinChars:~

How do I pass parameters to a running batch program by another one

我怕爱的太早我们不能终老 提交于 2020-06-29 03:39:28
问题 example: foo.bat : @echo off start bar.bat 2 3 set result=//somehow return the value echo %result% pause exit bar.bat : @echo off set int1=%1 set int2=%2 set /a result=%int1%+%int2% //somehow send the result to the running foo.bat exit can someone give me an idea on how to do this. I can only think about writing a file and checking in a for loop if the file exists and what it contains. But this is way complicated in my opinion. Thanks in advance. 回答1: The batch file foo.bat must be written as

Getting “Invalid Procedure Call Argument” When i run call a Bat file from Subroutine

﹥>﹥吖頭↗ 提交于 2020-06-28 05:09:12
问题 Find the below code: Sub Button1_Click() argh = Shell("C:\Users\YYYY\Desktop\test1.bat", vbNormalNoFocus) End Sub When I run call a Bat file from Subroutine, I always get below error. Attached screen shot as well. "Run time Error" "Invalid Procedure call or argument" 回答1: We cannot run a .bat file from Excel macro , It will always ask for the Administrator permissions. Better Create a .vbs file and call the .bat file from .vbs file. .vbs file : Save the file as runbatch.vbs Set objShell =

Getting “Invalid Procedure Call Argument” When i run call a Bat file from Subroutine

不问归期 提交于 2020-06-28 05:09:10
问题 Find the below code: Sub Button1_Click() argh = Shell("C:\Users\YYYY\Desktop\test1.bat", vbNormalNoFocus) End Sub When I run call a Bat file from Subroutine, I always get below error. Attached screen shot as well. "Run time Error" "Invalid Procedure call or argument" 回答1: We cannot run a .bat file from Excel macro , It will always ask for the Administrator permissions. Better Create a .vbs file and call the .bat file from .vbs file. .vbs file : Save the file as runbatch.vbs Set objShell =

How to ignore first and third data column on sorting and summing the text using batch file?

孤人 提交于 2020-06-28 04:54:10
问题 I have made this script below: start /w "" "C:\Program Files (x86)\CoolUtils\Total PDF Converter\PDFConverter.exe" "%userprofile%\Desktop\teste.oxps" "%userprofile%\Desktop\teste.txt" del /f /s /q "%userprofile%\Desktop\teste.pdf" findstr /v /r /c:"http" /c:"Banrisul" /c:"Sac" /c:":" /c:"-" /c:"SAC" /c:"OUVIDORIA" /c:"B A N R I S U L" /c:"+" "teste.txt" > "output.txt" for /f "usebackq tokens=* delims=" %%a in ("output.txt") do (echo(%%a)>>output2.txt move /y output2.txt output.txt My output

How can I create a batch file that changes my MAC address?

强颜欢笑 提交于 2020-06-28 01:58:16
问题 I recently learned how to change my MAC address thanks to https://superuser.com/questions/1514745/how-to-change-mac-address-on-windows-10-without-third-party-software/1544773 but I was wondering if I could implement this in a batch file. The registry key for my NIC is HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0011 . I want to create a batch file that randomizes my MAC Address. You don't need to create the batch file for me (you can, I can't

wmic cpu get LoadPercentage always returns empty value

拟墨画扇 提交于 2020-06-27 08:50:10
问题 I'm use wmic command to get current CPU utilization, the command are: wmic cpu get LoadPercentage /value It's works fine at first, but somehow it doesn't shows the LoadPercentage, but always returns with empty result like: C:\Users\Administrator>wmic cpu get LoadPercentage /value LoadPercentage= It's so weird and I'm pretty sure that the result don't match with the taskmgr.exe . I also tried this command without /value , the result is still the same. I have copy a large file in my server, and

Best practice for exiting batch file? [closed]

会有一股神秘感。 提交于 2020-06-27 08:46:06
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . Improve this question For a batch file I want to check for different conditions and have a help message Which one is the best practice for exiting the batch file after displaying the message? if "%1"=="/?"( echo "help message" exit /b 0 ) [more code] or if "%1"=="/?"( echo