My Blog

contains PHP and other web related content. (Sometimes there are some off topic things - don't freak out!)

Archive for the ‘windows’ Category

How desktop.ini saved me from myself

Tuesday, October 7th, 2008

When working at “the triangle” we used junction points on windows to link to repositories that we needed to run the code base – but weren’t necessary for the project. (see creating junction points on windows with linkd.exe.)

The problem I ran into was thinking I could delete my whole folder with all of the repositories after the project was done. Unfortunately, because they were junction points, they would also delete the source of the links.

Next, I decided that I should delete each folder individually. However, I kept forgetting which were junction points and which were real folders. Unfortunately, windows did not automatically distinguish real folders from junction points.

Finally, I found out about desktop.ini – and how I could use it to my advantage. I ended up creating a desktop.ini file inside of each of my real folders and changing the icons to something else. This way, I would know that they were real folders and not junction points. This worked great and kept me from deleting junction points ever again.

Microsoft is pretty close lipped on their msdn link above – so I found this to be a better resource: Peatsoft desktop.ini reference.

Automatic Backup with SVN on Windows

Friday, September 12th, 2008

A while ago, I decided that I needed to have a better backup solution for my file server. After doing some research on various systems, I let my inner programmer take over – in addition to my desire to NEVER LOSE ANYTHING – and I defaulted to use SVN.

I was using a Windows machine as my file server – so I wrote some batch files. I also had SVN installed on the machine. The final touch was adding scheduled tasks.

The setup includes a computer that is always on with windows, svn command line, and 5 directories to monitor for backups.

First thing’s first, do an SVN Checkout

The very first thing I did was make an SVN checkout in all of the five parent directories. This way I can continue to use SVN add, svn commit without any other interaction. Don’t worry, we’ll use recursion!

Create the full list of backups

So, first thing’s first: Create the list of directories that need to be monitored. I made them in this txt file named ‘svndirectories.txt’:

1
D:\pictures D:\storage\videos\misc D:\storage\files\art D:\storage\files\NeverAgain D:\storage\files\Therapee

Note, all of them are separated by a space. This becomes important in our next batch script.

Schedule the SVN Add

I added an SVN Add batch script at Midnight on sundays. Actually, there are two batch files. I made them separately so that I could invoke a scheduled task – but also run the “add” by hand if need be.

The first file, addsvn.bat:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@echo off

REM ------------------------------------------------------------------
REM - forces adds on all svn files
REM ------------------------------------------------------------------
 
 
:START
REM - Get file to process
set direct=%1
echo %direct%
echo.
 
:SVNADD
svn add --force %direct%\*
 
:NEXTFILE
shift
if "%1"=="" goto END
goto START
 
 
:END

That will force an add of each file passed in on the command line. Then, the batch file that I made to be ran from the scheduler will read in the folders from the text file, and run this script. Here is ‘scheduled_addsvn.bat’:

1
2
3
4
5
6
7
8
@echo off
REM - This is what should be scheduled to add files to svn repos

REM - read in svndirectories.txt
for /f "tokens=*" %%a in ('type svndirectories.txt 2^>NUL') do set value=%%a

REM - call the addsvn program with all the directories
addsvn %value%

Theoretically, I could have called it with the entire line of files after it, but I wanted to call them separately to handle errors better.

After all of these have been added, lets move on…

Schedule SVN Commit

Just in case I made a huge addition of files, I let an hour pass between scheduled add and scheduled commits. Additionally, I ran the commit every day instead of every week. I figured I’d make more changes than I would make additions.

So first, read in all of the directories again and run the commit. Then, the file to schedule. These are pretty much similar, just different commands:

commitsvn.bat:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@echo off

REM ------------------------------------------------------------------
REM - commits all SVN changes
REM ------------------------------------------------------------------
 
 
:START
REM - Get file to process
set direct=%1
echo %direct%
echo.
 
:SVNCOMMIT
svn commit --message="Auto Backup" %direct%\*
 
:NEXTFILE
shift
if "%1"=="" goto END
goto START
 
 
:END

scheduled_commitsvn.bat:

1
2
3
4
5
6
7
8
@echo off
REM - This is what should be scheduled to commit files to svn repos

REM - read in svndirectories.txt
for /f "tokens=*" %%a in ('type svndirectories.txt 2^>NUL') do set value=%%a

REM - call the addsvn program with all the directories
commitsvn %value%

This has worked out pretty well for me. If you see anything I could do better, please let me know!

Convert from VMWare Player to VMWare Server

Tuesday, September 2nd, 2008

At superdev, we have a distribution of a gentoo image made with vmware workstation. This works fine in vmware player – but not the free vmware server – and I wanted to have vmware server running so I could have more than one server running on my windows laptop. Well, there are two small simple edits I had to do – and it was all good.

First of all, I grabbed my favorite free hex editor and evilly smiled. Open XVI32.

Second, edit the file named VirtualMachineName.vmx. Replace the virtualHW.version = “6″ with virtualHW.version = “4″. SAVE.

Finally, edit the file named VirtualMachineName.vmxd. If you have more than one (like -1, -2, use the one without the suffix. Those are the data files, the vmxd is the config). Once again, replace the virtualHW.version = “6″ with virtualHW.version = “4″. SAVE.

Other things I ran into…
For whatever reason, my eth0 turned into eth1 once I transferred. So I had to do that modification. (Also, my dhcp on my network stopped responding to the vm, but I changed it to NAT anyway – because I wanted it as a local connection anyways.)

Dig for Windows

Friday, May 30th, 2008

For those of us who develop on windows, we can sometimes feel linux tool envy. One particular tool is the ‘dig’ command. Well, luckily, you can get this to run on windows easily:

Download Bind from ISC

Visit the www.isc.org/sw/bind/index.php download page to download the Windows binary version.

Create folder and Extract necessary Files

Create a folder called ‘dig’ – or just push all the dlls and exe’s into your windows/system32 folder. Extract the following:

dig.exe
libbind9.dll
libdns.dll
libisc.dll
libisccfg.dll
liblwres.dll

Run Dig

c:\>dig

; <<>> DiG 9.4.2 <<>>
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 752
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 12

;; QUESTION SECTION:
;.                              IN      NS

;; ANSWER SECTION:
.                       4060    IN      NS      e.root-servers.net.
.                       4060    IN      NS      b.root-servers.net.
.                       4060    IN      NS      f.root-servers.net.
.                       4060    IN      NS      a.root-servers.net.
.                       4060    IN      NS      c.root-servers.net.
.                       4060    IN      NS      i.root-servers.net.
.                       4060    IN      NS      g.root-servers.net.
.                       4060    IN      NS      h.root-servers.net.
.                       4060    IN      NS      m.root-servers.net.
.                       4060    IN      NS      d.root-servers.net.
.                       4060    IN      NS      k.root-servers.net.
.                       4060    IN      NS      l.root-servers.net.
.                       4060    IN      NS      j.root-servers.net.

;; ADDITIONAL SECTION:
e.root-servers.net.     71529   IN      A       192.203.230.10
b.root-servers.net.     71529   IN      A       192.228.79.201
f.root-servers.net.     85723   IN      A       192.5.5.241
a.root-servers.net.     85723   IN      A       198.41.0.4
c.root-servers.net.     71529   IN      A       192.33.4.12
i.root-servers.net.     71529   IN      A       192.36.148.17
g.root-servers.net.     71529   IN      A       192.112.36.4
h.root-servers.net.     71529   IN      A       128.63.2.53
m.root-servers.net.     25212   IN      A       202.12.27.33
d.root-servers.net.     71529   IN      A       128.8.10.90
k.root-servers.net.     85723   IN      A       193.0.14.129
j.root-servers.net.     85723   IN      A       192.58.128.30

;; Query time: 15 msec
;; SERVER: 10.30.12.26#53(10.30.12.26)
;; WHEN: Tue May 27 10:49:05 2008
;; MSG SIZE  rcvd: 433

Yay!

Thanks to Todd Keup @ magnifisites for this tip.

XDebug and Eclipse PDT on Windows – From Start to Finish

Tuesday, May 20th, 2008

XDebug and Eclipse PDT on Windows – From Start to Finish

With our recent upgrade to php at “the triangle,” I felt it was time to start working on using a debugging and code profiling tool. When I say felt like it was time… I meant our PHP version finally supported it. *sigh*. Anyway, from start to finish, this is what I did in order to get Xdebug to integrate into my current eclipse PDT – as well as investigate the other features of xdebug. I tried to detail all of the mistakes I made as well as what I figured out. Let’s go:

(more…)

Use MySQL Gui tools to securely connect to remote database

Saturday, October 27th, 2007

This particular example is going to be based on a connection from Windows XP using Putty, MySQL GUI tools and Dreamhost.

Quick summary of issue: I want to use MySQL Query Browser to access my database on my dreamhost account. The database allows connections from the webserver only – nothing external. I have an SSH account on the webserver.

Quick answer: This requires us to tunnel from our machine to the webserver and connect through this tunnel to the database server.

Lets take a look on how we can accomplish this:

(more…)

Add Event Viewer to My Computer Right-Click

Wednesday, September 19th, 2007

Just wanted to note this awesome registry change that you could apply to get a right-click menu on my computer that allows direct access to the event viewer in windows xp.

eventviewer.reg

Windows Registry Editor Version 5.00

;Adds Add/Remove to right click of MY Computer
[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\shell\Event Viewer\command]
@="eventvwr"

Force Log Messages using Tortoise SVN

Wednesday, July 25th, 2007

Everyone knows that standard SVN has its list of 6 or 8 standard hooks – but what if you’re 1) lazy, 2) busy, 3) don’t have access to the SVN server? Using one of the popular win32 shell integrated svn clients, TortoiseSVN, we can still force commit log messages easily:

(more…)

Symbolic Linking in Windows?

Saturday, July 21st, 2007

Be careful! Those of you who are trying to emulate a symbolic link in windows have probably come across the Windows Resource Kit tool linkd.exe. This creates junction points on the file system. However, before you have to find out the hard way, here’s my reminder… junction points are more akin to hardlinks than symbolic links: if you delete a junction point, it deletes the target as well!

Execute Windows Commands from PHP without blocking

Saturday, July 21st, 2007

When researching for my live error reporting posting, I tried running some exec and passthru command tests by starting up calc.exe. While they executed the command correctly, I got some weird results in my script … which I suppose now make sense. Lets see how we can start programs in Windows, and not run into the same issues that I did.

(more…)

  • twitter loader

Follow me on twitter: @aaronsaray

The views on this website are my own and do not reflect the opinions of my employer or clients.
Creative Commons License Home | Open Source | Book | Music | Art | Bio | Resume | Contact
My Baby