Saturday, June 14, 2008

Scheduled Tasks Error - "0x80070005: Access is denied."

For some reason Microsoft chose to throw the following error rather than explain itself:
An error has occurred while attempting to set task account information.
The specific error is:
0x80070005: Access is denied.
You do not have permission to perform the requested operation.

Of course, this seems like some deep, dark security setting or registry modification at first reading. Then, after multiple internet searches you may be led to a similar conclusion. However after digging deep I found the following Google discussion in which the questioner discovered the solution on her own -> Backup Task Scheduler Error 0x80070005: Access is denied.

So here's the deal:
PROBLEM: I'm trying to schedule a task that wakes the computer, logs on, and runs at a scheduled time. However, when it asks me for a password (see picture below), I just hit "OK" since I don't have my computer's password enabled. Then it gives me the above error.


SOLUTION: Reopen the scheduled task and check the box titled "Run only if logged on" (see picture below). You'll find this in the bottom left side of the window.


That should do it.

Note that if you do have a password enabled, all bets are off. You'll simply input your password and uncheck the "Run only if logged on" box. This way the task will log on using the password you enter in the box two pictures above in this post. I do remember having an issue with this in the past, but can't remember what it was or how to solve it.


Good evening

Donald W. Hasson
http://www.linkedin.com/in/donaldhasson
http://donaldhasson.blogspot.com

Tuesday, December 05, 2006

Microsoft Excel Visual Basic Functions

Here's how to create custom Excel functions.

I finally broke down and wrote my own function for root mean square (RMS). This is an extremely common statistical function that Excel (2003 in my case) does not have. Usually I just type the following code

=SQRT(SUMSQ(A:A)/COUNT(A:A))

I figured writing this function would be very simple. It wasn't too hard but was not very intuitive for someone who had never done it before. So here's how it's done.

Phase 1 - Write Function

1. Go to Tools > Macro > Visual Basic Editor; or press ALT+F11.
2. Once in the Microsoft Visual Basic window got to Insert > Module.
3. In the Module window, type the code for your function. For example, here is my simple function:

Function RMS(values)
'
' This computes the root mean square of entered values
'
RMS = Sqr(WorksheetFunction.SumSq(values) / WorksheetFunction.Count(values))
End Function
"Function" tells VBA it's not a subroutine or macro. "RMS" is the name of the function and you must end the function with the function name being equal to desired output value. For me it was just one simple line. The reason I have words and periods (library names) before the Excel normal Excel functions I used is discussed below. "End Function" is auto-generated by VBA. Also, comments are any text after the apostrophe (') on a line. I have three comment lines that I used to make thing look clean and describe my function a bit.

Phase 2 - Saving as Add-In

