Tag Info

New answers tagged

0

Try this: mkdir -p /dir1/dir2 From the mkdir man page: -p, --parents no error if existing, make parent directories as needed mkdir with the -p flag allows creation of parent directories if they do not exist. If they do, the command continues to make the child directory without error. Edit: Just noticed this is for batch files, so probably ...


-1

in Linux: mkdir -p /folder/subfolder/subsubfolder In windows this one works: http://stackoverflow.com/questions/905226/mkdir-p-linux-windows


0

md "dir 1" cd "dir 1" md "dir 2" Or simply: md "dir 1\dir 2". Omit quotes if dir names have no spaces.


0

You would create what is called a batch script. There are many tutorials around online for getting started with batch scripting, such as this one, I would recommend you have a read and test some of the basics to get a feel for it. As for your specific case, open Notepad (Not a Word doc), and type in the commands that you would normally type into Command ...


3

You need to write a batch file in Windows (in case of Linux they are called shell script). It is very easy to write once you know what commands to use (In your case you already know the commands). In a batch file you need to write down the commands in the order in which you want them to execute. To create a batch file, open a Notepad and write down those ...


2

set "PATH=%PATH%;%~d0\pathtocoreutils\bin;%~d0\pathtodropbox;%~d0\pathtoemacs\bin" What you should not do is to include the quotes in the value, but you can (and in same cases you should) quote the assignment.


2

I found my answer: There should be no quotes in the set PATH= line. It worked the second time in the same window because then there were an even number of quotes at the beginning.


0

The runas command cannot be used to elevate the command prompt -- even if you provide Administrator credentials. There is no way to elevate the command prompt from a non-elevated one.


3

Windows does not keep detailed logs about what applications were run and by whom. You can set up auditing on filesystem objects, and the security log does track logon events and privilege use. But the security log doesn't contain the info you're looking for and auditing would have had to have been set up beforehand. Even if you had auditing set up, ...


0

Bizarre to want to do it using Chrome rather than wget but it Works for me The format is Chrome URL, (you wrote start there in between which you shouldn't) C:\>"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http:// dl2.romhustler.net/download/MTOeeo3FWffukwoWvagsXw/1430069124/psx_full/Dino%20Crisis%20%5BU%5D%20%5BSLUS-00922%5D.rar ...


5

If the services you refer to are Windows Services non admin users cannot stop or start them without elevating permissions. If you're talking about removing logs from the windows event viewer, that must also be done with admin privileges, and even then I think you can only clear the entire log, not selectively remove certain entries. All of those things, ...


3

If you are have problems echoing ! then you have EnableDelayedExpansion set. If EnableDelayedExpansion is set then ! is treated as a special character and must be escaped with ^. ^ must be used twice as it is also a special character. Escaping Exclamation marks When the shell is running in EnableDelayedExpansion mode the ! character is used to ...


2

In your command line: xcopy /C /D /Y /I "C:\Temp\Source" "C:\Temp\Destination" as far as I can see, you haven't told xcopy what to copy. If you're trying to copy everything in C:\Temp\*.* then try: xcopy C:\Temp\*.* C:\Temp\Destination\ /C /D /Y /I


1

Use robocopy instead of XCOPY. It supports the same options and allows to select file patterns: robocopy source dest file(s) [options] For file pattern you could use '?' for any single character, '*' for zero to multiple chars and so on. It would help if you gave an example of how the extensions are looking like.


2

You could always just hide them instead of having a script constantly delete them. Right click the icon Cick Properties Check the Hidden box at the bottom of the general tab Hit apply and it's gone! If you hide something and want to get it back later, you need to: Navigate to your Desktop from Explorer (open a folder, type Desktop in the bar at the ...


0

You need to create a shortcut to the bat file. Then right-click and choose properties for the shortcut and you can change which account runs the shortcut and hence the batch file. UPDATE: From the clarification, you want to run something at "startup" without giving an admin password. There are several possibilities depending on your actual need. Startup ...


0

Some people get around this by setting up a task in Task Scheduler. You reference the batch file and you use the Administrator credentials. You should test to see the first few times that it actually runs each login. Also, you will need to change the saved password if the Administrator password expires or changes.


1

The error indicates that your file Test.txt is not in the same directory you are running your script from. To better accomplish grabbing just the third line from a text file, try the following, which will run quickly on ANY size file, instead of having to run through an entire file as yours would (and yours would incorrectly... you are actually grabbing ...


0

here is the command for cmd: for /f %a in (Y:\el.txt) do move "%a" "C:\Users\srinu\Desktop\test" in a batch file: for /f %%a in (Y:\el.txt) do @move "%%a" "C:\Users\srinu\Desktop\test" >> log.txt


2

Changes made to the batch file after the pause statement are fine and will take effect when you hit any continue to continue. But I would strongly recommended you do not change anything before the pause statement. Windows remembers what position it is at, so changes made to the batch file before the pause statement can affect your batch file in weird ways ...


1

Changes made to the batch file after the pause statement are reflected in the results. Changes made to the batch file before the pause statement are ignored, provided they don't change the number of characters. See answer by sgmoore for the reason why.


0

convert.cmd: powershell .\convert.ps1 powershell convert.ps1: $head=3 $f=gc data.txt $f[$head..($f.count-1)]|%{ if($_.Contains("Business Date:" )){$s=$_.split(': ')[3]}; if($_.Contains("MERCHANT TOTAL:")){$MT=($_.trim()-replace'\s+',' ').split(' ');$s=$s+';'+$MT[-2]+';'+$MT[-1]}; if($_.Contains("SMARTELLER" )){$SM=($_.trim()-replace'\s+',' ...


0

Regardless what programming language or tool you use, you must first establish how you will reliably identify the information you need to extract. It looks to me like you your date follows "Business Date: " at the beginning of a line. The terminal number follows "nn/nn/nn nn:nn:nn " (date and time) at the beginning of a line. You are not clear as to which ...


1

Powershell (3 -see note) one liner: gci *.txt -Recurse -File |sort -Property LastWriteTime |% {(gc $_) + "`n"} >output.doc It first lists all matching files (gci) then sorts them by modified date (sort) then gets contents of file and appends a newline to each (gc) and finally writes all to output file. Note: Because it uses -File which was ...


1

@echo off setlocal enableextensions disabledelayedexpansion set "root=%cd%" >"output.doc" ( for /f "tokens=2,*" %%a in (' robocopy "%root%\." "%root%\." *.txt /l /s /is /ts /ndl /njh /njs /nc /ns ^| sort ') do type "%%~fb" ) This will use robocopy to get the list of all the .txt files under the ...


0

powershell V4: gc .\data.csv | ConvertTo-Json | sc .\data.json powershell V4,V3: Using PowerShell for dynamic JSON parsing ConvertTo-Json powershell V2: Read Json Object in Powershell 2.0 But in general, I think that you can get the data in xml with weather station ...


0

command-line: powershell $h=25;$f=gc data.txt;$f[$h..($f.count-1)]^|%{$_.Trim()-replace'\s+',','>>data.csv } or: powershell $h=25;$f=gc data.txt;$f[$h..($f.count-1)]^|%{('\"'+$_.Trim()+'\"')-replace'\s+','""";"""'^|ac data.csv} powershell script: $h=25;$f=gc data.txt;$f[$h..($f.count-1)]|%{$_.Trim()-replace'\s+',','>>data.csv} or: ...


0

If this system is at least Windows 7/Server 2008 R2 then you can run the following command interactively in Powershell: Get-ChildItem -Exclude _* -Path w:\wamp\www\ | where{$_.mode -like "d*"} | select name It really is advised to scrap batch all together and move to Powershell. It is the successor of cmd (which will be deprecated in the future) and is ...


1

run multiple commands from a file after logging into putty from a bat file You can't log-in to Putty. Putty is an SSH client application which has no authentication. You can use Putty to log-in to a server computer which is providing an SSH service. Typically this would be a Linux server. It is the server that requires you log-in to it. In my ...


0

If all you need is the listing, the full code could be dir /a /b /d "w:\wamp\www" | findstr /v /b /c:"_" Use findstr to filter the list, and retrieve only the lines that do not contain (/v) at the beginning of the line (/b) an underscore


1

You can test for the underscore somewhere inside your FOR loop. SET FIRSTCHAR=%%a SET FIRSTCHAR=!FIRSTCHAR:~0,1! IF NOT "!FIRSTCHAR!"=="_" (do some stuff) This site has some good tips on string manipulation in CMD. http://www.dostips.com/DtTipsStringManipulation.php


1

Try this, assuming that there is only one instance of programname.exe allowed on the system: @echo off color a echo ProHaxor1337 Initialised color b :start start programname.exe REM Delay using ping to localhost (1 ping per second) ping 127.0.0.1 -n 60 > nul REM Kill the process forcefully. taskkill /im programname.exe /f GOTO start


0

FOR /F "tokens=2*" %%A IN (' REG QUERY "HKLM\SOFTWARE\SomeApp\Server" /v ServerName 2^> nul ') DO SET "ServerName=%%B" ECHO Server: %ServerName% Changes from your code: (not needed) delims removed. Tabs and spaces are the default delimiters, there is no need to include them (needed) The stderr stream (stream number 2) is redirected to nul ...


1

That message is coming because the REG command is writing to either the standard output stream or the standard error stream. If you really don't care about the messages, you can redirect that output so that it is not displayed. Change your command to: REG QUERY "HKLM\SOFTWARE\SomeApp\Server" /v ServerName > nul 2> nul


0

If you just want to open an excel file using command prompt, please check this : Starts Excel and opens the specified file. Example excel.exe "c:\My Folder\book1.xlsx" or excel.exe http://MySite/Book1.xlsx For the documentation how to do that please read this. You can create *.bat / *.cmd to open up multiple excel using that command And you can open ...


1

@echo off setlocal enableextensions disabledelayedexpansion rem Assumming there is some kind of log where everything is being written set "logFile=output.txt" rem Variables we need rem .... a variable containing a carriage return for spinner output for /f %%a in ('copy "%~f0" nul /z') do set "CR=%%a" rem .... a lock file to be ...


1

You can use for /r for this. Try the following batch file: for /r "starting_directory" %%a in (.) do ( pushd %%a if exist icon.ico ( attrib -s -h -r desktop.ini echo f | xcopy /h /y "%~dp0desktop.ini.txt" desktop.ini attrib +s +h +a desktop.ini ) popd ) Source FOR /R - Loop through files (Recurse subfolders) Loop through ...


1

I would use the following Robocopy syntax ROBOCOPY "C:\MyFiles" "C:\OldFiles" /move /minage:30 /s In the above note minage:30 This will move everything older than 30 days So, in your instance, you'll use minage:7 ROBOCOPY "C:\MyFiles" "C:\OldFiles" /move /minage:7 /s Your post isn't clear if you only want this to be targetting .txt files or not, ...


0

Try Robocopy. More precisely the following command should help. It is merely a template :). The command only moves all text files from "source" to "old" older than last week (03/23/2015) ROBOCOPY C:\source\*.txt C:\old /MOVE /MINAGE:n = 20150323


0

I managed to figure it out. The problem was the trailing slash in the first parameter. This slash was escaping my quite and because of that it wasn't working as a quite (yet powershell still cut the string at some later space for whatever reason). My batch file was autogenerated but I managed to fix it by adding another slash at the end of the first ...



Top 50 recent answers are included