0×80070005 error when trying to create Scheduled Task in Windows 2003

October 12th, 2009

When I was trying to set up a scheduled take in windows 2003, I kept getting this error: 80070005 access is denied

A lot of googling and I found the following things to try if you are having a similar issue:

Local Security policy Settings

1. Open your local security policy control panel:
Start -> Control Panel -> Administrative Tools -> Local Security Policy
2. go to the folder:
Security\Local Policies\Security Options
3. check the following permissions:
Interactive logon: Require Domain Controller authentication to unlock – set to Disabled
Network Access: Let everyone permissions apply to anonymous users – set to Enabled
Interactive Login: Message text for users attempting to log in – clear this setting

That last one creates a popup message that appears when users log into the computer. I found that this causes problems with some but not all of scheduled tasks.

File Permissiosn

Check the file and folder permissions of whatever script you are tying to execute. Make sure that the user you are trying to run the scheduled task as has Read and Execute permissions for the script.

If your script is a .bat file, make sure the user has Read and Execute permissions for cmd.exe

If your script is a .vbs. file, make sure that the user has Read and Execute permissions for cscript.exe

Too many permissions, try an unprivileged user

With older copies of windows it was fairly common practice to run all scheduled tasks as Administrator or some other type of super user. Security policies tend to be tighter now and are often set to restrict users with too much power as logging on in batch mode.

Create a new user who is a member of only the default Users group. Grant this user permissions on the folders you need to run your scheduled tasks. Keeping this user out of the Administrators group will make your server more secure and might clear up the Access Denied error.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

Stereoscopic camera

October 9th, 2009

Last month Gillian asked me to help her with an event that she had promised to shoot in 3D. I think I’ve gotten Gillian to adapt some of my “how hard could it be” attitude over the years.

After a ton of Googling, and realizing that that fancy Fuji3d camera wouldn’t be out in time. I decided to tether two Canon SD750’s using the plans described on this fine blog.

After getting all the parts I needed and set up, I chickened out when it came to soldiering wires directly to the internals of the camera. I am a little rusty with my soldiering and I had a 1 week deadline. If I ruined either of the cameras I wouldn’t be able to get another in time for the event.

Luckily, there is a whole community dedicated to exactly what I wanted to do and they had some simple solutions that didn’t require any permanent alterations to the cameras. A little bit of light soldiering and cutting and we were in business. The camera came out great and worked perfect for the event.

DSC00004.JPG

For the mount I used aluminum that I cut with a jigsaw and file, then riveted together. For the electronics all I needed was a few usb cables, an audio cable and jack, a momentary push button, and a 4 AA battery pack. All in all, it cost about $75 in parts – including the rivet gun. I already had 1 camera so the second one I got for $100 on ebay.

IMG_0672
IMG_0680
DSC09971
DSC00036_ps

Merging the photos taken was trivial with StereoPhoto Maker. An awesome piece of free software that I wish was open source so it could be ported to OSX, or better yet a CLI version.

Here is one of the images Gillian took that night. Any pair of red-blue glasses should work with it. You can see the whole gallery here. I have a few more shots from around the city on my Flickr stream.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

AS3 port of JZLib

June 8th, 2009

Last month I was working on a project that used FZip to decompress some zip files in flash.

One tricky thing about FZip is that when running in Flash Player it requires your zip files to have an adler32 checksum for each file in order to work. This is normally fixed with a work around python script provided with FZip.

The python script is easy and all, but why not figure out how to do it in pure AS3 with more standard zip files?

The checksum is needed because AS3’s ByteArray only supports ZLib when running in Flash Player. In AIR it supports deflate which is what zip files use by default. I would be really curious to hear from Adobe why they chose not to support deflate since you need deflate for Zlib to work anyway.

I decided to implement inflate in as3 but I didn’t want to do it with new code so I looked for FOSS projects to port. JZlib was a good choice because Java is similar to AS3 and it didn’t rely on any external system calls.

This port supports everything in JZlib so you can use it for any inflate or deflate operations you might need.

To use with FZip

I used this library in FZip so it no longer requires that zip files be converted before use. It is tested to be working with the OSX cli zip command. It doesn’t work with OSX finder zip compression because of another issue.

In FZipFile.as:

protected function parseContent(data:IDataInput):void {
	if(_compressionMethod === COMPRESSION_DEFLATED && !_encrypted) {
		if(HAS_INFLATE) {
			// Adobe Air supports inflate decompression.
			// If we got here, this is an Air application
			// and we can decompress without using the Adler32 hack
			// so we just write out the raw deflate compressed file
			data.readBytes(_content, 0, _sizeCompressed);
		} else if(_hasAdler32) {
			// Add zlib header
			// CMF (compression method and info)
			_content.writeByte(0x78);
			// FLG (compression level, preset dict, checkbits)
			var flg:uint = (~_deflateSpeedOption << 6) & 0xc0;
			flg += 31 - (((0x78 << 8) | flg) % 31);
			_content.writeByte(flg);
			// Add raw deflate-compressed file
			data.readBytes(_content, 2, _sizeCompressed);
			// Add adler32 checksum
			_content.position = _content.length;
			_content.writeUnsignedInt(_adler32);
		} else {
			data.readBytes(_content, 0, _sizeCompressed);
 
			//throw new Error("Adler32 checksum not found.");
		}
		isCompressed = true;
	} else if(_compressionMethod == COMPRESSION_NONE) {
		data.readBytes(_content, 0, _sizeCompressed);
		isCompressed = false;
	} else {
		throw new Error("Compression method " + _compressionMethod + " is not supported.");
	}
	_content.position = 0;
}
 
protected function uncompress():void {
	if(isCompressed && _content.length > 0) {
		_content.position = 0;
		if(HAS_INFLATE) {
			_content.uncompress.apply(_content, ["deflate"]);
		} else if(_hasAdler32) {
			_content.uncompress();
		} else {
			var uncompr:ByteArray = new ByteArray();
			var d_stream:ZStream=new ZStream();
			d_stream.next_in = _content;
			d_stream.next_in_index = 0;
			d_stream.next_out = uncompr;
			d_stream.next_out_index = 0;
			
			var err:int = d_stream.inflateInitWithNoWrap(true);
			while(d_stream.total_in <= _content.length && i<=_content.length*4) {
				d_stream.avail_in=d_stream.avail_out=10;
			
				err=d_stream.inflate(JZlib.Z_NO_FLUSH);
				if(err == JZlib.Z_STREAM_END) {
					System.println("decompress success:" + this.filename);
					break;
				} else if (err == JZlib.Z_STREAM_ERROR) {
					System.println("stream error:" + this.filename + " " + d_stream.msg);
					break;
				} else if (err == JZlib.Z_DATA_ERROR) {
					System.println("data error:" + this.filename + " " + d_stream.msg);
					break;
				//} else {
				//	System.println("status:" + this.filename + " " + err);
				}				
			}
			err=d_stream.inflateEnd();
 
			_content = uncompr;			
		}
		_content.position = 0;
		isCompressed = false;
	}
}

*** UPDATE 2/9/2010: Thanks to Kathrin Furtlehner for sending me a test case for a bug where it wasn’t extracting the full file when dealing with longer strings. I updated the patched FZip archive to reflect the fix.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

Fonts on the web – Part 1

May 31st, 2009

I’ve been reading and hearing a lot of rumbling lately from designers lately desperately looking for a better way to add fonts to their web design.

I feel that there is a lot of confusion in the design and web developer community as to what the issues are with font embedding or linking and when there isn’t confusion I often find myself on the opposite side of the debate and end up at a impasse with whoever I am talking with. In the past month I have found myself in this position more than once in person.

Last week I was posting a response on MildFuzz (link) and I realized that just debating the technical merits of the problem and proposed solutions isn’t going to get me anywhere. I set out to write a blog post to express my positions and beliefs and explain the technical problems to people but as I was writing I realized that there is just too much to dump into a single blog post.

My goal here is to write a long multi-part post that frames the technical issues, talks about proposed solutions, touches on the debates going on in the community, and offers my thoughts on a solution to the problem. This first post will just be an introduction.