Note: Follow these steps only if you want your new function in a new custom add-in. If you want your function in one of the add-ins you previously made, simply drag your new module into the modules folder of your existing add-in project (mine is called "VBAProject (Donald Add-Ins.xls)". The projects are in the "projects" window which can be viewed by View > Project Explorer (or CTRL+R).

1. Go to File > Save (where is the name of your spreadsheet file); or press CTRL+S
2. Click the "Save as type:" drop down and select "Microsoft Office Excel Add-In (*.xla)".
3. You will be directed to your computer's "AddIns" folder. Simply type a descriptive name for your custom add-in functions (i.e. "Donald Add-Ins").

Interestingly enough you will not see your new add-in project directory structure in the Project Explorer window until after the new add-in is actaully "added in". You don't have to worry since it will be there when you go back to Excel. If, however, you'd like to see it leave VBA open go back to Excel and follow the below steps. When you're done, go back to VBA and you'll see it.

Phase 3 - Selecting the Add-In and Using the New Function

1. Go to Tools > Add-ins...
2. Check the box to the left of your new add-in, then click OK
3. To use the function simply type its name as you would any normal Excel function with the values in parentheses (i.e. RMS(A:A) was my function).

A couple other things I struggled with in writing the function:

1. You can't type functions in VBA exactly as you would in Excel. To see available function go to View > Object Browser (or press F2). You can do some basic searches, but it's not perfect. For example, you won't find SQRT (the square root function) in the search. But an internet search helped me find the Excel's SQRT is VBA's SQR (no idea why they did that - but Math details are here: http://msdn2.microsoft.com/en-us/library/thc0a116.aspx). Otherwise I was able to find COUNT in the Object Browser search just fine.
2. You must tell VBA from which library to pull the object you're specifying. If you don't you see this error "Compile Error: Sub or Function not defined".

click below picture to enlarge...


You can find the libraries for the objects in the above-mentioned Object Browser. Find your object then click on it and the library will be at the bottom. For example,

Function Sqr(Number As Double) As Double
-> Member of VBA.Math <- or Function SumSq(...) As Double -> Member of Excel.WorksheetFunction <-

So you know that SQR is a member of the "Math" libray. However, since that library is already in VBA it will be recognized simply by "Sqr" without a library declaration. However for the SumSq function you need to tell VBA where this library is since it's an Excel library. The way you tell VBA this information is when using the object in your function simply type the name of the library before the name of the object with a period in between (i.e. WorksheetFunction.SumSq()).



Here is a good website on building functions and add-ins. It may be more helpful than my directions:

http://www.fontstuff.com/vba/vbatut03.htm

Some other good discussions:
http://www.eng-tips.com/viewthread.cfm?qid=91843&page=9
http://www.vertex42.com/ExcelArticles/user-defined-functions.html
http://office.microsoft.com/en-us/excel/HA010548461033.aspx?pid=CL100570551033

Thursday, October 12, 2006

PERL - Convert Space Delimited to Comma Delimited

Here's some PERL code to convert a list of space-separated or space-delimited variables to comma-separated variables (CSV) or comma-delimited variables.

use strict;

my $indata = $ARGV[0]; # Load a file name from the command line

system "copy $indata $indata-orig"; # Tell DOS to make a copy of file

open(DATA, "<$indata") or die "Couldn't open $indata for reading:$!\n"; my $outdata = "$indata-"; open(OUT, ">$outdata")
or die "Couldn't open $outdata for reading:$!\n";

my @array;

while (<DATA>) # Read the incoming data line by line
{
s/^\s+//; # replace the 1st space with blank (delete first space)
s/(\n)+//; # delete newline at end (probably didn't need to do like this
s/l//i; # for my data I needed to get rid of an "L" in the data
s/(\s)+/,/g; # replace all groups of spaces with a comma

@array = split (',',$_); # Now put each record from the current line into an array
print OUT (join (",", $array[0], $array[1], $array[2], $array[4], $array[6]), "\n"); # then print this array with just the data you want to your output file

# You probably won't have to do the last 2 steps the way I have them. I needed to only bring out a few of the columns. You can just print $_ (which, in PERL, is the most recently affected variable) to your output file.
}
close (DATA) or die "could close $indata: $!\n";
close (OUT) or die "could close $outdata: $!\n";

# I wanted to get rid of junk files and rename my new file the the original filename. You don't have to do this either.
system "del $indata";
system "rename $outdata $indata"
If you have questions, just send me a comment and I'll be glad to answer if I can.

Good afternoon

Donald W. Hasson
http://www.linkedin.com/in/DonaldHasson
http://DonaldHasson.blogspot.com

Monday, October 09, 2006

PERL - Bad File Descriptor

This is an easy one.

I got the error "Couldn't close 0.opt file: Bad file descriptor". As you may know the first part is my language and the part after the colon is the PERL error message "Bad file descriptor". There were a couple of other suggestions for what may be causing this and I've listed their discussion links below. But for me the problem was simply that I had closed the file already in another subroutine. For some reason PERL does not respond with "File already closed" as would be logical.

By the way, I'm on Windows XP using ActivePERL 5.8.8.817.

Other possibly useful links:
http://www.webmasterworld.com/forum13/4039.htm - Bad directory location
http://www.velocityreviews.com/forums/t26003-why-quotbad-file-descriptorquot.html - Bad zip file or non-zip file
http://coding.derkeiler.com/Archive/Perl/perl.beginners/2004-01/1301.html - Troubleshooting suggestions

It also could have to do with permissions on the file.

Good evening

Donald W. Hasson
http://www.linkedin.com/in/DonaldHasson
http://DonaldHasson.blogspot.com

Friday, September 29, 2006

Making a Blog Work For You

As I work through creation of my new blog I realize I am coming to many more crossroads than I planned. If it were simply a "brain dump" it may offer some value in getting your thoughts on a screen, but it would soon become a disorganized mess with no purpose and a waste of time (at least long term). How careful should I be with what I say? I plan to use this to promote myself to future (and current) employers and folks with whom I would like to network (for a variety of reasons). Therefore, I want them to know the true Donald Hasson, but not to be turned away by words taken out of context, without understanding my tone, by not understanding my whole life or why I am saying such and such or whatever.

A big thing that I'm starting to realize is a very valuable key to building a blog; you must think thoroughly about what you're writing. Random thoughts that pass through the mind are almost worthless. But as they are formed on the screen, edited, cut, pasted, researched and re-edited, they can become quite valuable. This point is discussed in many places. Quality content is very important. Therefore, if you want your blog to be at all valuable you will think through and research your post to be sure you are accurate and even provocative. Also, I thought Sandhill Trek had good feedback to his question 'Why do we blog?'. The first quote from Anne Matthewson from fishbucket.net starts with "We cannot live for ourselves alone...". What a great and fitting statement for people trying to find purpose. Selflessness is truly a key to success and happyness. What easier way to be selfless than to share information that you've acquired with the world?

Likely more on this later.

Good evening

Donald W. Hasson
http://www.linkedin.com/in/donaldhasson
http://donaldhasson.blogspot.com

Outlook 2003 Signature

I have started using email signatures occasionally at home. At the office I have Outlook 2003 and I just got the same version at home. I have an icon at the top of a new mail message seven from the left title “Signature” at work. I use this very regularly because I don’t want a 20-page signature with every email I send. So I choose the “formal” signature for appropriate emails. At home, however, no such icon existed and no menu or pulldown or whatever. When I tried help it returned the suggestion to open up the email signature editing box, copy then paste the desired signature into the email. This didn’t sound right. So after some snooping I realized the difference was that at home I chose to have Word be my email editor. After changing this allow Outlook to create the emails, the icon appeared right where it should. I realize Word offers some nice “idiot proofing”, but I’ll just check my emails a bit more carefully now.


Good evening

Donald W. Hasson
http://www.linkedin.com/in/donaldhasson
http://donaldhasson.blogspot.com

Sunday, September 24, 2006

McAfee Script Error

I have Windows XP Pro SP 2 running McAfee VirusScan 10.0.

Does this error look familiar?
An error has occurred in the script on this page.

Line: 752
Char: 5
Error: The task has been configured with an unsupported combination of account settings and run time options.
Code: 0
URL: mcp://C:\PROGRA~1\mcafee.com\vsooui.dll:mgavprop.htm

Do you want to continue running scripts on this page?

You may see this error if you attempt to view the VirusScan options page one of two ways - 1) right click on the red McAfee "M" in the Windows notification area (near the clock), go to VirusScan then Options OR 2) Go to the McAfee Security Center by double clicking on the red "M" or go through the Start menu, then click on "Configure VirusScan Options". Either way gets you to the same place. But you may get the error which is the reason for this post.


