Category Archives: Programming

How to disable “Printing x of y” dialog when using the printer object

I have a new process that prints several hundred documents via a batch, but I don’t want the dialog to pop up every time it starts a new file.  This is really annoying as I might be typing in another window and the “Printing” dialog pops up as I’m hitting the spacebar and it thinks I want to cancel printing the document.

You can get around this by making a dummy print controller.

‘This was already declared earlier in the process
MyDocument = New PrintDocument()
Dim dlgPrintingDialog As New StandardPrintController
MyDocument.PrintController = dlbPrintingDialog

That’s it – now you can print and you won’t see a pop-up.

Publisher could not be verified!

I hate that message!  I have a batch file set to run via a timer and every day it stops because it wants to verify the publisher.

Here is a way to disable the message:

1. Click Start–>Run and type gpedit.msc. Click OK

2. Go to User Configuration–>Administrative Templates–>Windows Components–>Attachment Manager

3. Add “*.exe” to the “Inclusion list for moderate risk file types” setting. You can also add other file types.

This should disable the “Publisher Could Not Be Verified” messages from appearing for that file type in the future.

Good luck!

(Note, this is the second method I’ve used for this and I’m waiting to see how well it works.  I used a different method yesterday via IE to trust the directory where the batch file is located and it made absolutely no difference at all)

 

My Favorite Windows XP Batch File of All Time

My Favorite batch file for Windows XP ever only contains one line:

net stop wuauserv

When do you use it?  You use it when you are in the middle of trying to meet a deadline and every 5 minutes, the Microsoft Updater jumps up and says “You need to reboot your machine to complete your updates.”

These three words can take away as much stress as your manager calling to say that the meeting has been canceled and you should go home early to enjoy the rest of your day.

Now, I’m not suggesting you completely ignore updates, just ignore them when they are bugging the heck out of you.

 

Saving all files from subdirectories to a main directory

Here is a quick batch file that will go through all subdirectories in a directory tree and copy files, ie photos, to another directory.  This works well with the Saving Vox photos post that I did recently.

——————————————————–

for /f %%a in (‘dir /b *_files’) do call :process “%%a” “%%~dpa”
goto :eof

:process
cd %1
copy *.jpg c:\TARGETDIR
cd ..

——————————————————–

The main points in this are the “_files in the dir command and the C:\TARGETDIR in the copy command.  In my example case, Firefox and iMacros created a bunch of directories called (something)_files, so I want to loop through all of those.  The batch starts by building a list of all of these directory names then it starts a loop process to work through them.

The subroutine “process” changes the current directory to the subdirectory and then copies all of the JPG (picture) files up to C:\TARGETDIR.  You would call this something else, but make sure it’s created before you start.

Running instructions -

After making appropriate changes, you save this batch file in the parent directory of the subdirectories you want to read from.  I call it something simple like “DOIT.BAT” and then I shell out to DOS and run it.

Again, this works for me – there are probably other ways to achieve the same results.

VOX – Saving all your photos locally

When I heard Vox was shutting down, I didn’t worry too much about my posts because there is an import tool at WordPress and Six Apart also gave us a free Typepad account.  I was quickly able to make multiple secure backups of all of my blog posts.  Then a few days later, I read someone’s post about all their photos and a shiver went down my spine.  For the longest time, my phone was set to automatically upload all photos directly to Vox and I didn’t keep local copies.  That means a majority of my photo memories for the last few years were sitting out on the Vox servers and I had to find a way to get them out of there.

Six Apart had set up a Flickr tool so you could copy all of your photos over there, but with about 2,900 photos, I was going to blow up my free account in about five minutes, so I started working on other alternatives.  I first tried to write a VB app to download the photos – and it worked surprisingly well – amazingly, actually.  I was thrilled – but it would NOT download private (neighborhood/friends only) photos.  This had to do with cookies and authentication, blah, blah, blah.  I tried several different methods to attempt to get cookies in VB for all of the various Vox servers (a2.vox.com, a3.vox.com, etc, etc) – but it just wasn’t working and time was running out.

