Jump to content

autorun -> send index of CD to text file


betlog

Recommended Posts

I like to keep a text file that contains a "dir /o:n /b >>CDindex.txt" for easy searching of my multitudinous media.

question:

How would I use something like VBscript to interrogate the inserted CD for it's label/name, so I can get autorun to exec the script, so that simply by inserting a CD/DVD it would write/update a text index file on my local drive?

Where each text/index file has the same name as the CD.

Link to comment
Share on other sites


Sorry if I was difficult to understand.

After I posted i tried writing a script to do what i wanted.. it seems to work a bit, but still errors.

Heres how it works:

1) a file called CDIndex.cmd is in \windows folder

----contents of file----

CDIndex.vbs %1

----

2) a file called CDIndex.vbs is also in \windows

---- contents of file----

Set Sh = CreateObject("WScript.Shell")

VolKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CD Burning\Current Media\Disc Label"

WriteKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Common Documents"

VolName = Sh.RegRead(VolKey)

WriteName = Sh.RegRead(WriteKey)

Command = "dir" & " " & Mid(Wscript.Arguments(1),2) & " " & "/o:n /b>" WriteName & "\" & VolName & ".txt"

Sh.Exec(Command)

--------

So basically Autorun (through a handler I made) passes "%L" (drive:/) to the .CMD, which calls the script and passes it the drive name (eg: w:/).

The script then checks the registry to get it's label (name)...

... and the default "my documents" folder location...

...and then does a "dir" command with some parameters...

...and pipes the output into a text file with the same name as the CD label.

So why does it constantly give a 'subscript out of range" error?

Is my syntax wrong?

Link to comment
Share on other sites

I don't have time to try it much, and I'm not sure if your "handler" passes the proper data on either, but this looks wrong:

Command = "dir" & " " & Mid(Wscript.Arguments(1),2) & " " & "/o:n /b>" WriteName & "\" & VolName & ".txt"

it's missing a & before WriteName for sure (I also moved a couple space chars)

Command = "dir " & Mid(Wscript.Arguments(1),2) & " /o:n /b>" & WriteName & "\" & VolName & ".txt"

Mind you, if you do it that way... You'll probably encounter some problems down the road. For the volume label, I'd use the FSO's Drive object instead, and for the common documents, FSO's GetSpecialFolders(43). Anyhow, now to the problem: you will most likely have several CDs with the same volume names (I'm sure I have at least a dozen with the same names). Also, I don't know why you even pass on the drive letter to a .cmd file to pass it on to a .vbscript, why not pass it on directly instead? Or even better, why even pass it on when your "handler" could do a much better job at listing/sorting/formatting the file list without external dependancies and (I'm assuming it's a program) has full access to API's and what not, and would run faster then launching 2 external interpreted scripts...

Anyways, I'll wait for feedback :)

Link to comment
Share on other sites

  • 3 weeks later...

Yeah, the syntax is probably missing an & - i was expanding my original code to see where the problem was.. and gave up midway.

I'm passing to the vbs from a cmd because i cant make an autorun handler that will execute a .vbs .... and all it really needs to pass is the drive letter.

Also, excuse my ignorance, but what is an FSO?

I'll assume its another registry key, and have a look for it later...but it doesn't sound like one.

And no, i make sure I name ALL my CDs/DVD's with the date and an alpha letter.

(if i burn something for someone else I couldnt care less, it's rare and i don't catalogue them)

eg:

20041002a (for today - cd 1)

20041002b (for today - cd 2)

etc

(it's not likely i'd ever burn more than 26 CDs in a day, but i'd go to "aa" "ab" ..."az" "ba" "bb"... "bz" etc if i ever did.)

|:)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...