• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Here's how to print from Android or any mobile device that normaly can't

Lars

Android Expert
Mar 24, 2010
1,439
210
www.larsdennert.com
I've been agonizing whether to release this in the wild because it isn't a 100% solution yet. The problem with Mobile devices is that no one has developed a good way to print documents directly from them. I have come up with a fairly simple way to print.

It involves installing a simple print daemon on a windows machine that has a default printer of some kind. It doesn't matter the type. If the PC can print and it is the default you are good to go.

This daemon will print any document recognizable by the Windows PC.
The basic idea is to pass the name of the directory you would like the daemon to monitor for files as a parameter.
The directory must be shared and writeable by devices such as smartphones.
This folder can be a network share or ftp folder if you have an ftp server setup. If you don't know how to share folders or setup an ftp server, start googling.

1. Extract the file in the zip and save it to your local disk. On XP drop a shortcut to this file to Documents and Settings\All Users\Startup.
On Vista and newer click Start-Programs-Startup and right click Open All Users then drop a shortcut to the file in that folder. You must be in an admin account to do this and the Print.vbs file must be on a local drive of the PC or you will get security warnings. I wrote the program in vb. Inspect it if you like.

2.Edit the properties of the shortcut and add the folder name to monitor to the commandline such as "c:\program files\print.vbs" "C:\Printme". This printme folder is the one shared to the mobile devices.

3. Reboot the computer and log back in. You should then see wscript running in the task manager. It checks for files every three minutes and doesn't slow the computer. You'll get a warning if you didn't do step two and things won't work.

4. For Windows Mobile map the shared folder from the pc using NetUse.
For Android create a Samba share to the LAN using estrongs File manager.
For other platforms or the the above, turn on ftp on the XP machine
and use an ftp client to access the folder. estrongs can also be used for ftp if you are printing over the internet.

5. To print, simply copy the file(s) into the Shared folder on the server from the phone using estrongs or an ftp client.
If the XP machine has a file association for the file, it will print to the default printer and then delete the file. You may want a special folder like Printme so that other stuff doesn't go in there.

PDFs and office documents work well. Problems: First it requires a moderately tech savvy person to setup. Second, you need software such as MS Office or adobe reader installed on the host so the computer knows what to do with the file. Third, and here is the big one so far, a user account has to be logged in to activate the script. I haven't been successful running it as a system service because the System service can't spawn apps even if you runas admin.

So there it is. Maybe it helps someone.
 

Attachments

  • Print.zip
    1.1 KB · Views: 199
The path should get passed as a commandline argument. If you created a shortcut to run the bbs then go back and edit the shortcut. In the commandline you'll see the name of the script. Put a space after the name and then the folder you want it to monitor in double quotes " . Make sure that folder is empty because everything in there gets printed and deleted. I guess I could have made it move the files as a safety.
 
Upvote 0
The path should get passed as a commandline argument. If you created a shortcut to run the bbs then go back and edit the shortcut. In the commandline you'll see the name of the script. Put a space after the name and then the folder you want it to monitor in double quotes " . Make sure that folder is empty because everything in there gets printed and deleted. I guess I could have made it move the files as a safety.

Awesome Dude!!! Works great, thanks a lot!!!

How do I modify the script so that it deletes file without prompting to confirm deletion?
 
Upvote 0
got it to work! thanks! how do i have it delete without prompting to confirm deletion?

I found a way to modify the script so that it just deletes the file after printing without putting up a dialog box and waiting for a response. Find the first line shown below in the script and insert the second line into the script below the first line as shown:

Dim strFolderPath : strFolderPath = ArgObj(0)
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")

Do the same with these two lines:

wscript.Sleep(10000)
objFSO.DeleteFile(objItem.Path)
 
Upvote 0
Thanks and thanks to dave for digging into VBscript further than my lazy A$$. The machine needs Recycle bin prompts turned off BTW. Printing jpgs varys with Windows version and may pause to prompt depending on your file associations.

If I was on Linux, I'd make a php script and have an interface on the phone that would do a file upload. Open that to the web and print from anywhere.

In reality HP is solving this issue for us with their Air Print printers. About time.
 
Upvote 0
Windows??? REALLY? What about if all you use on all your PC's is Linux?

Write a bash/ksh/sh script that checks a directory for files, and if they exist, print them. The Android side would be the same.

A simple script would be something like this:

Code:
#!/bin/bash

set PRINT_DIR=/tmp/AndroidSpool

if [ -e $PRINT_DIR ] then mkdir $PRINT_DIR

for i in `ls $PRINT_DIR` do
  lpr $i
done

exit 0

Yes, this script needs some work, as most files will come out munged, but you get the idea.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones