batch-file

Batch Script to delete files based on findstr regex

久未见 提交于 2020-01-13 18:08:47
问题 I'm trying to delete some files with a batch script, based on a regular expression. What I have is: FOR /f "tokens=*" %%a in ('dir /b | findstr MY_REGEX_HERE') DO ECHO %%a I know my inner command works on its own, giving me the list of directories, but when I embed it in the for loop like this I get an error | was unexpected at this time. Is piping not allowed within FOR loop commands? Or do I need to escape it or something? Any help on how I can do this would be great. 回答1: FOR /f "tokens=*"

Safely remove USB from batch file?

霸气de小男生 提交于 2020-01-13 11:34:12
问题 Can a batch file be made in windows that could safely eject the USB?So far on various sites there exist different utilities like devcon. 回答1: Eject Media and Remove Drive Freeware by Uwe Sieber - http://www.uwe-sieber.de Remove drive is what you need for USB safe removal. 回答2: Download RemoveDrive.exe from http://www.uwe-sieber.de/drivetools_e.html and then use the code below. removedrive\x64\RemoveDrive.exe F: -L Note that F: is the drive you want to eject -L means Loop 回答3: Please try this

store SID in a variable

怎甘沉沦 提交于 2020-01-13 11:29:20
问题 I need a way to store the current user's SID in a variable, I tried a lot of variants of: setlocal enableextensions for /f "tokens=*" %%a in ( '"wmic path win32_useraccount where name='%UserName%' get sid"' ) do ( if not "%%a"=="" set myvar=%%a echo/%%myvar%%=%myvar% pause endlocal None are working. wmic path win32_useraccount where name='%UserName%' get sid should be returning 3 lines, and I need the second one stored in a variable. Can someone fix my script? Edit : I am using a .cmd file.

VBScript for creating a scheduled task

南楼画角 提交于 2020-01-13 09:40:19
问题 I'm trying to create a VBScript that creates a batch file then creates a scheduled task to run the batch file. So far everything I've tried creates the batch file, but does not create the scheduled task and I haven't received any errors. Here is what I have so far: Option Explicit Dim objFSO, outFile, wShell Set objFSO = CreateObject("Scripting.FileSystemObject") Set outFile = objFSO.CreateTextFile("C:\test.bat", True) outFile.WriteLine "Start www.google.com" outFile.Close Set wShell =

How to NOT wait for a process to complete in batch script?

放肆的年华 提交于 2020-01-13 08:25:31
问题 I have a batch script that calls a process and currently it waits for the process to complete before going to the next line. Is there a way (or a switch) for it NOT to wait and just spawn the process and continue? I am using Windows 2008. 回答1: Use START c:\wherever\whatever.exe 回答2: Why not just start somecmd.exe or start "" "some command with spaces.exe" ? Note that if your command has spaces, you must put quotes around it, but if the first argument to start has quote around it the command

How to rename the files in the path with new different names in batch?

人盡茶涼 提交于 2020-01-13 08:17:52
问题 I have one file destination.txt with path information about my CDs: C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SME99.ISO C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\Biomasse.iso C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SAMPE36.ISO Now I have to rename the ISOs with the numbers that are in the file PPN.txt one after another: 470692405 394006801 348117876 So it should be SME99.ISO -> 470692405.ISO Biomasse.iso -> 394006801.ISO Sampe36.ISO -> 348117876.ISO I have the

How to rename the files in the path with new different names in batch?

拥有回忆 提交于 2020-01-13 08:17:28
问题 I have one file destination.txt with path information about my CDs: C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SME99.ISO C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\Biomasse.iso C:\Users\NekhayenkoO\Desktop\LOG Dateien CD Imaging\SAMPE36.ISO Now I have to rename the ISOs with the numbers that are in the file PPN.txt one after another: 470692405 394006801 348117876 So it should be SME99.ISO -> 470692405.ISO Biomasse.iso -> 394006801.ISO Sampe36.ISO -> 348117876.ISO I have the

Running Python file by double-click

旧时模样 提交于 2020-01-13 08:17:12
问题 I have really annoying problem, I cannot run a Python file just by double-clicking. I have tried to set it to open the file with idle.bat but that only starts IDLE editor on double-click, it does not run the Python file. 回答1: What version of Python do you have installed? You should write your own batch file to execute your python binary and your script. For example, with a default Python 2.7 installation on Windows, this could be the entire contents of your script. myscript.bat : ECHO ON REM

Running Python file by double-click

雨燕双飞 提交于 2020-01-13 08:16:17
问题 I have really annoying problem, I cannot run a Python file just by double-clicking. I have tried to set it to open the file with idle.bat but that only starts IDLE editor on double-click, it does not run the Python file. 回答1: What version of Python do you have installed? You should write your own batch file to execute your python binary and your script. For example, with a default Python 2.7 installation on Windows, this could be the entire contents of your script. myscript.bat : ECHO ON REM

Nuget pack AND push within same batch script

假如想象 提交于 2020-01-13 07:52:06
问题 I'm having a heck of time writing a batch script to both pack and push the resulting .nupkg file up to my private nuget feed. I can call pack just fine, but I don't know how to parse the name of the nupkg out of the resulting output in order to do the push . Unfortunately, the version number auto-increments all the time, so I can't just make an assumption of what the resulting file would be named. FWIW, I'm using myget.org for my private hosting, but this is could easily be applied to any