I abandoned that idea and started looking for Firefox add-ons that would assist with downloading all of my photos.  I found two, but neither of them could navigate from photo to photo and download them.

Finally, I remembered that I installed a Firefox tool called “iMacros” a while back in order to assist me with deleting huge quantities of status updates from Facebook.  I wondered if it would work to save photos?

It does – and pretty well.  It still has to cycle through each and every photo in order to save them, but I don’t mind that too much.  There is a looping function so once the script is in place, I just tell it to run in batches of 200 and let it go.  It’s a slight bit of trickery because it isn’t saving a picture/photo, but instead, it is saving a web page.  The web page just happens to be the actual photo page, so it doesn’t just save a .jpg, but instead it saves an HTML page and a directory with all of the resources for the page, one of which is your main photo.

What does that mean?  It means the macro is going to create x directories, one per page and in each of those directories will be one photo.  Again, I don’t care about this.  It’s just a matter of moving them all back into one directory and deleting them.  You could probably create a macro or batch file or something to move them all up – and while that’s a fine idea, I’m done wasting time on this.  I’ve achieved my goal of saving all of my private photos locally.  You can certainly take this script and do whatever you want with it, but it appears to work for me.

Things you’ll need:

1.) An installed copy of the latest Firefox.
2.) Download and install the iMacros Add-In for Firefox.
3.) The script:

———————————
VERSION BUILD=7000908 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=A ATTR=TXT:View<SP>full<SP>size
SAVEAS TYPE=CPL FOLDER=C:\VOX FILE=+_{{!NOW:yyyymmdd_hhnnss}}
BACK
TAG POS=1 TYPE=A ATTR=TXT:Previous
———————————

What to do:

1.) Open Firefox, go to Vox and login to your account
2.) Select Library/Photos, then pick your newest photo and select “View on Blog”
3.) Open up iMacros and click the record button and then the stop button to make a new macro
4.) Use the edit tab to edit your macro and copy/paste the above script into your macro (without the —–lines)
5.) Note the line where it says “SAVEAS” – I created a C:\VOX directory to store my data.  You should make this directory first, or change the name of the directory to something else.  You don’t want to call it something with spaces like “MY SAVED PHOTOS FROM VOX” or something otherwise silly, just keep it simple.
6.) Save and Close the Macro
7.) Select the PLAY tab and click “Play”.  You should see Firefox open up your photo in full page mode, and then in a moment, it will go to the previous photo in your collection.
8.) Take a moment to explore your C:\VOX folder to see if something was indeed saved.  You should see a directory and if you look in that directory, you’ll see your photo.  It will also have an obscure (Vox) name.
9.) If this all worked, you can use the Repeat Macro selection to put in a  Max value of say 100 and then hit “Play (Loop)”

It should create several hundred directories with all of your files in them.  If it’s working okay, you can run the loop again until eventually it will store everything on your local drive.

If something goes wrong, you can always navigate to the last picture you think it saved and start the macro again.

One change I did make to the defaults was under iMacro settings/options, I changed the timeout from 60 seconds to 300 seconds because some photos take a long time to download and 60 seconds just wasn’t always enough.  (oh, yeah, if your internet connection is slow, this is something you might want to run overnight)

I’m not really going to support this or get into long discussions on using iMacros or better ways to do it – I’m sure there are a lot of ways to accomplish this task, but this is one I chose and it worked for me.

ASP routine to check valid IP address

Create MS MDB without MS Access

(from http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=1089)

//Set a COM Reference to “Microsoft ADO Extensions for DDL and Security” (ADOX)

private ADOX.Catalog cat = new ADOX.Catalog();
private ADOX.Table tbl = new ADOX.Table();
private string db_file_path;
db_file_path = ActiveWorkbook.Path + “\\abc.mdb”;
//connect to the Access database
cat.ActiveConnection = “Provider=Microsoft.Jet.OLEDB.4.0;” + “Data Source=” + db_file_path;

//Create a table
tbl.Name = “Prospects”;
// First, fields are appended to the table object
// Then the table object is appended to the Tables collection
tbl.Columns.Append “Name”, adVarWChar;
tbl.Columns.Append “Company”, adVarWChar;