This discussion on McAffe's support site claimed to have fixed the problem but all he did was remove the VirusScan task from Windows Scheduled Tasks program. What if you DO want this task scheduled? And who wouldn't? It's virus protection software which should run EVERY night as a scheduled scan scanning all your attached hard drives and partitions - and it should do all this while you sleep. Simply deleting the task is not a good answer.

Here's what I discovered the actual culprit was: In the properties of the task in the Windows Scheduled Tasks program, I deselected "Run only if logged on". Allow me to sidetrack here for the purposes of explanation and edification: Most people say your computer should be password protected for many reasons. Thus, I believe XP Pro (not Home Edition) is the way to go. So, following good advice, I have XP Pro and have my computer set to require a password upon returning from Hibernation. So when VirusScan runs in the middle of the night after the computer has been hibernating for several hours, it must run even if not logged on. Now back to the main issue. You can see for yourself. If you get the above error message, deleting the task and resetting it in McAfee will only fix the problem until you go in to the VirusScan task and uncheck the aforementioned "Run only if logged on" box (which you can only do in Windows Scheduled Tasks. You will instantly see the error when you attempt to view the VirusScan options page (using the method detailed above). Clearly this is an issue with McAfee. But finding the technical support less than helpful I was forced to create a workaround - which I am now quite happy with.

Again, XP Pro with VirusScan v10.0.
What you must do is create a batch file (good tutorial here) (or command file) which will run VirusScan for you. Open Notepad and paste the below text:
c:\PROGRA~1\mcafee.com\vso\mcmnhdlr.exe /runtask:0
Save this file as something obvious (I called it "Scheduled Run McAfee.bat"), but it MUST have the ".bat" extension. It could just as easily be called "run_scan.bat" if you like. Additionally, I saved it in an obvious location on the hard drive (C:\Program Files\McAfee.com) so I could find it easily later, which I suggest. Now if you were to double click on this newly created file, it would start running a full system scan. I have not completely figured out the command line switches (these are the groups of text after forward slashes ("/") at the end of the command line). Right now I have "/runtask:0" (that's a zero at the end). I would think there's a way of setting up different scanning configurations (scan only internal hard drives, scan only certain folders, etc), but I have not figured that out yet and would rather everything be scanned. It runs in the middle of the night anyway.

The final task is the actual scheduling of the newly created batch file. Go to Start -> All Programs -> Accessories -> System Tools -> Scheduled Tasks. Once open, click on "Add Scheduled Task". This brings up "Scheduled Task Wizard". Click "Next" on the first screen, then on the 2nd screen click "browse". Find your file, click on it then click "open". On the next screen name your task whatever you want and select how often to perform the task (I recommend "Daily") then click "Next". This can all be changed later if you want, by they way. Now set the time you wish to start this task (I recommend middle of the night) and you can change specifics of how often it's run (again, I recommend "Every Day", but if you selected "Weekly" or "Monthly" on the previous screen, this won't be an option) and click "Next". The next page may ask you to enter a password if you have XP Pro and have set up this feature which I recommend, then click "Next". The last page tells you that you were successful (if, in fact, you were that is) and gives you an option to check the "Open advanced properties for this task when I click Finish" box. We want to see advanced properties so click the box and then click "Finish". Be sure "Run only if logged on" is NOT selected. If it is selected, click the box to uncheck it. Finally, click the "Settings" tab and check the box that says "Wake the computer to run this task". This allows the task to run even if the computer is in Stand by or Hibernate mode. Then just click "OK". There are a couple other advance properties that you can play around with or ask me about by posting a comment.

This will allow you to have scheduled task which runs when you are not logged on even in Hibernate mode and you won't get the above McAfee errors when trying to view options and other things.

One other note: Running a batch file is very powerful (see above link to tutorial). I have added one more line to my file so the file looks like the below:
c:\PROGRA~1\mcafee.com\vso\mcmnhdlr.exe /runtask:0
notepad C:\Documents and Settings\All Users\Application Data\McAfee.com\VSO\ODSLog\*your_login*_ods.log
(Lines 2 and 3 should be on the 2nd line together but word wrap throws it off; *your_login* is whatever your XP login name is; but better to go to the correct folder and find the actual name of the VirusScan log file). This additional line opens the log file upon completion of the scan. This allows me to see that McAfee did, in fact, run during the night and what the results were. I noticed on the McAfee forum there were many problems with VirusScan not even running. I don't have a good solution for this, but bringing the log to attention shows that you're okay.


