Welcome!

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

SignUp Now!

AutoRun.inf?

May
12,846
164
In another thread someone asked about running a batfile when an IPOD was plugged in. Another person suggested an AUTORUN.INF in the IPOD's root directory. This made me wonder if I could get an external storage device to mount on a drive letter of my choosing. I've almost got it (all but the AUTORUN.INF part).

Supposing the AUTORUN.INF mechanism works, I'd use it to run ASSIGN.BTM which resides on the removable media:

SET current=%@left[1,%@full[%0]]
ECHO Current drive letter: %current
INPUT New drive letter:` ` %%new
ECHO New drive letter: %new
ECHO select volume %current > v:\diskpart.scr
ECHO assign letter=%new >> v:\diskpart.scr
CDD v:\
v:\assign.btm

In order for the change of letter to take place without a reboot message the removable media must not be busy. Thus ASSIGN.BTM leaves (with CDD) if necessary, and the current BTM exits when V:\ASSIGN.BTM is invoked.

V:\ASSIGN.BTM says, simply

diskpart.exe /s v:\diskpart.scr
CDD %new:\

All that works. Maybe the AUTORUN.INF part is easy (maybe impossible); I haven't tried yet.
 
In another thread someone asked about running a batfile when an IPOD was plugged in. Another person suggested an AUTORUN.INF in the IPOD's root directory. This made me wonder if I could get an external storage device to mount on a drive letter of my choosing. I've almost got it (all but the AUTORUN.INF part).

Supposing the AUTORUN.INF mechanism works, I'd use it to run ASSIGN.BTM which resides on the removable media:
...

In order for the change of letter to take place without a reboot message the removable media must not be busy. Thus ASSIGN.BTM leaves (with CDD) if necessary, and the current BTM exits when V:\ASSIGN.BTM is invoked.

V:\ASSIGN.BTM says, simply

diskpart.exe /s v:\diskpart.scr
CDD %new:\

All that works. Maybe the AUTORUN.INF part is easy (maybe impossible); I haven't tried yet.

I assume your system contains your utilities on a drive to which the drive letter V is permanently assigned.

Regardless, the above scheme seems to be very useful as well for "inikey" usage of TCMD/TCC "on a stick".

BTW, your message did NOT arrive in my email...
 
On Fri, 23 Jan 2009 07:03:18 -0600, Steve Fábián <> wrote:


>I assume your system contains your utilities on a drive to which the drive letter V is permanently assigned.
>
>Regardless, the above scheme seems to be very useful as well for "inikey" usage of TCMD/TCC "on a stick".
>
>BTW, your message did NOT arrive in my email...

Hmmm! I can't get the autorun mechanism to work (and searching only turned up
folks who couldn't **keep** it from working. According to MS, this should work:

[AutoRun]
shellexecute="assign.btm"

Assign.btm becomes what happens when I double-click the external drive and it
appears on the context menu, but nothing happens when I plug in the drive and
Windows discovers it. It's a WD Passport. Any thoughts?
 
Try using open instead of shellexecute.

[autorun]
open=v:\tcmd9\tcc.exe /c v:\assign.btm

-Scott

vefatica <> wrote on 01/23/2009 08:30:48 AM:


> On Fri, 23 Jan 2009 07:03:18 -0600, Steve Fábián <> wrote:
>
>
>
> ---Quote---
> >I assume your system contains your utilities on a drive to which
> the drive letter V is permanently assigned.
> >
> >Regardless, the above scheme seems to be very useful as well for
> "inikey" usage of TCMD/TCC "on a stick".
> >
> >BTW, your message did NOT arrive in my email...
> ---End Quote---
> Hmmm! I can't get the autorun mechanism to work (and searching
onlyturned up

> folks who couldn't **keep** it from working. According to MS, this
> should work:
>
> [AutoRun]
> shellexecute="assign.btm"
>
> Assign.btm becomes what happens when I double-click the external drive
and it

> appears on the context menu, but nothing happens when I plug in the
drive and

> Windows discovers it. It's a WD Passport. Any thoughts?
>
>
>
>
 
On Fri, 23 Jan 2009 10:00:20 -0600, samintz <> wrote:


>Try using open instead of shellexecute.
>
>[autorun]
>open=v:\tcmd9\tcc.exe /c v:\assign.btm

That was the first thing I tried (in vain). MS says shellexecute works just
like open but lets you use associations.
 
But on most systems, .BTM won't be associated with anything....

FWIW, my 4NT-on-a-stick setup used ShellExecute= instead of Open=, but it just pointed to the executable:

Code:
[autorun]
UseAutoPlay=1
ShellExecute=usbbin\4nt\4nt.exe
Icon=usbbin\4nt\4nt.exe
Label=Portable 4NT


</PRE>
 
On Fri, 23 Jan 2009 10:55:41 -0600, Charles Dye <> wrote:


>---Quote (Originally by vefatica)---
>That was the first thing I tried (in vain). MS says shellexecute works just
>like open but lets you use associations.
>---End Quote---
>But on most systems, .BTM won't be associated with anything....

BTM has an association here. And part of it works. I get "AutoRun" on the
context menu and if I 2-click the removable drive in Explorer, I get the desired
autorun behavior. It's just not "auto".
 
I know that the icon entry works. Have you tried to launch an executable
just to see if it works?

-Scott

vefatica <> wrote on 01/23/2009 11:33:11 AM:


> On Fri, 23 Jan 2009 10:00:20 -0600, samintz <> wrote:
>
>
>
> ---Quote---
> >Try using open instead of shellexecute.
> >
> >[autorun]
> >open=v:\tcmd9\tcc.exe /c v:\assign.btm
> ---End Quote---
> That was the first thing I tried (in vain). MS says shellexecute works
just

> like open but lets you use associations.
>
>
>
>
 
I just re-read your message. If you double-click on the drive icon in My Computer it executes assign.btm but it does not autorun when first plugged in? Is that what you are saying?

There is a very good article and explanation on Wikipedia of AutoRun and AutoPlay. It's possible you have a policy setting in your registry that's blocking AutoPlay from running your file.

-Scott


Hmmm! I can't get the autorun mechanism to work (and searching only turned up
folks who couldn't keep it from working. According to MS, this should work:

[AutoRun]
shellexecute="assign.btm"

Assign.btm becomes what happens when I double-click the external drive and it
appears on the context menu, but nothing happens when I plug in the drive and
Windows discovers it. It's a WD Passport. Any thoughts?
 
Charles Dye wrote:
| FWIW, my 4NT-on-a-stick setup used ShellExecute= instead of Open=,
| but it just pointed to the executable:
|
|
| Code:
| ---------
|
| [autorun]
| UseAutoPlay=1
| ShellExecute=usbbin\4nt\4nt.exe
| Icon=usbbin\4nt\4nt.exe
| Label=Portable 4NT

Am I correct assuming that usbbin is a top-level directory on the stick? Is
it possible to specify additional parameters for 4nt (e.g., location of .ini
and 4start) on the ShellExecute= line?
--
Steve
 
On Fri, 23 Jan 2009 11:33:45 -0600, samintz <> wrote:


I just re-read your message. If you double-click on the drive icon in My Computer it executes assign.btm but it does not autorun when first plugged in? Is that what you are saying?

There is a very good article and explanation on Wikipedia of AutoRun and AutoPlay. It's possible you have a policy setting in your registry that's blocking AutoPlay from running your file.

I've seen several such articles. It's a brand new machine and I have not
monkeyed with any such settings.

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun
has the default value 0x91 which, as I understand it forbids autorun for
DRIVE_REMOTE (network) and DRIVE_UNKNOWN. TCC identifies the external HD as
DRIVE_FIXED.
 
Am I correct assuming that usbbin is a top-level directory on the stick? Is
it possible to specify additional parameters for 4nt (e.g., location of .ini
and 4start) on the ShellExecute= line?

Yes, USBBIN is a (the) top-level directory. And yes, you can specify additional parameters. Locations, however, are not a good use. At the time you create AUTORUN.INF, you have no way of knowing how the drive will be mapped -- what drive letter it will be assigned, or even whether it will get a drive letter. Instead of hard-coding paths in AUTORUN.INF, you need to get them dynamically in 4START with e.g. %@PATH[%_CMDSPEC] and save in environment variables or directory aliases or whatever.
 
Another registry key to look at is
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers

There's a bunch of stuff in there including cancelling of AutoPlay based
on the file that it's supposed to run.

-Scott

vefatica <> wrote on 01/23/2009 01:05:14 PM:


> On Fri, 23 Jan 2009 11:33:45 -0600, samintz <> wrote:
>
>
>
> ---Quote---
> >I just re-read your message. If you double-click on the drive icon
> in My Computer it executes assign.btm but it does not autorun when
> first plugged in? Is that what you are saying?
> >
> >There is a very good article and explanation on Wikipedia of
> AutoRun and AutoPlay. It's possible you have a policy setting in
> your registry that's blocking AutoPlay from running your file.
> >
> >[URL='[URL='http://en.wikipedia.org/wiki/Autorun']http://en.']http://en.wikipedia.org/wiki/Autorun[/url]']http://en.[/URL]
> wikipedia.org/wiki/Autorun[/url][/URL]
> ---End Quote---
> I've seen several such articles. It's a brand new machine and I have
not

> monkeyed with any such settings.
>
>
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoDriveTypeAutoRun

> has the default value 0x91 which, as I understand it forbids autorun for
> DRIVE_REMOTE (network) and DRIVE_UNKNOWN. TCC identifies the external
HD as

> DRIVE_FIXED.
>
>
>
>
 
Charles Dye wrote:
| ---Quote (Originally by Steve Fábián)---
| Am I correct assuming that usbbin is a top-level directory on the
| stick? Is
| it possible to specify additional parameters for 4nt (e.g., location
| of .ini
| and 4start) on the ShellExecute= line?
| ---End Quote---
| Yes, USBBIN is a (the) top-level directory. And yes, you can specify
| additional parameters. Locations, however, are not a good use. At
| the time you create AUTORUN.INF, you have no way of knowing how the
| drive will be mapped -- what drive letter it will be assigned, or
| even whether it will get a drive letter. Instead of hard-coding
| paths in AUTORUN.INF, you need to get them dynamically in 4START with
| e.g. %@PATH[%_CMDSPEC] and save in environment variables or directory
| aliases or whatever.

That's basically what I have been doing for many years and many machines
with varying directory hierarchies. The only difficulty is specifying the
location of TCSTART / 4START (they are normally not in TCC's own directory),
but that's not critical - your method can redirect to the "real" one.

BTW, I just tested TCC9 B154, and it accepts paths relative to its own
location in .INI directives INCLUDE, TCStartPath, etc., which makes such
things much simpler.
--
Steve
 

Similar threads

Back
Top