Tag Info

Hot answers tagged

13

It looks like the DOS ASCII encoding of the Byte Order Mark for UTF-8 (0xEF 0xBB 0xBF): http://en.wikipedia.org/wiki/Byte_order_mark In Notepad++ try encoding it as "UTF-8 Without BOM" or as plain ASCII. I think the use of BOM for UTF-8 is discouraged for this reason, it's not exactly backwards compatible with ASCII.


5

This is normal behavior. CD stands for Change Directory. In order to change the drive, go to it by typing: E: followed by enter C:\>E:_ E:\Program Files\wkhtmltopdf>_ It will remember your cd action though, so the new path should be what you've cd'd to.


4

Turns out it needs to be set to ANSI encoding to work properly. To set this, I chose Encoding->Encode in ANSI. To figure this out, I tried to create a batch file from the command line. echo @echo off > batch.bat echo REM Some comment... >> batch.bat echo echo Hello world! >> batch.bat I then opened this file up in Notepad++, and checked ...


2

You missed a couple of double-quotes... What's going on is that @FILE returns the file name wrapped in double-quotes, so you need to reference it as such in your IF-statement comparison. You can witness this by doing a forfiles /P "I:\testroot" /C "CMD /C echo @FILE", and seeing that testung.txt is echoed as "testing.txt". To use double-quotes within a ...


2

I would recommend GhostScript: gs -sDEVICE=jpeg -r300x300 -dNOPAUSE -dBATCH -sOutputFile="image00.jpg" "input.pdf" r parameter is resolution gs -sDEVICE=jpeggray -r300x300 -dNOPAUSE -dBATCH -sOutputFile="image00.jpg" "input.pdf" This one is for grayscale output.


2

The following simple script will rename all .jpg files in the current folder to random 8 character alphanumeric names, preserving the .jpg extension. Note that it is possible for the random name generator to produce a name that already exists, so the script loops until it successfully generates a unique name. @echo off setlocal disableDelayedExpansion set ...


2

The way recusion works is that is ensures that everything beneath a root folder is also worked on. For example - if you have a C:\myfolder folder with a dozen subfolders, some of which have their own subfolders and even some of them do as well - each with files in... then managing them and applying a change to them all is very time consuming and easy to ...


2

In a batch script, you can use %~dp0 to represent the directory that contains the running batch script. So if you had files at the following locations: C:\scripts\script.bat C:\scripts\relative_path\registry_settings.reg you could write this in script.bat: regedit.exe /s "%~dp0relative_path\registry_settings.reg" and get all the benefits of relative ...


2

Use a for loop: @echo off ( for /f "tokens=*" %%i in (list.txt) do type "%%~i" ) > compiled.txt


2

Batch can't do this. But PowerShell can Here is a very simple example to open two Internet Explorer windows and move/resize them $ie1 = new-object -comobject InternetExplorer.Application $ie1.navigate("http://google.com") $ie1.visible = $true $ie1.top = 10 $ie1.width = 790 $ie1.height = 790 $ie1.Left = 10 $ie2 = new-object -comobject ...


1

Oh, that extra carriage return does some weird stuff. tl;dr: Something like this seems to work: FOR /F %%L in ('wmic desktopmonitor get screenheight') DO ( CALL :foo "%%L" ) :: ... GOTO :EOF :foo IF NOT [%~1]==[] set RESULT=%~1 GOTO :EOF Anyway, the root of the problem, as you've noted, is wmic weirdly outputting those extra carriage returns. (It ...


1

Thanks to Ben Nesson answer i've found an easy solution that works both on XP and Vista: just pipe wmic output to findstr and strip all the newlines: FOR /F %%L IN ('wmic desktopmonitor get screenheight ^| findstr "."') DO set YRES=%%L


1

If you don't want to use AutoIt then look into the quser command which displays, amongst other things, the idle time to the nearest minute: C:\Users\Richard>quser USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME >richard console 1 Active none 26/06/2014 15:29 C:\Users\Richard> One ...


1

You can make a commandlet. Create a new text file type into the text file (you may have to use quotes if the path to the .hta has spaces) %windDir%\system32\mshta.exe "FULLPATH_OF_HTA\FILENAME.hta" save the text file change the extention from .txt to .cmd now you can right click and run as admin or shift right click to run as other user. you can also ...


1

This should do it: @echo off REM create empty result file copy nul results.txt /y REM iterate over list skipping #entries and copy binary for /f "usebackq delims=" %%F in (`findstr /R /V "^#" list.txt`) do ( copy /b results.txt+"%%~F" results.txt ) Syntax as it's batch file, if you want to execute directly from cmd line change %%F to %F


1

^ is an escape character in cmd.exe. You have to escape it. Try ren *^^ *^^.html.


1

The problem is that the Windows Command Prompt / Command-Line Interpreter (CLI), known as CMD.EXE, has a bug (well, I’m sure Microsoft thinks that it’s a feature) wherein, when it reads a block construct like IF … ( … ) or a FOR loop, it interprets all %variable_name% variables immediately, before the loop or block is executed.  In your example, if potion is ...


1

A very simple command to do what you need is timeout command (your command) TIMEOUT 5 your TASKKILL command where 5 is time in second


1

You have two main options here: The first option is to add the /i parameter. The related text in the documentation is as follows: If Source is a directory or contains wildcards and Destination does not exist, xcopy assumes Destination specifies a directory name and creates a new directory. Then, xcopy copies all specified files into the new directory. ...


1

Change the current drive By default, the cd or chdir commands won't change the drive letter you're currently on; you need to use the /d parameter. For example: cd /d E: You can also use a specific path, if you want: cd /d "E:\Program files\wkhtmltopdf" As an alternative you can use the pushd (push directory) command, like this: pushd "E:\Program ...


1

The part of the answer that nobody else has explained is that Windows keeps track of (up to) 26 different current directories for each process (one for each drive), so, when you type C:\> cd E:\Program Files\wkhtmltopdf you are changing your E: working directory to \Program Files\wkhtmltopdf -- but (as the other answers have explained), you’re not ...


1

Alwayse quote the paths. paths with space in name must quote. use this : cd "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\System" mkdir Settings cd "C:\ProgramData\Microsoft\Windows\Start Menu" dir move "Default Programs.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\System\Settings" pause


1

Solution The problem lies in the following line of code: move "Default Programs.lnk" "C:\ProgramData\Microsoft\Windows\Start Menu\System\Settings" As pointed out by @Scott, the destination path is wrong. In particular: Start Menu\System That part should read: Start Menu\Programs\System Remarks Even if you were able to solve the problem, there are ...


1

Would the computer's hostname be sufficient, instead of IP Address? IF %COMPUTERNAME% NEQ NetBIOSPC (wmic nicconfig where (TcpipNetbiosOptions!=null and TcpipNetbiosOptions!=2) call SetTcpipNetbios 2) Obviously, replace NetBIOSPC with the actual hostname of the system. Be sure you're using the right hostname by typing hostname or echo %COMPUTERNAME% at ...


1

Solution Despite its name, the forfiles command is able to handle both files and folders. Here's a batch script that does the job: @echo off setlocal set target=X:\backups set days=-2 for /f "usebackq delims=" %%G in ( `forfiles /p "%target%" /c "cmd /c if /i @isdir == true echo @path" /d %days% 2^>nul` ) do echo rd /s /q "%%~G" pause endlocal & ...



Only top voted, non community-wiki answers of a minimum length are eligible