first. About me:
I have been working as a professional web and application developer for 11 years now. Before that I did some type design and released several commercial and free fonts over at GrilledCheese.com. While the site may appear very very stale, I have been working for months now updating all of my typefaces and preparing them for a re-release. (Cleaning up glyphs that are over 10 years old and converting to OpenType is quite a chore, not to mention the 10 or so unfinished works I never released). I am most likely going to release most of my typefaces as Creative Commons licensed works or some hybrid commercial entity that I will talk about in a later article. Since I am now a professional programmer and not a designer I tend to look at things from more of a technical perspective and that will probably come through in this writing.

here is an outline of the posts I am working on

  • A brief history of type and fonts
  • The type industry compared to other creative works
  • Type on the web – methods and controversy
  • My proposed solution
Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

It’s better with windows

May 28th, 2009

Microsoft and Asus just launched a new site called It’s Better with Windows (link).

It's better with Windows

It's familiar
The basic premise of the site is that Windows is familiar and Linux is different and scary.

The marketing premise sounds reasonable but I think the problems with Microsoft is that they actually believe it. They believe that consumers would rather have something familiar than have something better.

I’m not saying Linux on a netbook is better than Windows. I am saying though that I think this “familiar” argument is what caused Microsoft to be totally blindsided in the mobile space in the past few years.

“It’s familiar” was their primary selling point for why you should buy Windows Mobile and not Palm. Palm fell flat on it’s face a few years later, but not because all the users were finally convinced that the Microsoft UI paradigm was superior. As MS tends to do, once they because the dominant player in the space, they completely stopped trying to improve their product.

Microsoft: People aren’t as loyal to the start menu as you think. The lower cost the device the more true this is.

When Apple and then Google came around with their mobile offerings, they had a UI that was totally unfamiliar to everyone, but substantially better. Now Microsoft is caught playing catch up. They are just now coming to grips with the fact that the Windows Start Menu and tiny icons isn’t how people want to interact with their phone or PDA.

Microsoft should be making a custom version of windows with a netbook centric UI that takes advantage of the small screen and stop trying to cram windows into everything. It is only a matter of time before Apple and Google release netbooks and leave them wondering why people aren’t yearning for a start menu and taskbar.

It's familiar
Another side note, the secondary argument they are making, is that “Windows has better device support than any other platform” is just absurd. Anyone that has plugged in an older or a newer printer or scanner into a Windows computer knows that more often than not the computer doesn’t know what the hell to do with it. At this point, OSX tends to recognize way more devices and know exactly what to do with them way better than Windows.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

Moving from Tomcat 6 to Jboss AS5 – notes

May 18th, 2009

I’m moving a bunch of single WAR sites from Tomcat 6 to Jboss AS5. Here are the configuration steps that need to be taken.

Assuming this is your tomcat config file:
%TOMCAT_HOME%/conf/server.xml:

<Host appBase="/home/wirelust/wirelust.com" autoDeploy="false"
     debug="0" deployXML="true" liveDeploy="true"
     name="domainname.com"
     unpackWARs="true">
 
    <Alias>www.wirelust.com</Alias>
 
     <Context cachingAllowed="true" cookies="true" crossContext="true" debug="0"
             displayName="wirelust" docBase="." path="" privileged="false"
             reloadable="true" swallowOutput="false" useNaming="true">
             <Resource auth="SERVLET" name="wirelustDatasource" scope="Shareable" type="javax.sql.DataSource"
                     username="username"
                     password="password"
                     driverClassName="net.sourceforge.jtds.jdbc.Driver"
                     url="jdbc:jtds:sqlserver://sql.wirelust.com/database"
                     removeAbandoned="true"
                     removeAbandonedTimeout="30"
                     logAbandoned="true"
             />
     </Context>
</Host>

Becomes the embedded tomcat config file:
%JBOSS_HOME%/server/default/deploy/jbossweb.sar/server.xml

<Host appBase="/home/wirelust/deploy/wirelust.com.war" autoDeploy="false"
     debug="0" deployXML="true" liveDeploy="true"
     name="domainname.com"
     unpackWARs="true">
 
    <Alias>www.wirelust.com</Alias>
</Host>

Notice that the appBase is now in a folder called “deploy”. You have to add this deploy folder to the config file:
%JBOSS_HOME%/server/default/conf/bootstrap/profile.xml

