Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Alias or Environment Variable -- is one better?

Dec
43
2
In a batch file, I can do this:

alias wrar = "C:\Program Files\WinRAR\Rar.exe" a -r -idcdp -m5 -rr10
Then when I want to create a RAR archive I can just do:
wrar archivename

I can also do this:
set wrar = "C:\Program Files\WinRAR\Rar.exe" a -r -idcdp -m5 -rr10
And then create a RAR archive with:
%wrar archivename

I've done it both ways and they both work. Is one better or preferable to the other?
 
In your example I think they both do the same thing. There might be slightly different parsing paths taken.
 
Well, in the second approach, you have type type the percent sign every time you want to use the command. So there's that.
 
Environment variables don't take parameters as aliases do ... show-stopper! Below, "divide" is an alias. I imagine that would be hard to do using an environment variable.

Code:
v:\> divide 6 by 4
1.5

v:\> divide 6 by
You dummy!

v:\> divide 6 bye 4
You dummy!

v:\> divide 7 by 2
3.5

And environment variables are inherited by external apps; aliases are not. Rar.exe (or any other program you might run) doesn't need to know that "wrar" means.
 
I use a rexx script to create .zip and .rar files. This basically creates a blank file, that can be opened in anything, such as fc/2 or wincmd. It just creates an empty zip file.

The ,ION is a fix for some programs putting quotes around the file name, and others not reading them as a result. Basically, it removes the quotes.

Code:
/**/
parse arg filename .
parse upper var filename . '.' ext
select
  when ext = 'RAR' then call newrar
  when ext = 'ZIP' then call newzip
  when ext = 'ION' then call fixion
  otherwise; nop;
  end
exit


newrar:
rartxt = '52617221 1a0700cf 90730000 0d000000 00000000'x
call stream filename, 'c', 'open write replace'
call charout filename, rartxt
call stream filename, 'c', 'close'
return


newzip:
ziptxt = '504B0506  00000000 00000000 00000000 00000000 0000'x
call stream filename, 'c', 'open write replace'
call charout filename, ziptxt
call stream filename, 'c', 'close'
return


fixion:
'gsar.exe descript.ion -o -s":034" -r""'
return
 
Just
Code:
set RAR=-r -idcdp -m5 -rr10
in your user (or system, but beware!) environment block.
RAR will read default options from this env.var.

Mine is set to
Code:
[C:\]$ set RAR
RAR=-m5 -mdE -mm -s -w"C:\Windows\TEMP" -idp -os
 

Similar threads

Back
Top