Showing posts with label winxp. Show all posts
Showing posts with label winxp. Show all posts

Thursday, 4 December 2008

mysql database copy

problem: its always good to have a dev version of any working database for learning purposes...

what im not doing: going all 'gui'... the command line rox and it all starts there


this is surprisingly difficult with my set-up. xampplite setup on a xppro box (its my work setup, dont judge me)! in the end i had to do the following;

create database test;

then export my production database to file via phpMyAdmin, .sql

then i seemed to hit a brick wall. found posts that advised adding 'use test;' at the top of the file then issuing the following command;

mysql < c:/backup.sql;

wouldnt work. tried;

mysql -u root -p ***** < c:/backup.sql;

no good :(

but then, almost as a last gasp;

use test;
source c:/backup.sql;

job done! always remember '\' escapes in mysql so windows absolute paths are initially annoying!

Thursday, 18 September 2008

recursive for loops

problem: for example, reading a text file input, searching for the entry in a database and outputting specified csv's

what im not doing: hitting this with vbs, because vbs is only for when batch cant do it


try it, recursive for loops arent supported in winxp cmd / batch files, but here is a wee workaround

for /f %%a in (list.csv) do call :list %%a
:list
if not %1'==' for /f "tokens=1-5* delims=," %%a in ('findstr /i %1 db') do echo %%~c,%%~d,%%~e >> summary.csv

save the batch and watch it recurse!

Thursday, 1 May 2008

xp show / hide login

problem: a friend and his family have just got their pc back from re-installation and wish to have everyones login reduced to limited user

what im not doing: disabling the graphical login screen


this instance applies specifically to xphome, but can translate to pro dependent on its applied use. as you no doubt know, winxp home requires at least one user account with admin rights in addition to the existing administrator account, which can only log on in safe mode. the idea is to setup an account with admin rights, hide it from the graphical logon screen and leave all additional users as 'limited users'. this situation isnt really scalable as adding any additional users and basic admin right dependent tasks cannot be performed from user only accounts, but my friend was ok with this.

so, create your user scheme then, as a member of admin navigate to

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList

create a dword named the account name that you wish to hide, and assign the hex value '0'. if you need to log in under this account, 'ctrl-alt-del' x2 at the glogin screen and enter your credentials. easy!

Wednesday, 12 March 2008

more batch goodness!

problem: app generated csv encases entries with double quotes, we want the double quotes removed... please!

what im not doing: using wsh (the client googled and suggested that i use vbs, looking nervous as they obviously didnt know what this meant).

start at the start, batch as always (i hate myself);

for /f "tokens=1* delims=," %a in (foo.sv) do echo %~a,%~b >> bar.csv

kinda easy!

Tuesday, 4 March 2008

winxppro startup issue (panic panic panic)

problem: client pc starts-up to desktop (almost) and displays 'services.exe unable to start, some dll missing, blah, blah, reinstall, etc' inciting real panic and confusion... restarting the machine boots to blue screen (for a second) then restarts (as is the default setting). talk of a brand new pc ensues as i stroll into the office...

what im not doing: agreeing with a new purchase and blagging the pc, i mean i have a soul (and i think its still under warranty, so i would be filling in forms and making calls... no) also, stating the obvious, this isnt a trick or anything new, im just tracking problems and fixes.


boot of xppro cd, enter recovery console and enter the mighty;

chkdsk c: /r

and restart. job done.


thoughts - my linux distro of choice runs a similar tool every 30 mounts, winxppro would benefit from such pragmatic steps.

Monday, 3 March 2008

batch magic!

problem: client has a generated csv of months credit notes issued, each item credited should be (but sometimes not due to human error) flagged as damaged, quality issue, shortage, not-as-ordered or error (*d*, *q*, *s*, *nao*, *e*). a summary of each catergory should be generated for that month. during the brief i offered a futher category of 'misc' for items not flagged and was hailed as the hero i am (for a short while).

what im not doing: playing football tonight probably... it has snowed!

batch solves the above, toffee!

setlocal enabledelayedexpansion
copy foo.csv cred.csv
set foo=foo
for %%a in (d,q,nao,s,e) do (
type !foo!.csv find /i "*%%a*" >> %%a.csv
type !foo!.csv find /i /v "*%%a*" >> "%%a%%a.csv"
del !foo!.csv
set foo=%%a%%a
)
rename ee.csv misc.csv

notes on the 'cdrill.bat'
name the initial file 'foo.csv'
need setlocal or the variable expands to 'e' instantly
piping output of type for tidyness (no ----- blah.csv at head of file as when 'find' is used), pipe doesnt seem to show up in post

Wednesday, 27 February 2008

which image?

problem: i have been supplied a cd containing images of products (404 images) and need to copy images matching keywords for further processing.

what i am not doing: clicking through this cd via explorer for 4 hours


normally these images are supplied named by supplier code but this particular one has a brief description as image names. keywords are;

Gleneagles
Edinburgh
Newbury
York
New York
Homestead
Sunset
Devon

now, im not using xcopy as i dont really want a copy of the dir structure (there are a few on the cd) on my target, so;

for /f "tokens=*" %a in ('dir /s /b *glen*.jpg,*edin*.jpg,*bury*.jpg,*york*.jpg,*home*stead*.jpg,*sun*set*.jpg,*devon*.jpg') do copy "%a" "%userprofile%\desktop\%~na.jpg"

and i am down to 79 images, all of which are relevant to this project.