<bean name="BootstrapProfileFactory" class="org.jboss.system.server.profileservice.repository.StaticProfileFactory">
    <property name="bootstrapURI">${jboss.server.home.url}conf/jboss-service.xml</property>
    <property name="deployersURI">${jboss.server.home.url}deployers</property>
    <property name="applicationURIs">
        <list elementClass="java.net.URI">
            <value>${jboss.server.home.url}deploy</value>
 
            <value>file:/home/wirelust/deploy</value>
        </list>
    </property>
    <property name="attachmentStoreRoot">${jboss.server.data.dir}/attachments</property>
    <property name="profileFactory"><inject bean="ProfileFactory" /></property>
</bean>

Make sure your exploded directory ends in .war or jboss won’t see it.

Then in that new deploy directory, create a datasource file, in this case called “wirelust-ds.xml” with these contents:

<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE datasources
    PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<datasources>
    <local-tx-datasource>
        <jndi-name>wirelustDatasource</jndi-name>
        <connection-url>jdbc:jtds:sqlserver://sql.wirelust.com/wirelust</connection-url>
        <use-java-context>false</use-java-context>
        <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
        <user-name>username</user-name>
        <password>password</password>
 
        <Pool.LogAbandoned>false</Pool.LogAbandoned>
        <Pool.RemoveAbandoned>false</Pool.RemoveAbandoned>
        <Pool.RemoveAbandonedTimeout>50000</Pool.RemoveAbandonedTimeout>
   </local-tx-datasource>
</datasources>

In order to bind to the correct virtual host, you have to create a new file in your exploded WEB-INF directory called jboss-web.xml with these contents:

<!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 4.2//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
 
<jboss-web>  
    <context-root>/</context-root>  
    <virtual-host>wirelust.com</virtual-host>
</jboss-web>

Then the last change you have to make is how you are looking up your datasource in the application.
If you have code like this in your tomcat application it will fail because your jndi is not bound to java:comp/env:

Context ctx = new InitialContext();
Context envCtx = (Context) ctx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("wirelustDatasource");
con = ds.getConnection();

This of course can be fixed with some further configuration and resource-ref settings but I couldn’t get that to work so I just changed the code to work either way:

Context ctx = null;
Context envCtx = null;
DataSource ds = null;
Connection con = null;
 
try {
	ctx = new InitialContext();
} catch (NamingException e) {
	e.printStackTrace();
}
 