0x8007007a: The data area passed to a system call is too small
This batch file idea may even fix the below problem which Microsoft didn't (at the time of this writing) have a good answer for and a real fix for. Though I can't prove the batch file will work since I don't personally have this problem.

Black M after scheduled scan runs
Using a batch file may even fix this problem, but, again, I don't know.

Something else is that changing the default browser from Internet Explorer did NOT affect the functionality of McAfee. McAfee technical support told me I must have IE as the default. This is not true.

Good afternoon

Donald W. Hasson
http://www.linkedin.com/in/donaldhasson
http://donaldhasson.blogspot.com

Saturday, September 23, 2006

What's with the word?

As I clearly stated in my first posting I have several goals for starting this blog. Before pursuing methods of meeting those goals I must say I really dislike the word "blog". weB LOG; yes I realize from where it originated. Some words are beautiful; even poetic. Autumn, roses, love, cherish, blog. Something amiss here? Couldn't we as an internet society, joining races, countries, cultures and all of mankind, come up with something a little better? How about "intournal" (INTernet jOURNAL)? Or "moughts" (My thOUGHTS)? Or even "who cares?", which unfortunately for must of what is written I my site may be true. I admit mine are no better. Maybe you could post some suggestions for me to use in place of "blog"? Unfortunately "blog" is now a noun and a verb; not good. Since I'm quite certain I have said too much on this topic, I'll sign off now.

Good evening

Donald W. Hasson
http://www.linkedin.com/in/donaldhasson
http://donaldhasson.blogspot.com

Job Recruiters

I have only been on LinkedIn for a few months now and have little experience in the networking world. So I will say this posting will be mostly opinion but hopefully helpful.

About two weeks ago I received my first communication from a recruiter with several available positions in the GPS navigation industry. The initial description was fairly detailed I must say. Though I am enjoying my work as a Navigation Analyst at Honeywell right now I think it is always wise to build/maintain a good working relationship with quality individuals in any capacity. This could be an especially profitable relationship for both sides because she probably focuses on the Navigation or Aerospace & Defense industry. This could yield the following positive results for both sides:

1. She may be able to help me find employment in the industry in which I currently have the most strengths if the need were to arise in the future.
2. I believe engineers are still in fairly high demand. This allows both her and me to keep open the option of better opportunities now for me and my family (i.e. location, promotions, other interesting technologies, and of course possibly more money). And she can keep my name and information filed away in case she comes across positions she needs filled that she thinks will be of interest to me. This makes the search easy for her and possibly gets me a good job.
3. As a recruiter she will likely have many contacts which could be beneficial to me. And, again, she may be facilitator for another recruiter which always strengthens her relationships with other networking recruiters.
4. Since I am directly in the middle of the industry from which and for which she is trying to recruit, I can be a good "insider" for her. If I am in any way productive for her then the benefits are many. She gets her position filled with quality individuals to whom she has at least some connection. Additionally, the connection is someone who knows the industry backwards and forwards. This must be far superior to cold-emailing or cold-calling. Secondly, the person I know, who hopefully I am looking out for his/her best interests, will find a position which may better fit their talents and goals. Finally, I feel good about being part of making a good fit. The recruiter and my contact will likely look to return the favor when the time comes.

Because of all these things I decided to send her a kind note thanking her for presenting the opportunities. With it, I included my long-term goals (in case of any random fits) and my resume so she could get a good feel for my background. Additionally, I offered to keep my ears open for folks looking for work in the industry. Now she is a contact of mine on LinkedIn and I hope to build a strong professional relationship with her - for both of our sakes.

Good afternoon

Donald W. Hasson

http://www.linkedin.com/in/donaldhasson

http://www.ecademy.com/user/donaldhasson

http://donaldhasson.blogspot.com

Windows XP Repairs - Hibernate Mode

