Some program like UNIX 'file', but for Windows?

C

Chaos Master

Mike Henley puts out:

So I just need to learn Unix commands? is that it?

Yes, and a basic Linux commands tutorial may be enough.

When you learn the basics, you can go on to more advanced stuff like compiling
programs.

[]s
--
Chaos Master®, posting from Brazil.
"People told me I can't dress like a fairy.
I say, I'm in a rock band and I can do what the hell I want!"
-- Amy Lee

The Evanescen(t/ce) HP: http://marreka.no-ip.com
 
O

omega

B.t.w. in the other situation (batch files to be used contextually),

Wow, you've stayed on top of all the separate queries that I was mixing
around in the same pot. Very keen and adept. I appreciate that immensely.
basepath.exe %1
%basepath%.\ :: make the target drive active, if necessary
cd %basepath%
Does this solution now also work out for you?

Perfectly!

I configured it with success results for the two CLI programs where I had
the highest need for sendto functionality. I have the delighted confidence
now that for those many others that come up, I forthwith have the means to
handle them.

Details...

The basepath lines you gave worked right out of the box. Immediate success.

Next, I tried to see if the same end could be achieved with commands close
to those in the solution you'd provided for my run.pif situation. I had
a hard time. I was an enfeebled hound, circling the wrong trees, while
smelling the treed 'coon so near. Finally, by luck, I bumped into a saved
text file from http://www.ericphelps.com

It contained the precise sekrit formula.

%1\ :: change to the drive
cd %1\.. :: change to the directory
:: prog.exe -params %1

(Btw, is it too much to hope that the above works equally for 2000/XP?)
And there was this other situation:


Does change drives, then cd (maybe using basepath) at some place in the
config also help there?

I added to my explorer cntxt-menu for bat files, a command to point to
a pif-bat, utilizing the special cd %1\ lines.

[HKEY_CLASSES_ROO\batfile\shell\Launch\command]
@="batlaunch.pif \"%1\""

----batlaunch.bat--------
%1\
cd %1\..
REM start %1 (*)
shexec %1
---------------------------

(*On my system, the default action with bat is to open in a text
editor. So that's what occurs if I use Start %1. The shexec line
I've used above, it's a little program in my path which performs
shell execute, ignoring my default verb.)

Tested it up, and all seems well. Finally I can do what failed before.
I can launch batch files right from toolbars! No more "File Not Exist,
Invalid Command, BAD Girl" or whatever it is that Mr. Console was always
grumbling at me.
 
O

omega

I configured it succesfully for the two CLI programs where I had the highest
need for sendto functionality.

The first Success Story: Innounp

Innounp, Unpacker for Inno Setup files
http://innounp.sourceforge.net/
http://umn.dl.sourceforge.net/sourceforge/innounp/innounp013.rar

When I got hold of Innounp, a commandline program, I could not figure out
how to get it to work with sendto. How to get it to put its output in the
path of the target. So I had to settle for having it on cntxt menu.

[HKEY_CLASSES_ROOT\exefile\shell\outinno\command]
@="<path>\\innounp -x %1"

Really, I did not like having it crowded right at the root of my explorer
cntxt menu for exe files. It only applies to a small subset of exes, so it
was unnatural to have it in the main menu for all exes.

Instead, I wanted a pif shortcut for it put in a special sendto folder
for its category of use. In a folder with the other contextual shortcuts
to programs that do extraction of various forms of setup exes.

The problem I had with setting it up in sendto was that I did not know how
to get it to produce its output into the same path as my target. Thank you,
Sietse, for giving me answers to this area of mystery.

-----outinno.bat-----------
%1\
cd %1\..
<path>\innounp -x %1
----------------------------

I don't know whether the above works for XP/2K, or whether they have to
use their own trick instead. I can say that in my tests on 98, results
are good.

I select an Inno set file, send it to that batfile shortcut, and Innounp
automatically creates a subfolder containing the extracted contents of the
setup exe I've targeted.

.. . .

Incidently, regarding recognizing which exes are of the Inno type. I don't
know. I just click and watch. If the installer exe I've targeted is the
right type, an Inno (3x/4x), then I witness successful output. And if the
exe is something else, the result is nothing beyond a quick flash-by of
the console.

I haven't been observant enough to say for sure, but my ~memory leads
me to believe that an Inno setup file can have any kind of icon that
the programmer might choose when he's compiling the installation file.
(It would take someone who has used Inno to say definitely.)

What I did notice, when today I was checking my recent inbounds for Inno
type setup icons, is one particular standard icon. Here's a pic of that
icon - http://omega5.port5.com/clips/1001/InnoIcon.png
I thought could help as a visual aid for others (except those who are
already ahead of me on Inno recognition techniques) who take up use
of Innounp.

<Disclaimer blahblah>
As far as recommending Innounp. I'm saying I use and appreciate it. Not
advocating its widespread use -- certainly it is not a program for our
lazy relatives. Those who use it will have to take responsibility for
their own uninstalls, and sometimes for registering included libraries,
and whatever similar needs can get involved.
</Disclaimer blahblah>
 
O

omega

The next Success Story: UNDOReg

This is the companion program for Inctrl and Regshot. It processes an
Inctrl or Regshot report, and removes from one's registry all newly added
keys listed in that report.

