Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Add Command in Context Menu?


  • Please log in to reply
28 replies to this topic

#26
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,036 posts
  • OS:none specified
  • Country: Country Flag
Good. :) Fixed the typo in the original post. jaclaz


How to remove advertisement from MSFN

#27
exit15

exit15
  • Member
  • 4 posts
  • OS:Windows 7 x64
  • Country: Country Flag

OMG, I went back to the office today and the printer started shooting all of my Listing.txt files from yesterday. What a waste. I did not mean for it to actually print, I just wanted to create the text file with the list of the files within the selected directory so that I can later manipulate in excel or access.

So here's the code: what it currently does is to create a txt file within the selected directory, this file Listing.txt has the names of all the files contained in that directory; it then sends this file to the printer. I want to stop sending the file to the printer.  – help me save some trees.

 

Printdir.dat

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
DIR "%~1\*.*" /ogn /-p > "%~1\Listing.txt"
notepad.exe /p "%~1\Listing.txt"

PrintDirectoryListing.reg

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Shell]
@="none"

[HKEY_CLASSES_ROOT\Directory\Shell\Print_Directory_Listing]
@="Print Directory Listing"

[HKEY_CLASSES_ROOT\Directory\shell\Print_Directory_Listing\command]
@="Printdir.bat \"%1\""

[HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory]
"BrowserFlags"=dword:00000008

[HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory\shell\Print_Directory_Listing]
@="Print Directory Listing"

[HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory\shell\Print_Directory_Listing\command]
@="Printdir.bat \"%1\""

[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\AttachmentExecute\{0002DF01-0000-0000-C000-000000000046}]
@=""

[HKEY_CLASSES_ROOT\SOFTWARE\Classes\Directory]
"EditFlags"="000001d2"

exit15



#28
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,036 posts
  • OS:none specified
  • Country: Country Flag

Sure :).

If you invoke notepad with the /p switch, it will

1) open the file (but NOT display it on screen)

2) send it as is to the printer

3) close the file and terminate the running notepad

 

http://www.robvander...com/notepad.php

 

Just remove the /p from :

notepad.exe /p "%~1\Listing.txt"

 

Or remove the whole line above from the batch if you don't want the file to be opened in notepad.

 

Sorry for your paper (and for the trees). :(

 

jaclaz



#29
exit15

exit15
  • Member
  • 4 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Works perfectly... and I'm learning something too.

thanks,

exit15






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN