Help - Search - Members - Calendar
Full Version: AIM backup script
ieXbeta Board > Tech > Developer Center
dkreifus
After getting annoyed with losing AIM data when wiping computers, I decided to use batch scripting, to write a script that will back up and restore AIM settings from a folder/file.

So...I have a 2 part question:

1. Do you see anything wrong or ineffecient with my script?
2. What's the best way to package this up into a working program that I can distribute (freely).

I havnt done VB in a long time, and I'm only really familiar with batch scripting...so another language isn't really possible right now.

CODE
CLS
@echo off
TITLE AIM Backup
set xcopy=false
set choice=false


IF NOT EXIST "%WINDIR%\system32\xcopy.exe" set xcopy=true
IF NOT EXIST "%WINDIR%\system32\xcopy.exe" copy "%CD%\xcopy.exe" "%WINDIR%\system32\xcopy.exe"

IF NOT EXIST "%WINDIR%\system32\choice.com" set choice=true
IF NOT EXIST "%WINDIR%\system32\choice.com" copy "%CD%\choice.com" "%WINDIR%\system32\choice.com"

CLS

ECHO.
ECHO Welcome to AIM Backup. This will back up your AIM profiles, Away messages, AIM downloads, and DeadAIM chat logs.
ECHO.
ECHO This works on 5.0-5.5. It has not been tested on anything higher yet.
ECHO.
ECHO If you have multiple accounts on the computer, you must this program on each one individually.
ECHO Once the program runs, copy the AIMBACK directory to your new computer
ECHO.
ECHO Note: This only applies to the current logged-in user.
ECHO Choose
ECHO 1) Backup Your AIM Profiles
ECHO 2) Restore Your AIM Profiles
ECHO 3) Exit

choice /c:123 /N

if errorlevel 3 GOTO end
if errorlevel 2 GOTO restore
if errorlevel 1 GOTO backup

:Backup
ECHO.
ECHO Backing up AIM profiles
xcopy "%APPDATA%\AIM\*" "%CD%\AIMBACK\%USERNAME%\profiles\" /s /i /q
IF %errorlevel% GEQ 1 ECHO AIM profiles were not properly backed up.
IF errorlevel 0 ECHO AIM profiles Backed up

ECHO.
ECHO Backing up AIM filelib (only if there is data)
xcopy "%userprofile%\My Documents\filelib\*" "%CD%\AIMBACK\%USERNAME%\filelib\" /s /i /q
ECHO.
ECHO.
IF %errorlevel% GEQ 1 ECHO AIM filelib were not properly backed up.
IF errorlevel 0 ECHO AIM filelib Backed up

ECHO.
ECHO Backing up Away messages and registry settings
REG EXPORT "HKCU\Software\America Online\AOL Instant Messenger (TM)\CurrentVersion\Users" "%CD%\AIMBACK\%USERNAME%.reg"
ECHO.
IF errorlevel 1 ECHO Registry Export Failed. Must be done manually
IF errorlevel 0 ECHO Registry export Succeeded.
ECHO.
ECHO Backing up DeadAim Logs (if they exist)
xcopy "%userprofile%\My Documents\aim logs\*" "%CD%\AIMBACK\%USERNAME%\aim logs\" /s /i /q
ECHO.
IF %errorlevel% GEQ 1 ECHO DeadAIM chat logs were not properly backed up.
IF errorlevel 0 ECHO DeadAIM chat logs Backed up
ECHO.
ECHO.
ECHO.
ECHO To back up other account's AIM settings, run this program from their account.

PAUSE

GOTO End

:restore
ECHO.
ECHO.
ECHO Avaialable usernames:
DIR "%CD%\AIMBACK\" /A:D /B
ECHO.
ECHO.
ECHO Please enter the username of the account you backed up AIM from.
Set /P account=

IF EXIST "%CD%\AIMBACK\%account%\" GOTO true ELSE GOTO false

:false
ECHO.
ECHO The username, %account%, was not found, or is invalid.
PAUSE
GOTO restore