Seems you can boot off the Windows XP CD (press F12 if Dell at splash screen - or change BIOS(usually press DEL at first screen) to boot off CD first) and go into repair mode. I knew this was possible but didn't know there was a specific repair for the registry. Now this could be dangerous and I don't know how it will work, but it's worth a try. I certainly plan to backup the registry first. The method is to press "r" when the selection page comes up (this is after the Windows CD loads some stuff and the pages gives you the option to load windows, repair windows or exit I believe). I think it loads a couple other things for a few seconds then drops you into the C:\Windows directory in a DOS-looking screen. The command is "chkdsk /r" (no quotes). CHKDSK is a standard DOS program which checks many aspects of the computer's hard drive. The "/r" is a command-line switch which directs CHKDSK to check the Windows registry. I'll update you on how well it actually works. It may be better to purchase a piece of 3rd party registry repair software.

The problem I'm having is the laptop (Dell Latitude D820) looses the ability to go into hibernate mode after some unknown amount of time (1 day, hours, ???). After a restart the feature magically returns. I can't select hibernate from the Power Down menu, the Power Options menu doesn't show hibernate as an option and the hibernate tab (which allows you to enable hibernate mode) doesn't even show up. I have done many modifications to the laptop like reformatting the hard drive, reinstalling Windows, modifying some Windows features and installing a decent amount of useful software (virus protection, Windows Defender, firewall, cleanup software, in addition to the typical software). So I'm quite certain it's something I've done and not the fault of the computer.

Good afternoon

Donald W. Hasson
http://www.linkedin.com/in/donaldhasson
http://donaldhasson.blogspot.com

First Post

Interestingly enough my initial post will likely turn out to be very uneventful and useless. I suppose if the beginning of our country were to have felt like this first post, we would all be communists now. Thankfully our founding fathers put more effort into the birth of our country in 1776 (I'm very interested in this book, 1776 by David McCullough) than I likely will in this initial post; the genesis of my blog.

Basically the goal here is several-fold:

1. I work out a lot of problems, often in creative ways. Why should everyone else have to go through the same things just to get the same solution? I want to share what little knowledge I have so people can quit spending 5 hours a night trying to get the answer to "Why does my house plant have brown leaf tips?" or "What are some American companies with facilities in Italy?". I work hard to get accurate information and run it through my own personal filter (brain) honed by years of experience, blood, sweat and tears and all that jazz.

2. I want to promote my skills in the professional world. Again, I work hard to become very good at whatever I do. These skills stay with me wherever I go. I want people to be able to tap into this experience. If possible, this will be an avenue to broaden my professional career.

3. I have a lot of thoughts; who doesn't? More importantly, I would like to part of the huge network of experience and life's lessons called society. Everyone has different talents and views of the world. If thought through, concise and well written and, if possible, backed with data/research/good arguments people may actually benefit from what's in my head.

4. Networking (http://www.linkedin.com/, http://www.ecademy.com/) - personally or professionally. Somewhat of a combination of the first 3 reasons, I want to do all the above in a networking fashion by promoting my blog (http://donaldhasson.blogspot.com/) on other's websites (http://www.cfo-coach.com/index.htm) and post other's thoughts on my blog; or at least link.

5. Finally, again applying this to the previous reasons, I don't want to forget good stuff. Probably 5 years ago I posted my one and only guitar tablature on a website designed for this purpose. Every other tab for this song (Drive by Incubus) was very poorly done. I had developed a pretty good ear after playing guitar for several years and was confident my tab was correct (actually now 5 years later this one is exactly how I play it). Well, now looking for that tab online I can no longer find it. Likely legal issues with copyrights and such have stirred up the online guitar tab world enough that my post may be long gone. If it were on my blog, I'd have control over it. Another thing is all this stuff I'm learning about PERL programming language, MatLab, and Vim Text Editor to just name a few. Some of the discoveries I make come only after and hour or two of web searching and experimentation. It would be ridiculous to keep that just in my head. This blog is a good forum to which to do "brain dumps" at the end of the day.

I'm not sure how personal I'll get. I'm sure most will understand when I say I don't want a few billion people knowing that I had a bad day at work because of whatever. That's me and my wife's business and maybe the dude who caused the bad day.

Good evening

Donald W. Hasson
http://www.linkedin.com/in/donaldhasson
http://donaldhasson.blogspot.com