My semi-pointless batch files & .exe's
My PC Hell Forum
January 08, 2009, 03:30:04 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Moving to New Location Soon! Watch out for notification. 14th Dec 2007.
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: My semi-pointless batch files & .exe's  (Read 4785 times)
Cache
Rising Star
***
Posts: 380



View Profile
« on: September 21, 2005, 04:34:06 PM »

Well I made the things, though I might as well show them. I guess posting them here makes them just that lil bit less pointless (for me to make), lol.

Best say first that im aware there is "propper" software with much better functionality than my batch files, I only make these for fun. Also, if anyone does choose to use or try these batch files, please only do so if you know what they are doing. They have only ever been tested on my WinXP machine. Feel free to ask any questions you may have about these files, I'll try to answer as best I can.

Ok, so here is the first:

I call this "Clean up XP". It will either delete all Windows temp files or all IE temp files. The IE cleaning option will also turn the index.dat files into a Zero byte file prior to deletion. The Windows temp file deletion option should be used with care, and only used once every 2 to 3 months or so, maybe even longer.

Code:
TITLE Clean up XP
COLOR 1F
@ ECHO OFF
:start
CLS
ECHO.
ECHO                             **********************
ECHO                             *     Clean up XP    *
ECHO                             *  ----------------  *        
ECHO                             **********************
ECHO.
ECHO.

ECHO Please choose from the folowing options...
ECHO.
ECHO 1: Clean Internet Explorer Temp folders
ECHO 2: Clean Windows Temp files/folders
ECHO 3: Exit program
echo.

SET /P choice=CHOICE:

if %choice% equ 1 goto IE
if %choice% equ 2 goto Win
if %choice% equ 3 (EXIT) else (
ECHO.
ECHO Error "%CHOICE%" is not an option. Please try again...
PAUSE
GOTO start
)

:IE
if %OS% == Windows_NT (
TASKKILL /F /IM iexplore.exe /FI "STATUS eq RUNNING" >NUL
TASKKILL /F /IM explorer.exe >NUL && (
ping -n 3 127.0.0.1 >NUL
ATTRIB -S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\Temporary Internet Files" >NUL
ATTRIB -S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\Temporary Internet Files\Content.IE5" >NUL
ATTRIB -S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\History" >NUL
ATTRIB -S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\History\History.IE5" >NUL
ATTRIB -S "%Systemdrive%\Documents and Settings\%Username%\Cookies" >NUL
TYPE NUL > "%Systemdrive%\Documents and Settings\%Username%\Local Settings\Temporary Internet Files\Content.IE5\index.dat" >NUL
DEL /F /S /Q "%Systemdrive%\Documents and Settings\%Username%\Local Settings\Temporary Internet Files\*.*"
TYPE NUL > "%Systemdrive%\Documents and Settings\%Username%\Local Settings\History\History.IE5\index.dat" >NUL
DEL /F /S /Q "%Systemdrive%\Documents and Settings\%Username%\Local Settings\History\*.*"
TYPE NUL > "%Systemdrive%\Documents and Settings\%Username%\Cookies\index.dat" >NUL
DEL /F /S /Q "%Systemdrive%\Documents and Settings\%Username%\Cookies\*.*"
ping -n 3 127.0.0.1 >NUL
ATTRIB +S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\Temporary Internet Files" >NUL
ATTRIB +S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\Temporary Internet Files\Content.IE5" >NUL
ATTRIB +S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\History" >NUL
ATTRIB +S "%Systemdrive%\Documents and Settings\%Username%\Local Settings\History\History.IE5" >NUL
ATTRIB +S "%Systemdrive%\Documents and Settings\%Username%\Cookies" >NUL
echo.
echo Operation Complete...
PAUSE
START explorer.exe
goto start
)
) else (
echo.
echo ERROR:This BATCH file is NOT intended for use on "%OS%" systems,
echo all batch operations will now terminate...
echo.
pause
EXIT
)

:Win
if %OS% == Windows_NT (
Taskkill /F /IM explorer.exe >NUL
ping -n 3 127.0.0.1 >NUL
DEL /F /S /Q %temp%\*.*
DEL /F /S /Q %Windir%\Temp\*.*
DEL /F /S /Q %Windir%\Prefetch\*.*
DEL /F /S /Q %Systemdrive%\*.tmp
DEL /F /S /Q %Systemdrive%\*.chk
DEL /F /S /Q %Systemdrive%\~*.*
pause
START explorer.exe
gogo start
) else (
echo.
echo ERROR:This BATCH file is NOT intended for use on "%OS%" systems,
echo all batch operations will now terminate...
echo.
pause
EXIT
)
Logged
Cache
Rising Star
***
Posts: 380



View Profile
« Reply #1 on: September 21, 2005, 04:38:36 PM »

I call this one "Directory Master" lol. The name sead it all really. It makes, moves, renames or deletes files/folders.

Code:
TITLE Directory Master
COLOR 1F
@ ECHO OFF

:start
CLS
ECHO.
ECHO                             **********************
ECHO                             *  Directory Master  *
ECHO                             *  ----------------  *        
ECHO                             **********************
ECHO.
ECHO.

ECHO Please choose from the folowing options...
ECHO.
ECHO 1: Make folder
ECHO 2: Delete file
ECHO 3: Delete folder
ECHO 4: Rename folder or file
ECHO 5: Move folder or file
ECHO 6: Exit program
ECHO.

SET /P CHOICE=CHOICE:

IF %CHOICE% EQU 1 GOTO A
IF %CHOICE% EQU 2 GOTO B
IF %CHOICE% EQU 3 GOTO C
IF %CHOICE% EQU 4 GOTO D
IF %CHOICE% EQU 5 GOTO E
IF %CHOICE% EQU 6 (EXIT)

ECHO.
ECHO Error "%CHOICE%" is not an option. Please try again...
PAUSE
GOTO start

:A
ECHO.
ECHO Please enter the path and name to use for the new folder...
SET /P NEWDIR=
MKDIR %NEWDIR%
ECHO.
ECHO New folder was created at %NEWDIR%
ECHO If no path was given "%NEWDIR%" will have been created in the working directory
pause
GOTO start

:B
ECHO.
ECHO Please enter the full path to the file you would like to delete
ECHO "Wrap the path in quotation marks"
SET /P DELFILE=
IF EXIST %DELFILE% (DEL %DELFILE%) ELSE ECHO Error no file found at "%DELFILE%"
PAUSE
GOTO start


:C
ECHO.
ECHO Please enter the full path to the folder you would like to delete
ECHO "Wrap the path in quotation marks"
SET /P DELDIR=
IF EXIST %DELDIR% (RD %DELDIR%) ELSE ECHO Error no folder found at "%DELDIR%"
PAUSE
GOTO start

:D
ECHO.
ECHO Please enter the full path to the folder you would like to rename
ECHO "Wrap the path in quotation marks"
SET /P RENDIR=
ECHO.
ECHO Please enter the new name...
SET /P RENAME=
IF EXIST %RENDIR% (REN %RENDIR% %RENAME%) ELSE ECHO Error no file or folder found at "%RENDIR%"
PAUSE
GOTO start

:E
ECHO.
ECHO Please enter the location of the folder or file to move
ECHO "Wrap the path in quotation marks"
SET /P MOVDIR=
ECHO.
ECHO Please enter the location you would like to move the foler or file to
ECHO "Wrap the path in quotation marks"
SET /P MOVED=
IF EXIST %MOVDIR% (MOVE %MOVDIR% %MOVED%) ELSE ECHO Error no folder or file exists at "%MOVDIR%"
PAUSE
GOTO start
Logged
Cache
Rising Star
***
Posts: 380



View Profile
« Reply #2 on: September 21, 2005, 04:41:34 PM »

This one is called "Drive Diag". It will do(or show):

1: Analyze Volume fragemtation
2: Defragment Volume
3: Volume Information
4: NTFS Volume statistics

Code:
TITLE Drive Diag
COLOR 1F
@ ECHO OFF
:start
CLS
ECHO.
ECHO                             **********************
ECHO                             *     Drive Diag     *
ECHO                             *  ----------------  *        
ECHO                             **********************
ECHO.
ECHO.

ECHO Please choose from the folowing options...
ECHO.
ECHO 1: Analyze Volume fragemtation
ECHO 2: Defragment Volume (Ctrl+C to terminate)
ECHO 3: Volume Information
ECHO 4: NTFS Volume statistics
ECHO 5: Exit program
ECHO.

SET /P choice=CHOICE:

if %choice% equ 1 goto Ana
if %choice% equ 2 goto Def
if %choice% equ 3 goto Vol
if %choice% equ 4 goto Stat
if %choice% equ 5 (EXIT) else (
ECHO.
ECHO Error "%CHOICE%" is not an option. Please try again...
PAUSE
GOTO start
)

:Ana
ECHO.
ECHO Please input a drive to Analyze... Example C:
SET /P DRIVE=Input:
ECHO.
if exist %DRIVE% (
CLS
defrag %DRIVE% -a -v
defrag %DRIVE% -a -v | FIND "You should defragment this volume" >NUL
if ERRORLEVEL 0 goto Ask
) else (
ECHO.
ECHO ERROR: Either "%DRIVE%" does not exist or the syntax is incorect...
PAUSE
GOTO start
)
:Ask
ECHO.
ECHO Since the analysis indicates you SHOULD defragment this Volume, would you like  to defragment now. Y/N?
SET /P DEFCHOICE=:
if %DEFCHOICE% EQU Y goto Def
if %DEFCHOICE% EQU y goto Def
if %DEFCHOICE% EQU N goto start
if %DEFCHOICE% EQU n goto start else (
ECHO.
ECHO Error "%DEFCHOICE%" is not an option. Please try again...
PAUSE
GOTO Ask
)

:Def
ECHO.
ECHO.
ECHO Please input a drive to Defragment... Example C:
SET /P DEFDRIVE=Input:
ECHO.
if exist %DEFDRIVE% (
CLS
defrag %DEFDRIVE%
) else (
ECHO.
ECHO ERROR: %DEFDRIVE% does not exist or the syntax is incorect...
PAUSE
GOTO start
)
ECHO.
PAUSE
GOTO start

:Vol
ECHO.
ECHO.
ECHO Please input a Drive letter... Example C:\
SET /P VOLDRIVE=Input:
ECHO.
if exist %VOLDRIVE% (
CLS
fsutil fsinfo volumeinfo %VOLDRIVE%
) else (
ECHO.
ECHO ERROR: Either "%VOLDRIVE%" does not exist, there is no media mounted at selected Drive, or the syntax is incorect...
PAUSE
GOTO start
)
ECHO.
PAUSE
GOTO start

:Stat
ECHO.
ECHO.
ECHO Please input a NTFS Drive letter... Example C:
SET /P STATDRIVE=Input:
ECHO.
if exist %STATDRIVE% (
CLS
fsutil fsinfo statistics %STATDRIVE%
) else (
ECHO.
ECHO ERROR: %STATDRIVE% does not exist or the syntax is incorect...
PAUSE
GOTO start
)
ECHO.
PAUSE
GOTO start
Logged
Cache
Rising Star
***
Posts: 380



View Profile
« Reply #3 on: September 21, 2005, 04:46:32 PM »

This next one is most likely the most pointless of all lol. Its a program written in C++ to take, store and display phone numbers.

Note: This is only a console app, no fancy GUI here. I use Dev-C++ to compile this but it should compile just as well in others.

Code:
#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]){

while (1) {
system("CLS");
string answer;
cout << "Bog Standard Phone Number Thingy.\n" << endl;
cout << "Please choose from the folowing options..." << endl;
cout << "1: " << "Add New Number To List" << endl;
cout << "2: " << "View Existing Number" << endl;
cout << "3: " << "Exit Program" << endl;
cout << "\n" << ":";
cin >> answer;

if (answer == "1"){
  string name;
  string number;
 
cout << "\n" << "Please input name..." << endl;
  cout << ":";
  cin >> (name);
cout << "\n" << "Please input number..." << endl;
  cout << ":";
  cin >> (number);
 
  string namenumber;
  namenumber += name + " " + number;
 
  vector<string> addnamenumber;
  string newnamenumber;
 
  ifstream prenamenumber ("namenumber.txt");
  while (getline(prenamenumber, newnamenumber)) {
addnamenumber.push_back(newnamenumber + "\n");
}
  addnamenumber.push_back(namenumber);
  prenamenumber.close();
 
  ofstream namenumberstream ("namenumber.txt");
  if (namenumberstream.is_open()) {
for (int i=0; i < addnamenumber.size(); i++)
namenumberstream << addnamenumber[i];
namenumberstream.close();
cout << "\n" << "New Entry Successfully Added" << endl;
system("PAUSE");
} else if (! namenumberstream.is_open()) {
cout << "\n\nError opening file" << endl;
exit(1);
}
} else if (answer == "2") {
  string findname;
  cout << "Please input a name" << endl;
  cout << ":";
  cin >> (findname);
  ifstream numberfile ("namenumber.txt");
  string line;
  while (getline(numberfile, line)) {
string::size_type position = line.find(findname);
if (position != string::npos) {
cout << "\n" << line << endl;
} else if (position == string::npos) {
cout << "\n" << "Name Not Found" << endl;
break;
   }
}
  cout << endl;
  system("PAUSE");
  } else if (answer == "3") {
  break;
  } else {
cout << "\n" << "ERROR: " << answer << " is not an option." << endl;
cout << "please select 1, 2, or 3 ";
system("PAUSE");
}
}
 
return EXIT_SUCCESS;
}
Logged
fleamailman
Rising Star
***
Posts: 344



View Profile
« Reply #4 on: October 08, 2005, 12:11:41 PM »

Nice bunch, do you have or could you make a simple batch file that I could burn on to a cd to make that cd auto exicutable, I had it before but can't find where I put it.
Logged

The goblin took a hike, fleamailman's account has been taken over by a different serious me then.
Cache
Rising Star
***
Posts: 380



View Profile
« Reply #5 on: October 09, 2005, 04:23:46 PM »

Quote from: fleamailman
Nice bunch, do you have or could you make a simple batch file that I could burn on to a cd to make that cd auto exicutable, I had it before but can't find where I put it.


Hi,

Have read through the folling link. It should tell you everything you need to know:
http://www.ezau.com/latest/articles/autorun.shtml
Logged
fleamailman
Rising Star
***
Posts: 344



View Profile
« Reply #6 on: October 10, 2005, 03:31:02 AM »

Thanks, I downloaded a program from there but I also remember a friend who just created an icon that looked like the cddrice with the word launch underneather which I just burned on to the cd to make it auto star. Would anyone here have a copy of that thing.
Logged

The goblin took a hike, fleamailman's account has been taken over by a different serious me then.
swell8
New FixmyXP Member
*
Posts: 1


View Profile
« Reply #7 on: June 06, 2006, 06:26:52 PM »

Here's one I have on my desktop, it might be common knowledge, but I find it useful.

defrag c:
shutdown -s

copy and paste into Notepad, save as .bat file, save it somewhere convenient.  Make shortcut on desktop, change name and icon, and that's it!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!