Jump to content

Inf Question


MCT
 Share

Recommended Posts

ive got this code

<snip>

[CDImage]
HKCR,"Folder\shell\MakeBootISO\command",,,"CDIMAGE.EXE -L"%here%" -h -j1 -m -o -B%11%\xpBoot.img %here% %target%"
HKCR,"Folder\shell\MakeDataISO\command",,,"CDIMAGE.EXE -L"%here%" -YD -N -H -X -o -m -D %here% %target%"

[Strings]
here = """%1"""
target = """%1.iso"""

it works, but how can i get the LABEL (-l) to show the name of the directory without the full path ? like current label is "G:\nLite XP" but i only want it to say "nLite XP"

Link to comment
Share on other sites


Yep, I get what you mean.

I'll put out a basic idea here, Alanoll knows this sort of a thing better....

The "CD" command will echo back the full path of where you are. There's some way to select only desired characters from the output (as in where you do "CD ~0,1" to select only the drive letter). So there has to be some way, to select only characters that start from the last position of slash, and pipe the output to a variable. After that, you can use that variable as your label (Eg: -l"%dirname%").

Link to comment
Share on other sites

It's indeed something like that! Darn, saw it somewhere a week or so ago... Trying to find it back....

EDIT:

May also specify substrings for an expansion.

    %PATH:~10,5%

would expand the PATH environment variable, and then use only the 5 characters that begin at the 11th (offset 10) character of the expanded result. If the length is not specified, then it defaults to the remainder of the variable value. If either number (offset or length) is negative, then the number used is the length of the environment variable value added to the offset or length specified.

    %PATH:~-10%

would extract the last 10 characters of the PATH variable.

    %PATH:~0,-2%

would extract all but the last 2 characters of the PATH variable.

So you need everything after X:\, so after the third character. Then I guess it would be %variable:~0,3%

Edited by Bâshrat the Sneaky
Link to comment
Share on other sites

Well in that case would it not be %CD:~3% i.e. no length just offset 3?

Anyhow, would the above only be effective if you CD to the directory first, and would the right click command only work on files located 1 level below root.

Link to comment
Share on other sites

I thought we couldn't put spaces in label name.

I'm not sure how your INF work but if you pass %1 argument somewhere, then you can get what you want with %~n1 (extract only last name of path)

Type FOR /? at command prompt for more details.

Link to comment
Share on other sites

If the %1 is already stored, which it must be in order for the inf to run using it, then just creating a label="""%~n1""" string and changing the first %here% in each of the two keys may do it then!

I would have suggested this in my last post, but thought that the ~n expanded the filename, which of course we don't have cos we're right clicking a folder. Whereas ~p gave the path and ~d the drive letter etc.

[EDIT]

Tested it as above, it gives %~N1 as the LABEL

[/EDIT]

Edited by Yzöwl
Link to comment
Share on other sites

C:\Documents and Settings\Administrator>echo %CD:~3%
Documents and Settings\Administrator

Looks like it works to me...

EDIT: Nevermind, I misunderstood. I was never able to figure out a way to use system environment variables within INF files. I attempted that in the early days of my update pack when I was trying to put the date in the registry. I ended up giving up and added the entries with a batch file instead.

Link to comment
Share on other sites

ive tried with that too,

[CDImage]
HKCR,"Folder\shell\MakeBootISO\command",,,"CDIMAGE.EXE -L"%label%" -h -j1 -m -o -B%11%\xpBoot.img %here% %target%"
HKCR,"Folder\shell\MakeDataISO\command",,,"CDIMAGE.EXE -LDATA -YD -N -H -X -O -M -D %here% %target%"

[Strings]
here = """%1"""
target = """%1.iso"""
label = """%1:~3%"""

returns

G:\nlite XP~3

Link to comment
Share on other sites

to be quite honest, i don't know. But i do know that all of the above won't work :P

the %~n3 or whatever, won't work as that's for CMD PROMPT interpreter, and not the INF intepreter. Nor would any of the other commands involving the ~. However... I can create a workaround for when importing, but otherwise...

What you could do instead, is call a CMD file upon right clicking, in which you can use the ~.

The problem here is that, you can't do any fancy INF stuff, as it's the registry and rundll i believe that interprets the parameters. I could be wrong, and it is the COMMAND interpreter but never really looked into it :P I don't think the registry is capable of ~

Link to comment
Share on other sites

well, technically, you're sending info from the Registry to the CMD file.

CDIMAGE.EXE -L"%1:~3%" -h -j1 -m -o -B%systemroot%\system32\xpBoot.img "%1" "%1.iso"

The in the INF

[CDImage]
HKCR,"Folder\shell\MakeBootISO\command",,,"%11%\cdimage.cmd """%1""""

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...