The standard version of UNDOReg available for download is version 1.46.
When you use this version: It pops up a confirmation prompt when you've
sent it a reg rpt, and once you've hit OK to proceed, it removes the
referenced keys from your registry, then vanishes. It works very well.
(It does not deal with newly-added values below pre-existing keys, nor
changed values, but that isn't the subject I intend to go into here.)

While UNDOReg in its latest incarnation works fine, I've taken pattern
of consistent use\need, as well, of the services provided by its ancestor.
The earlier one does not support Regshot reports - which doesn't affect
me, since I am an Inctrl user. The significant difference for me is in
how the earlier one operates. When sent an Inctrl report, that one creates
an undo.reg file. Perhaps not overly commonplace, such a need, but fact
is that in the configurations I engage in, I have regular need for getting
those re-usable undo.reg files.

UNDOReg, that earlier commandline version, was another of those programs
where my contextual sendto script was completely unsatisfactory.

Again, it's one of those menu commands that I do not want at the root of the
explorer cntxt menu. The extension type involved is txt (since Inctrl names
its logs RPT*.txt) -- and it is not a good fit to see an UNDOreg cmd every
time I'm choosing an action on a .txt file.

So I made a bat for sendto. It was very feeble.

------lam0.bat-----------------------------------
<path>\undoreg\2file\undoreg.exe "%1"
start notepad <path>\undoreg\2file\UNDO.REG
--------------------------------------------------

When I used it, I then always had to do the manual steps, with my notepad,
to save the generated undo.reg to the appropriate path.

Now, today, with the neat new trick Sietse taught me, things are finally
set the way I'd wished.

-------undoreg.bat------------------------
%1\
cd %1\..
<path>undoreg\2file\undoreg.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
:: start notepad UNDO.REG
-------------------------------------------

Voila. The generated undo.reg file nw gets automatically placed where I
want it.

Additional bonus, another good side effect to the new config. Previously,
with lam0.bat, I was getting failure whenever I sent a file which was on a
path containing spaces. I'd always assumed that the problem was with the
program itself. Now, launching it via a bat file with the matured syntax
(that was a needed tip, Sietse), that problem has vanished.

There might be a few out there who will also have use for this older version
of UNDOReg, this one that generates undo.reg files. I don't know where it
is on the web. Earlier this year, I tried searching, and didn't come up with
anything other the v146.

I don't know what the release history has been. The older one that I have
is version 1.0, and I've uploaded it. Actually, since the program is so
tiny (the execs are ~11k per), I've gone ahead and uploaded the both
versions together in one zip.

http://omega5.port5.com/clips/1001/undoreg.zip (64k)
_______________________________________
UNDOReg, by Davide "!bAsH"
Homepage URLs as listed in the readme:
http://neutronstar.cjb.net
http://spazioinwind.libero.it/neutronstar
 
O

omega

Another Tale of Success

The root of the cntxt explorer menu can get too crowded. I hunger for
shell extensions which let you create your own subfolders. The one I've
worked with that has the fullest scope of configuration possibilities
(FastExplorer) -- as well as a second-place door prize (CMenuExtender) --
they have, as a cost, some intrinsic problems.

Another one of interest for me has been MoreAct. It doesn't work with global
contexts, such as for folders, or all file types collectively. But where it
does offer to help is in adding extra subfolders for specified filetypes.
For a filetype such as html, where there are so many different programs you
might want to handle it, it is helpful to be able to have a group of them
together in a subfolder.

MoreAct was interesting to me in the fact that it is a hybrid. It is like
the explorer cntxt menu and the sendto folder converged into one entity.
When you configure it, you set up shortcuts such as lnks and pifs (likely
vbs etc works too), pretty much the same way as you do when setting things
up for the sendto folder.

http://omega5.port5.com/clips/1001/MoreActConfig.png

Then the way in which it enters onto the playing field, that's more like
a normal explorer cntxt menu extension. When you click on a file that has
a particular extension for which you've configured menu items, it brings
available the applicable sub-menu.

http://omega5.port5.com/clips/1001/MoreActCntxtMenu.png

Now that Sietse has handed me needed essentials in writing sendto bats,
I have the ability to get far more use out of this program. (Sietse,
again, thank you!!)


.. . . .
MoreAct URL? Even if I saw a homepage listed in the readme (I don't),
it'd very likely be long gone. This one is a Vintage 1997. It'd require
a Google query to find in which cellar it's being stored...
 
S

Sietse Fliege

omega said:
Sietse Fliege wrote:

One note: whether %1 is a file or a directory, postfixing %1 with
dot backslash will always result in making the target drive active.
I mean, the batch script above could also have been written like this:

%1.\ :: make the target drive active, if necessary
basepath.exe %1 :: get the path of the file and put it in an
cd %basepath% :: environmental variable and change to directory

This makes it easier to compare "my" method with "your" method.
Finally, by luck, I bumped into a
saved text file from http://www.ericphelps.com

It contained the precise sekrit formula.

%1\ :: change to the drive
cd %1\.. :: change to the directory

When I tested, it turned out that "my" postfix, dot backslash, does the
same as "your" simple backslash postfix.
The result is exactly the same (and, again, works whether %1 is a file
or a directory) : change to the drive.
Could be that some variant of (pure?) DOS requires dot backslash? Dunno.

What is more interesting is that you found out that, in order to change
directory if %1 is a file, there is no need at all to extract the path
(with basepath), as postfixing %1 with backslash dot dot suffices.
No external utility, no environmental variable, only 2 lines! :)))
Neat! Kudos!
(Btw, is it too much to hope that the above works equally for
2000/XP?)

