How could i make a batch file that would track and keep internet history (from google chrome) and after i run CCleaner and cleared history through google chrome, the batch file would have already created a text file and have the history still on it? I need this to be a batch file that would create and update a text file about this.
Batch code begins here:
#echo off
echo Welcome to the history tracker!
echo Turn on? [1]-Yes [2]-No
set /P variable=Enter choice:
IF "%variable%"=="1" (GOTO start)
IF "%variable%"=="2" (GOTO end)
:end
echo.
:start
REM I don't know what else to do
#echo off
:top
for /f "delims=: tokens=2" %%i in ('ipconfig /displaydns^|find "Record Name"') do (find "%%i" /i history.txt >nul 2>&1|| echo %%i >>history.txt)
timeout /nobreak 5 >nul 2>&1
sort history.txt /o history.txt
goto top
this will give you a list of all the SITES visited. not the individual pages on the sites, but the sites.
Related
I am currently trying to create a batch script so I can sort multiple tiff images in a folder by moving it to other specific folder according to user input. What I achieved so far is:
1. Can loop through all the files in the folder
2. Can open the image viewer to view the tiff file
3. Close off the image viewer program
4. Move the tiff file to specific folder
However, I do not know why my set /p is not registering user's input value, when I tried to echo the input out.
cmd gave me "ECHO is off" message.
Appreciate if anyone could give me a hand to resolve this problem.
Many thanks
G
#ECHO OFF
cd "C:\img\"
FOR /R %%f IN (*.tif) DO (
echo Current file is: %%f
start "" "C:\Program Files (x86)\Common Files\Global 360\Imaging\kodakprv.EXE" %%f
set /p name= Action:
IF "%name%" == "1" GOTO ONE
IF "%name%" == "2" GOTO TWO
IF "%name%" == "3" GOTO THREE
ECHO %name%
echo None of the above, BYE!
GOTO END
:ONE
echo "I pressed 1"
taskkill /IM kodakprv.EXE
move %%f "C:\img\1"
cls
:TWO
echo "I pressed 2"
taskkill /IM kodakprv.EXE
move %%f "C:\img\2"
cls
:THREE
echo "I pressed 3"
taskkill /IM kodakprv.EXE
move %%f "C:\img\3"
cls
)
:END
#ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
cd "C:\img\"
FOR /R %%f IN (*.tif) DO (
echo Current file is: %%f
start "" "C:\Program Files (x86)\Common Files\Global 360\Imaging\kodakprv.EXE" %%f
SET "name="
set /p name= Action:
for %%v in (1 2 3) do IF "!name!" == "%%v" (
set "validaction=Y"
echo "I pressed %%v"
taskkill /IM kodakprv.EXE
move %%f "C:\img\%%v"
pause
cls
)
if not defined validaction (
ECHO !name!
echo None of the above, BYE!
GOTO END
)
)
:END
A few little problems.
First, you can't use labels within a code block (parenthesised series of commands) and second the old favourite, delayedexpansion - if a variable is changed within a code block then unless delayed expansion is in effect, the original value will be used. If delayed expansion is in effect, then %var% refers to the original value and !var! to the current (run-time) value.
Note also that set /p does not change the value of the variable if user response is simply Enter - -hence the set "name=" above to clear its value. Of course, you can omit that line and the last-entered value of name will be used again if you just press Enter.
There are many articles on SO about delayed expansion - just use the search feature.
I am creating a batch file to open remote Computer Management console by taking User ID as input and computer name from 2nd column from file data.csv. it works fine on first attempt. When it goes back to :start label. and ask for other input. it gives error. System cannot find file ./data.csv
My code is
:start
set /p Input="Enter User-ID:"
for /f "usebackq tokens=1-4 delims=," %%a in (".\data.csv") do (
if %input% ==%%a ("cmd /c Start /B /wait compmgmt.msc –a /computer=%%b")
)
cls
GOTO start
Good practice to use %~dp0 for paths in batch files (instead of relative paths like .) that way if the current working folder changes the file will always be located.
So change to %~dp0data.csv
:start
set /p Input="Enter User-ID:"
PUSHD
for /f "usebackq tokens=1-4 delims=," %%a in (".\data.csv") do (
if %input% ==%%a ("cmd /c Start /B /wait compmgmt.msc –a /computer=%%b")
)
POPD
cls
GOTO start
should restore sanity, pushing the directory then restoring it before the next cycle.
Here is what I am attempting to do and if I can get your help it would be greatly appreciated!
Issue:
I want to create a script to do the following:
Go out to a network share where all account folders exist (2,400 folders with a 9-digit naming convention for account numbers, i.e folder name is 123456789).
Then go through a specific directory within the account folders that have a time stamp naming convention (i.e 123456789\Jan_29_2013_453pm).
Next, all folder structures are the same for all account folders EXCEPT the time stamped folder under the root (i.e 123456789`Jan_29_2013_453pm`\data).
Once being able to get through the time stamp folder there will be a set of folders that start off with a naming convention of media1, media2, media3, media4, media5, etc. that I need to access in order to move files.
I need to move a certain file from all media folders into media1. **There is an unknown amount of media folders for different account folders. Some may have 1 and other may have 50.
I need to run a test within the data folder (123456789\Jan_29_2013_453pm\data) to open a logfile.txt to see if a specific string exists at the end of the log (i.e item was successfully created as well as item has failed`).
If there is a SUCCESSFUL string in the logfile.txt, then go ahead and move all files from other media folders into media1. If a FAILURE string, then output the account folder name to a log file (output.txt) so I am aware which account folders failed (I would append the output as I will run this script multiple times).
The idea is to disregard account folders that have just a single media1 folder. Other account directories that have more than ONE media folder need to run a test against the log for SUCCESS or FAIL and depending on the string, to move a single file from all other media (media2,media3,media4,etc.) folders over to media1 unless FAILURE is read in the log.
I created a text file with all account folders on the share. I'm sure a FOR statement can be used against it. I'm also sure that a FOR statement can be used to go through the log in the "DATA" directory to look for the "SUCCESSFUL" or "FAILED" string.
The hard part I see is being able to get through the time stamped folder in order to get to the DATA directory.
THANKS AGAIN FOR ALL THE HELP!
#echo off
setlocal enabledelayedexpansion
:beginning
echo.
echo.
echo ===========================================================
echo Starting on !date! !time! on !Computername!
echo ===========================================================
echo.
echo Press ENTER to begin...
pause
echo.
goto :main
:main
cls
echo.
set /P acct=Please type the 9 digit account number you would like to restore:
set acctDir=X:\!acct!\
set acctDir2=media1\Setup\setup.exe /cd
set acctDir3=media1
set x=x:\!acct!\!userDir!
set sumLog="x:\!acct!\!userDir!\SummaryLog.txt"
set succ=finished
set log=c:\logs.txt
echo. Starting on !date! !time! on !Computername! >> !log!
echo.
echo The account number you selected is: !acct!
echo.
goto :user
:user
set /p answer=Is this correct (Y/N)?
echo.
if /i !answer!==y goto :yes (
) else (
echo.
echo Ok. Let's try again^^!
echo.
pause
cls
goto :main
)
)
:yes
set c=0
For /f %%a in ('dir !acctDir! /B /A:D') do (
set /a c+=1
echo !c! %%a
set dir!c!=%%a
)
echo.
set /p userIn="Select a directory [1-!c!]: "
set userDir=!dir%userIn%!
echo.
echo You selected !userDir! for your data retrieval.
echo.
goto :execute
:execute
echo.
echo The software will now be installed...
start !acctdir!\!userDir!\!acctDir2! >>!log!
:move
forfiles /p "!acctdir!\!userDir!\" /s /m *.ARC /c "cmd /c move #file !acctdir!\!userDir!\!acctdir3!"
goto
:string
findstr " .*!succ!" !sumLog!
if exist errorlevel 0 (
pause
goto :move
) else (
goto :eof
)
endlocal
goto :eof
I am having a problem. I need my code to list all the text files in a big directory and pause at each full screen. I set it up so that users will be able to input the number that is listed beside every txt file in the list but the /p parameter refuses to pause the list...
DIR SAVES\*.txt /B /P |FIND /V /N "//"
ECHO.
ECHO (Press "Q" to EXIT to the main menu)
ECHO.
CHOICE /C DLVQ /N /M "Would you like to DELETE, LOAD, or VIEW a file [D/L/V]?"
IF ERRORLEVEL 4 GOTO MENU
IF ERRORLEVEL 3 GOTO VIEW
IF ERRORLEVEL 2 GOTO LOAD1
IF ERRORLEVEL 1 GOTO DELETE
:DELETE
ECHO.
SET /P C=Choose the file number [#] to DELETE (and press ENTER):
FOR /F "usebackq tokens=1,2* delims=[]" %%d IN (`DIR SAVES\*.txt /B ^|FIND /V /N "//"`) DO (
IF /I !C! EQU q (GOTO MENU)
IF !C! EQU %%d (
ECHO.
CHOICE /N /M "Are you sure you want to DELETE %%e [Y/N]?"
IF ERRORLEVEL 2 GOTO LOAD
DEL /Q "SAVES\%%e"
DEL /Q "SAVES\"%%~ne"_stats"
IF EXIST "SAVES\%%e" (
IF EXIST "SAVES\"%%~ne"_stats" (
GOTO DELETE1
The folder could potentially have hundreds of txt save files and i need the ability to run this script in its own cmd window and pause as the screen fills up with info. Running my whole utility as a .bat means there is NO scrollbar available for users to view all the files. How can I make the /P pause parameter work?
You're piping the output of dir to find. find itself doesn't do pagination and simply outputs anything it matches in the input. dir itself can't do the pagination in this case, because find would be unable to do the input to advance to the next page, so you've effectively disabled pagination.
Try
dir | find | more
I'm messing around with dos and batch files for the first time and I am trying to make a "program" to backup my Minecraft saves (lol). I want the program to rename the current save (in my MinecraftSaves folder) as "Backup#" before the next one is copied into the MinecraftSaves folder. Its simple enough to rename it, but I want it to save multiple folders, each incrementing a number at the end of the folder name (ie Backup1, Backup2, Backup3). Any help? I've looked all over but I couldn't find something exactly to fit my needs.
#Echo off
title Minecraft Backup
echo.
echo.
echo.
echo Do you want to backup you're Single Player World?
echo.
SET /P ANSWER=Do you want to continue (Y/N)?
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
if /i {%ANSWER%}=={n} (goto :no)
if /i {%ANSWER%}=={no} (goto :no)
:no
PING 1.1.1.1 -n 1 -w 1000 >NUL
exit
:yes
ren C:\Users\Josh\Desktop\MinecraftSaves\SinglePlayer Backup
xcopy C:\Users\Josh\AppData\Roaming\.minecraft\saves C:\Users\Josh\Desktop\MinecraftSaves /-y /e /h
Thats what I have so far. I want to change the following to rename the SinglePlayer folder as backup1, and the next time I run it have it rename the new SinglePlayer folder as backup2. I'm trying to explain this as best I can. Maybe theres a simpler way to do this. I just need it to make backups with numbers on the backup folders. Hope thats clear enough.
Excuse me. I think I did not really understood your question. However, the following Batch file take an existent folder named CurrentSave and rename it to Backup-# adding 1 to the last Backup-# existent folder. The dash in the folder name make things easier.
#echo off
for /D %%d in (Backup-*) do set lastfolder=%%d
for /F "tokens=2 delims=-" %%n in ("%lastfolder%") do set /A nextnumber=%%n+1
move CurrentSave Backup-%nextnumber%
If this is not what you want, give us more details so we may help you.
EDIT
OK. The code I posted above works right, just a couple details are needed. Below is the code you must insert from :yes label on:
:yes
set lastfolder=Backup-0
for /D %%d in (C:\Users\Josh\Desktop\MinecraftSaves\Backup-*) do set lastfolder=%%~Nd
for /F "tokens=2 delims=-" %%n in ("%lastfolder%") do set /A nextnumber=%%n+1
ren C:\Users\Josh\Desktop\MinecraftSaves\SinglePlayer Backup-%nextnumber%
xcopy C:\Users\Josh\AppData\Roaming\.minecraft\saves C:\Users\Josh\Desktop\MinecraftSaves /-y /e /h
May I suggest you another modification?
SET /P ANSWER=Do you want to continue (Y/N)?
for %%a in (y yes) do if /i "%ANSWER%"=="%%a" goto yes
:no
Please let me know if you solved your problem.