:true
ECHO.
ECHO Terminating AIM process
taskkill /F /IM AIM.EXE
ECHO.
ECHO Restoring AIM profiles
xcopy "%CD%\AIMBACK\%account%\profiles\*" "%APPDATA%\AIM\"  /s /i /q
ECHO.
IF %errorlevel% GEQ 1 ECHO AIM profiles were not properly restored.
IF errorlevel 0 ECHO AIM profiles restored
ECHO.
ECHO Restoring AIM filelib
xcopy "%CD%\AIMBACK\%account%\filelib\*" "%userprofile%\My Documents\filelib\*"  /s /i /q
ECHO.
IF %errorlevel% GEQ 1 ECHO AIM filelib were not properly restored.
IF errorlevel 0 ECHO AIM filelib restored
ECHO.
ECHO Restoring Away messages and registry settings
REG IMPORT "%CD%\AIMBACK\%USERNAME%.reg"
ECHO.
IF errorlevel 1 ECHO Registry Export Failed. Must be done manually
IF errorlevel 0 ECHO Registry export Succeeded.
ECHO.
ECHO Restoring DeadAIM chat logs
xcopy "%CD%\AIMBACK\%USERNAME%\aim logs\*" "%userprofile%\My Documents\aim logs\" /s /i /q
ECHO.
IF %errorlevel% GEQ 1 ECHO AIM filelib were not properly restored.
IF errorlevel 0 ECHO AIM filelib restored

:end
pause
Exit






EDIT: CODE UPDATED
quantumAlpha
xcopy is part of all windows versions, you dont need to include that
choice isnt in XP i believe, hence your need to copy it. legally, though, you can't redistribute parts of MS software without their permission, so giving people copies of choice is against their eula

now, i dont use AIM, but you might wanna back up some other settings, like if they use DeadAIM, does that have separate settings? also, you might wanna note the version number of AIM that they're using, sometimes people dont like newer versions and refuse to upgrade, if you give them this info, they can track down the old version if/when they need to reinstall it


google.gif Search
Theres a bunch of programs that claim to pack BAT files inside EXEs, you could very easily write a VB program to do this yourself, or heck, use WinRAR's self extrator and have it set to execute the batch file on extract!

Edit: Spelling

Edit 2: Woot, 2001 posts!?! How'd i miss that one???
dkreifus
Actually, I was going to give a compatibility list for it. I wanted to make sure versions later than mine kept the same stuff.
I'm also gonna include the deadaim stuff. I was iffy on that.

As for xcopy...I wasn't 100% sure if it was included. I thought it was, but I couldnt check on any of the machines I access, cause I loaded a bunch of stuff on them. (choice, cdr, etc).

I want to pack it into a winrar self extractor. Could I somehow run choice from a temp folder? Maybe what I can do is have it check for the existence of choice. if its there, it won't do anything, and if its not there, it'll copy it, then fun, then delete it.
quantumAlpha
yeah, winrar would be be your best bet. just extract choice to the directory the batch file is located and then tell the batch to delete it when done (maybe the rarsfx can delete it too, idk)

you could have the rarsfx delete your batch script and everything else you packagae too so ppl arent given direct access to your script nor will it waste precious HDD space tongue.gif they can just run the sfx to run the program

Edit: Spelling, again
dkreifus
Hrm..I would have it delete the batch script, but not the folder, becuase the data is obviously stored there.

I could have it put the data in a separate folder on the C: drive...
quantumAlpha
yeah, i meant delete the files it extracts, not the data you're backing up tongue.gif
dkreifus
I might keep Xcopy in the file. If it is run on win2k, it may not have it. But I'm gonna add in a variable to delete those 2 programs after installing them.

Can Winrar delete the files automatically, or should I have that be part of the batch?

(i havent played with winrar in the compiling aspect)
quantumAlpha
hmm, i just took a peek a the rarsfx settings, i couldnt find anything, but there might be a command to type in the rar script manually, someone else might know...
dkreifus
1. I updated my code a bit.
2. I have to investigate how AOL has changed their AIM structure for files.
I know in the past they had the AIM95 folder. Obviously thats long dead, but if people never reformatted, it just kept updating that folder.

I'm even nervous to touch AIM triton or whatever. I hate that garbage.
quantumAlpha
oh, another thought, since you never CD out of the working directory, then just leave xcopy and choice in the working directory, no need to mess with win\sys32, some security-minded people like myself may find it a bit intrusive for a batch file to be putting files there

and i dont reccomend using taskkill/f. aim might not properly save some of its files when forcefully terminated like that (i know trillian doesnt sad.gif ) taskkill without /f should work fine, however (oh, important note, taskkill is NOT available on xpHome and probably not on win9x either, shame really, its a useful tool)

when restoring, if there was no previously restored data, the script could get stuck in a loop. maybe suggect to use ctrl-c if this happens or give them a prompt to quit, or simply check and see if there's any backed up data before even allowing restore as an option

you could also throw all the files into a .CAB or .ZIP (saves data and mft space, is neater, looks impressive). windows has the MakeCab.exe available in sys32 (aka diantz.exe, don't ask me about that one huh.gif)
dkreifus
I was considering using the zip function, and I agree with you about leaving the xcopy and choice in the %cd% folder. may make life easy. and then I can just put the data in a different folder if I really wanted.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.