Both "your" %1\ and "my" %1.\ produce an error, on XP at least.
Doesn't mean that XP-users are in trouble because, like
Mark R. Blain said, in WinNT, Win2K, and WinXP you can use:
cd /d %~dp1 :: This single command does it all.
( where /d = change to the drive, if it's not the current drive )
( %~dp1 = path of %1 )
But it does mean that batch code to change drive can be OS specific.
It indeed is something that one needs to know if working on different
machines or in case of migration to another OS.

B.t.w. I wonder if Win95cmd.exe (the MS batch enhancer for 95/98/ME)
would let you use cd /d %~dp1

----batlaunch.bat--------
%1\
cd %1\..
REM start %1 (*)
shexec %1
---------------------------

(*On my system, the default action with bat is to open in a text
editor. So that's what occurs if I use Start %1. The shexec line
I've used above, it's a little program in my path which performs
shell execute, ignoring my default verb.)

I wonder, could you not also use: command /C %1 or %COMSPEC% /C %1 ?
Or does using shexec have advantages? (I don't know shexec.)
Tested it up, and all seems well. Finally I can do what failed before.
I can launch batch files right from toolbars! No more "File Not Exist,
Invalid Command, BAD Girl" or whatever it is that Mr. Console was
always grumbling at me.

Great, Karen, that it is working out nicely.
Thanks for the success stories, also in the other posts in this thread.
(I must say that you grossly exaggerated my role in this thread, though.
Basically I never told you anything that you did not already know in
some form or another. I guess I may have been a catalysator, sort of
encouraging you to sort it out. And Mark R. Blain was very helpful!)

I am not gonna comment on those stories there, I think.
I'd recommend e.g. users of UNDOReg and Innounp to read them, though.
I may be interested in MoreAct, will look into it later.

Also, on that note, I no longer can reach your site.
Host Name Lookup Failed browser error. Ping also can not find host.
Maybe D.N.S. error on my side, dunno.

Finally, one thing about context menu item vs SendTo.
Suppose you have a batch that you want to start in a folder and do
something e.g. recursively.
Then the SendTo feature can come in handy, but I noticed that there is
no SendTo item for root folders, while at the same time doing something
from a root folder, recursively, can be very useful.
Easily solvable, just thought I'd mention it.
 
S

Sietse Fliege

Sietse said:
Also, on that note, I no longer can reach your site.
Host Name Lookup Failed browser error. Ping also can not find host.
Maybe D.N.S. error on my side, dunno.

Just now retried, no problem. :)
 
O

omega

Sietse Fliege said:
[...]
Finally, one thing about context menu item vs SendTo.
Suppose you have a batch that you want to start in a folder and do
something e.g. recursively.
Then the SendTo feature can come in handy, but I noticed that there is
no SendTo item for root folders, while at the same time doing something
from a root folder, recursively, can be very useful.

I'd paid attention to that before. I'm glad you brought it to my attention.
Easily solvable, just thought I'd mention it.

Easily solvable, oui. Regmagik got the trick done for me in half a minute.

On RM's dropdown bookmark menu, I keep handy the group of global context keys
(hkcr\*, hkcr\allfilesystemobjects, hkcr\directory, hkcr\drive, hkcr\folder).

After reading your post, I clicked the bookmark for \directory and the one
for \drive. I selected the sendto menu entry key under \directory, then did
a copy-paste, to add it under my \drive menu. Result:

[HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\SendTo]
@="{7BA4C740-9E81-11CF-99D3-00AA004AE837}"

I see no reason not to enable it this way for the drives context. And
especially, I agree with your point about it being relevant for various
sendto shortcuts. (Including, amongst many possible examples, for those
utilities that provide various space-used infos on selected drives.)
 
O

omega

[Edit]
I'd paid attention to that before. I'm glad you brought it to my attention.

Bleh. My cat typed that first sentence of the line above. What he was
supposed to have written was something more like: "I'd not observed
that before."
 
O

omega

Sietse Fliege said:
omega wrote:
[...]
One note: whether %1 is a file or a directory, postfixing %1 with
dot backslash will always result in making the target drive active.
I mean, the batch script above could also have been written like this:

%1.\ :: make the target drive active, if necessary
basepath.exe %1 :: get the path of the file and put it in an
cd %basepath% :: environmental variable and change to directory

This makes it easier to compare "my" method with "your" method.
Finally, by luck, I bumped into a
saved text file from http://www.ericphelps.com

It contained the precise sekrit formula.

%1\ :: change to the drive
cd %1\.. :: change to the directory

When I tested, it turned out that "my" postfix, dot backslash, does the
same as "your" simple backslash postfix.
The result is exactly the same (and, again, works whether %1 is a file
or a directory) : change to the drive.
Could be that some variant of (pure?) DOS requires dot backslash? Dunno.

My source is essentially no more that copying from someone who wrote a
collection of nice scripts, scripts whose value is in part that they are
readable by beginners. Your source I assume to be drawn from the likes
of the halls of the legendary professor Timo Salmi. So the %1.\ would be
expectedly the most formally correct form. At least in the sense of perhaps
providing some backward compatibility with DOS 5/6; or in DOS 7 "pure DOS"/
pre-Windows- load stage, as you've suggested.
What is more interesting is that you found out that, in order to change
directory if %1 is a file, there is no need at all to extract the path
(with basepath), as postfixing %1 with backslash dot dot suffices.

I still have need of the basepath utility for other matters. One main
project in particular, where I had a couple of barriers... Basepath
solves one of them. The other barrier, it involves batch output to a
file without CR/LF. I found one utility for that, possibly, but whose
usage I was still trying to figure out... Ah, but here I'm starting off
into a brand new subject. For moment will just leave that off, without
more than that vague, dangling reference.
No external utility, no environmental variable, only 2 lines! :)))
Neat! Kudos!

Ah, yes. That's when batch is beautiful in my eyes. When it achieves its
goal while staying short and sweet.
Both "your" %1\ and "my" %1.\ produce an error, on XP at least.

Thank you for letting me know.
Doesn't mean that XP-users are in trouble because, like
Mark R. Blain said, in WinNT, Win2K, and WinXP you can use:
cd /d %~dp1 :: This single command does it all.
( where /d = change to the drive, if it's not the current drive )
( %~dp1 = path of %1 )
But it does mean that batch code to change drive can be OS specific.
It indeed is something that one needs to know if working on different
machines or in case of migration to another OS.

B.t.w. I wonder if Win95cmd.exe (the MS batch enhancer for 95/98/ME)
would let you use cd /d %~dp1

I use Win95cmd.exe. I use it standalone, and not as my system command
processor. When I read the exchange between you and Mark, I did try a
test, and got successful results.

echo cmd | %1\
echo cmd | cd %1\..
echo cmd | start %1

(On my system my Win95cmd.exe is renamed to cmd.exe. Maybe like a kid putting
on its Mommy's make-up, for the sake of feeling like a grown-up. <g>)

[...]
Thanks for the success stories, also in the other posts in this thread.
I'd recommend e.g. users of UNDOReg and Innounp to read them, though.

It's good to have it clarified that one needs to use the one special trick
for the earlier command processor environment, and the other for the later
environment. I suppose, in theory, one could write one of those batch scripts
I see around which first detect OS, and then do that goto label sequence.
But the loss would be that the script loses the elegance of brevity.

So now, when it might arise that, for example, I get to advise an InnoUnp
user on using a sendto script, I'll know that their are two independent
methods to be used, which are dependent on environment.
 
O

omega

omega said:
I use Win95cmd.exe. I use it standalone, and not as my system command
processor. When I read the exchange between you and Mark, I did try a
test, and got successful results.

echo cmd | %1\
echo cmd | cd %1\..
echo cmd | start %1

OOOPS. I copy-pasted from the wrong file! The pertinent test (successful
result):

:: cmd is invoking win95cmd.exe
echo cmd | cd /d %~dp1
echo cmd | start %1

.. . . .

I had some other comments to make in reply to your message, Sietse.
But at this point I'm thinking I ought make making myelf wait. Until
I've taken my B vitamin supps and eaten my Wheaties. 8-o
 
S

Sietse Fliege

omega said:
I see no reason not to enable it this way for the drives context. And
especially, I agree with your point about it being relevant for
various sendto shortcuts. (Including, amongst many possible examples,
for those utilities that provide various space-used infos on selected
drives.)

One thing to note:
Suppose you have a listexes.bat that lists all .exe files in a folder :
dir %1\*.exe
When %1 is e.g. c:\windows then the command, with %1 expanded, becomes:
dir c:\windows\*.exe
But a root folder's name has a trailing backslash, expanding to e.g.:
dir c:\\*.exe
The double backslash then causes an error.
The solution is to use %1.\ instead of %1\
dir %1.\*.exe
Now listexes.bat works for all folders, including root folders.

B.t.w. this might also explain why in the other situation my source used
%1.\ instead of %1 It may have been just a case of routinely using %1.\
whenever %1 is a folder, rather then a DOS version thing.
 
O

omega

Sietse Fliege said:
[syntax for w9x batch files used contextually]

One thing to note:
Suppose you have a listexes.bat that lists all .exe files in a folder :
dir %1\*.exe
When %1 is e.g. c:\windows then the command, with %1 expanded, becomes:
dir c:\windows\*.exe
But a root folder's name has a trailing backslash, expanding to e.g.:
dir c:\\*.exe
The double backslash then causes an error.

Oops!

(console says)
okay: dir C:\\*.exe
Invalid directory
The solution is to use %1.\ instead of %1\
dir %1.\*.exe
Now listexes.bat works for all folders, including root folders.

(console says)
okay: dir C:\.\*.exe
(Volume is... etc)
Directory of C:\
(& gives listing of .exe files)
B.t.w. this might also explain why in the other situation my source used
%1.\ instead of %1 It may have been just a case of routinely using %1.\
whenever %1 is a folder, rather then a DOS version thing.

It sure does explain! I've fixed my batch files, and sworn over to the %1.\
for template. Thank you, Sietse! Your help is exquisite.
 
O

omega

Sietse Fliege said:
used %1.\ instead of %1\

:-(

Oh yeah, I was about to jump all over that typo that had slipped into the
one summary sentence. ;) But I got held up. Couldn't get over there, lodged
as I still was in my dyslexic quicksand of pifrun-runpif-pif.run.
 
O

omega

Sietse Fliege said:
Just now retried, no problem. :)

It was probably a problem at their end. The port5 service, it is free,
and it is clean. But as to overall performance, it scores fairly low.
I'd be up to paying for a service for this use, the occasionally file
and screenshot uploads for my ACF posts... But only if I could find a
super low rate (~$60/70 annum), so I wouldn't feel wasting money during
seasons of dormancy. And my other req, besides price, is harder. I don't
want to have to do a service involving domain registration, because of
the matter of privacy (publicized full name & address, etc).

Early this year, I did do one web shopping trip. I thought I found a
good candidate. At their site, I saw that they also had a free service,
so I decided to test drive that first, before upgrading with them to
a pay service. To complete the sign-up with them, it required that I
enable javascript permissions for their domain (my javascript default
setting is OFF for my msie-based browsers). So I did so. The next day,
I found that my home page had been changed. First time I recall being
"hijacked" like that, and needless to say, it's very offensive. But
good it happened: I'd have been most unhappy had I given #CC info to
a sleaze entity of that species.

Meantime, my next web shopping trip is in the distant back of my todo
list. I'm crossing my fingers that Port5 will provide performance that
is minimally acceptable, with only briefest occasions of bad weather.
 
S

Sietse Fliege

omega said:
(console says)
Invalid directory

This hopefully indicates thay Mr. Console is starting to show more
respect, as this time he did not say : "Invalid directory, BAD Girl"
Heh, heh.
 
O

omega

Sietse Fliege said:
This hopefully indicates thay Mr. Console is starting to show more
respect, as this time he did not say : "Invalid directory, BAD Girl"

Yep! I think he senses how you've come en scene to oversee those spats
and teach me how to fight back. :)
 
S

Susan Bugher

Sietse said:
This hopefully indicates thay Mr. Console is starting to show more
respect, as this time he did not say : "Invalid directory, BAD Girl"
Heh, heh.

Karen was wearing her "Computer Geek (male)" disguise. ;)

Susan
 
O

omega

Susan Bugher said:
Karen was wearing her "Computer Geek (male)" disguise. ;)

You made me realize: For the guys...they probably get scolded by
Sister Console, one of those strict nuns who whacks their knuckes
with a ruler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top