if (ctx != null) {
	try {
		// look for the datasource in the tomcat location
		envCtx = (Context) ctx.lookup("java:comp/env");
		ds = (DataSource)envCtx.lookup("wirelustDatasource");
	} catch (javax.naming.NameNotFoundException nnfe) {
		try {
			// look for it in the jboss location
			ds = (DataSource)ctx.lookup(wirelustDatasource);
		} catch (Exception e) {
			e.printStackTrace();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
 
// open the connection
if (ds != null) {
	try {
		con = ds.getConnection();
	} catch (Exception e) {
		e.printStackTrace();
	}
}

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

Converting binary to signed decimal in Actionscript

April 8th, 2009

If you’re like me, you may have been living these past few years taking advantage of the luxury of new sleek programming languages that rarely require you to do low level operations. One of the old skills I seem to always let get rusty enough is bitwise operation. Most code written with the help of frameworks doesn’t require this type of code and most programmers probably don’t even bother to learn it anymore.

I came into an instance yesterday where I needed to do some bitwise work in actionscript. The code was reading a bytestream from a binary file and converting to an array of numbers. Since this project was ported from Java (by someone else), a simple operation was overlooked. It was taking the binary number and converting it to a signed short. Since actionscript doesn’t have the same casting mechanisms conversion isn’t as straight forward in java.

In java the operation looked like this:

//  binary: 1111 1111 1111 0001
int hexValue = 0xFFF1;
 
short value = (short)(hexValue);
// value = -15 

Since short in java is always stored with a signed bit, the cast appropriately set the value at -15.

The way this was translated into Actionscript looked liked this:

//  binary: 1111 1111 1111 0001
var hexValue:int = 0xFFF1;
 
var value:int = int(hexValue);
// value = 65521  // Wrong! 

Actionscript has no concept of casting for primitives so the int(hexValue) doesn’t do anything at all.

Here is the workaround I came up with, I suspect there is a shorter way to get the same result but I can’t think of one right now.

//  binary: 1111 1111 1111 0001
var hexValue:int = 0xFFF1;
 
// get everything except the signed bit "111 1111 1111 0001"
var unsignedValue:Number = (hexValue & 0x7FFF);  
// unsignedValue now equals 32,753
 
var signedValue:Number = unsignedValue;
 
// if the signed flag is set, flip the value
if ((hexValue >> 15) == 1) {
    signedValue = unsignedValue - 0x8000;   // 0x800 =  32,768 (maximum 15 bit number)
}
 
// signedValue = -15 

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

Picture Pump

April 6th, 2009

About five years ago Ben Sisto had an idea for an application that I thought would be useful. The idea being that if you want to download images from Google image search — it takes forever to go through the results, wait for them to load, and save the images that aren’t 404. The application Ben envisioned, would simply download every result and ignore the ones that were 404 or took too long to load. Once you have all the results on your hard drive it is a lot easier to sift through them.

I quickly banged out a release that was workable in a few days and never really looked at it again.

This week I had an exact need for this application again. When I fired it up, it seems Google changed their site so it wasn’t working anymore. I spent some time tonight to fix it up and got it working much better than the original.

So here it is. v1.0 (i guess) release of Picture Pump (named after the site Ben ran at the time – HoneyPump):

Click launch to start/install the application. OSX users should be all set, windows users you might have to get java first.

also, hey look. source code

Email me with any suggestions or patches.

UPDATE: 10/24/2009
- fixed my mime settings so that launch button works again (sorry moved servers and forgot to set it)
- fixed a few bugs
- added support for safe search
- added filtering by image type and license
- source code is now under the Apache Public 2.0

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

Font Reader

April 2nd, 2009

I’ve been doing some work with Five3D lately. I extended it so I could render text with proper kerning pairs. I hit a bit of a wall though with converting my fonts to as3 since the way Mathieu does it doesn’t lend itself well to getting kerning pairs from flash itself.

Looking for an alternative, I started taking a look at Font Reader which is a port of a project called Typecast I saw a few years back.

Anyway. Long story short, I’ve been up all night playing around with and extending Font Reader (for my current project, but also because it’s fun to play with).

The version that is posted on the site uses a custom written path renderer which seems to have some bugs. In particular it seems to clip at the end of a logical path segment.

The custom objects were very close to the new stuff in the Flex 4 gumbo stuff from Adobe, so I was able to easily swap them out and use the Adobe classes instead. Since that was so easy, I started working on getting editable point handles so I can start editing the paths within the application. I have this about 75% done, but I can’t help quell that feeling that there must be a reusable class out there someone else wrote. Anyone know of one?

Here’s a screen shot of my current working build for comparison:

If I get this working by next week, I’ll post the code.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter

Howto set the cookie policy with Apache http client 4.0

March 29th, 2009

The Apache Http Components client changed quite a bit from 3.0 to 4.0 beta. It wasn’t entirely clear to me from the documentation how to set request headers and cookie policies with the new client. After a lot of fishing around I was able to figure it out, here is the code for anyone trying to do the same thing.

Downloading a page with the 3.0 client:

HttpClient httpClient = new HttpClient();
 
GetMethod get = new GetMethod("http://www.twitter.com/teacurran");
 
// set a faux User-agent
get.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)");
 
// set the cookie policy
get.getParams().setCookiePolicy(CookiePolicy.RFC_2109);
 
int responseCode = httpClient.executeMethod(get);
System.out.println(get.getResponseBody());
 
get.releaseConnection();

here is the same thing with the 4.0 client:

DefaultHttpClient httpClient = new DefaultHttpClient();
 
HttpGet get = new HttpGet("http://www.twitter.com/teacurran");
 
// set a faux User-agent
get.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)");
 
// set the cookie policy
get.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965);
 
HttpResponse response = httpClient.execute(get);
 
int responseCode = int code = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
 
System.out.println(EntityUtils.toString(entity));

Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Slashdot
  • Tumblr
  • Twitter