Autoexec.bat not working at restart

G

Guest

In Vista, I have a SUBST command in the C:\autoexec.bat file to assign a
local drive letter. It works OK from the DOS window. But the drive letter
assignment is not created after a restart. (I am logged in as the
administrator.)
This is a brand new Vista box (and my first exposure to Vista). Should the
drive assignment work?
 
A

Andrew McLaren

DJ said:
In Vista, I have a SUBST command in the C:\autoexec.bat file to assign a
local drive letter. It works OK from the DOS window. But the drive letter
assignment is not created after a restart. (I am logged in as the
administrator.)


Hi DJ

Vista is like Windows NT, 2000, XP and Server 2003 - it does not process the
C:\Autoexec.bat file on start-up. If such a file exits, Vista ignores it.
The autoexec.nt file in the System32 subdirectory is used to configure the
environment for MS-DOS applications, running in an NTVDM - but it doesn't
have any effect at all, for Win32 applications.

To run a command or set of commands every time you log in, you have a few
choices:

- configure a logon script; see
http://www.microsoft.com/resources/...s/en-us/lsm_profile_logonscript.mspx?mfr=true.
The script can be kept on the local C: drive, doesn't have to be on a
server. This is probably your most secure and reliable option. The "script"
can be a plain BAT file, or something more elaborate in VBScript or
PowerShell.

- add a command or batch file to these Registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software \Microsoft\Windows\CurrentVersion\Run
The first Key is per machine, ie, system-wide; the second is per user.
Since SUBST mappings are specific to each user's profile, you'd probably
want to do this in the User's profile. (If you map a drive with SUBST then
log on as a different user, you won't see the SUBST mapping any more). See
http://support.microsoft.com/kb/314866 for more details.

Autoexec.bat is a relic of DOS days. It isn't an idiom that really applies
to "grown-up" versions of Windows (NT, 2K, XP, Vista).

Hope it helps,
 
G

Guest

OK, thanks.

Andrew McLaren said:
Hi DJ

Vista is like Windows NT, 2000, XP and Server 2003 - it does not process the
C:\Autoexec.bat file on start-up. If such a file exits, Vista ignores it.
The autoexec.nt file in the System32 subdirectory is used to configure the
environment for MS-DOS applications, running in an NTVDM - but it doesn't
have any effect at all, for Win32 applications.

To run a command or set of commands every time you log in, you have a few
choices:

- configure a logon script; see
http://www.microsoft.com/resources/...s/en-us/lsm_profile_logonscript.mspx?mfr=true.
The script can be kept on the local C: drive, doesn't have to be on a
server. This is probably your most secure and reliable option. The "script"
can be a plain BAT file, or something more elaborate in VBScript or
PowerShell.

- add a command or batch file to these Registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
HKEY_CURRENT_USER\Software \Microsoft\Windows\CurrentVersion\Run
The first Key is per machine, ie, system-wide; the second is per user.
Since SUBST mappings are specific to each user's profile, you'd probably
want to do this in the User's profile. (If you map a drive with SUBST then
log on as a different user, you won't see the SUBST mapping any more). See
http://support.microsoft.com/kb/314866 for more details.

Autoexec.bat is a relic of DOS days. It isn't an idiom that really applies
to "grown-up" versions of Windows (NT, 2K, XP, Vista).

Hope it helps,
 
D

Darrell Gorter[MSFT]

Hello Andrew,
The autoexec.bat is not run, however it will be parsed during startup so
that environment variables will be picked up.
Commands in there are not run so the subst would be processed.
However entries like path statements should be parsed as would items like
set statements where you would be setting variables.
These entries should be appended to list of environment variables set by
the system.

Thanks,
Darrell Gorter[MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights
--------------------
|> From: "Andrew McLaren" <[email protected]>
|> References: <[email protected]>
|> In-Reply-To: <[email protected]>
|> Subject: Re: Autoexec.bat not working at restart
|> Date: Thu, 12 Jul 2007 17:10:08 +1000
|> Lines: 43
|> Organization: Not much ...
|> Message-ID: <[email protected]>
|> X-Priority: 3
|> X-MSMail-Priority: Normal
|> X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
|> X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16480
|> X-RFC2646: Format=Flowed; Original
|> X-MS-CommunityGroup-PostID: {85BC117E-EB4D-4A40-8760-CAA1BB6A4B66}
|> X-MS-CommunityGroup-ThreadID: F3B5FBBF-920E-42E4-AF25-5D88C62A9071
|> X-MS-CommunityGroup-ParentID: F3B5FBBF-920E-42E4-AF25-5D88C62A9071
|> Newsgroups: microsoft.public.windows.vista.general
|> Path: TK2MSFTNGHUB02.phx.gbl
|> Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.windows.vista.general:133584
|> NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
|> X-Tomcat-NG: microsoft.public.windows.vista.general
|>
|> > In Vista, I have a SUBST command in the C:\autoexec.bat file to assign
a
|> > local drive letter. It works OK from the DOS window. But the drive
letter
|> > assignment is not created after a restart. (I am logged in as the
|> > administrator.)
|>
|>
|> Hi DJ
|>
|> Vista is like Windows NT, 2000, XP and Server 2003 - it does not process
the
|> C:\Autoexec.bat file on start-up. If such a file exits, Vista ignores
it.
|> The autoexec.nt file in the System32 subdirectory is used to configure
the
|> environment for MS-DOS applications, running in an NTVDM - but it
doesn't
|> have any effect at all, for Win32 applications.
|>
|> To run a command or set of commands every time you log in, you have a
few
|> choices:
|>
|> - configure a logon script; see
|>
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-
us/lsm_profile_logonscript.mspx?mfr=true.
|> The script can be kept on the local C: drive, doesn't have to be on a
|> server. This is probably your most secure and reliable option. The
"script"
|> can be a plain BAT file, or something more elaborate in VBScript or
|> PowerShell.
|>
|> - add a command or batch file to these Registry keys:
|> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
|> HKEY_CURRENT_USER\Software \Microsoft\Windows\CurrentVersion\Run
|> The first Key is per machine, ie, system-wide; the second is per user.
|> Since SUBST mappings are specific to each user's profile, you'd probably
|> want to do this in the User's profile. (If you map a drive with SUBST
then
|> log on as a different user, you won't see the SUBST mapping any more).
See
|> http://support.microsoft.com/kb/314866 for more details.
|>
|> Autoexec.bat is a relic of DOS days. It isn't an idiom that really
applies
|> to "grown-up" versions of Windows (NT, 2K, XP, Vista).
|>
|> Hope it helps,
|> --
|> Andrew McLaren
|> amclar (at) optusnet dot com dot au
|>
|>
|>
 
A

Andrew McLaren

"Darrell Gorter[MSFT]" said:
The autoexec.bat is not run, however it will be parsed during startup so
that environment variables will be picked up.
Commands in there are not run so the subst would be processed.
However entries like path statements should be parsed as would items like
set statements where you would be setting variables.
These entries should be appended to list of environment variables set by
the system.


Hi Darrell

Well, you know I love you as a PSS brother-in-arms (retired, in my case).
But I must respectfully disagree, on this particular matter.

It is pretty easy to verify. On a Vista machine, edit C:\AUTOEXEC.BAT to
contain the following lines:

REM ************ top ***************
SET FOO=BAR
SUBST U: C:\Users
PATH=%PATH%;C:\Users
REM ************ end ***************

Now, reboot and log in.
Open a command prompt.
Run a "SET" command.
Observe that no %FOO% var is defined.
Ditto, no C:\Users has been appended to the %PATH%
And to confirm the SUBST had no effect, go to U: drive and observe the "The
system cannot find teh drive specified" error mesage.

In short, Windows has totally ignored the C:\autoexec.bat file. This is a
Good Thing: autoexec.bat would be a vector for a million securty exploits,
otherwise.

Just for completeness, add a line to C:\Windows\System32\Autoexec.nt saying
SET BAZ=BAR16
and reboot the system. Now go to a command prompt and do SET. Observe there
is no %BAZ% variable; again the Win32 system has ignored this value. Now run
the command "command" to start a COMMAND.COM session. Type a SET command,
This will show you the environment for the 16-bit NTVDM, created to host
COMMAND.COM. Here, there *is* a variable %BAZ%, equal to BAR16. So the NTVDM
does honour the autoexec.nt file - but not the C:\auotexec.bat.

I'm happy to be proved wrong :) but that's how it looks to me (and how I
understand Windows to work).

Best regards
Andrew
 
D

Darrell Gorter[MSFT]

Hello Andrew,
Being a PSS person, I did test this before posting and you are right it is
easy to test.
I actually looked at this about a month or so as well for a different
posting.
But I since it was your posting and I respect your knowledge of Windows, I
felt I needed to validate this one more time before I posted a reply to
this.
I added both a set variable and a path statement to the c:\autoexec.bat
file.
Set DGG-c:\DGG
Path=c:\tools
Rebooted the machine, opened an elevated cmd prompt
and ran "Set"
The path statement was appended to the end of my existing path statement
and the new variable appears listed in the output.
Subt is a command, not a environment variable and it isn't going to work. I
agree with that.
We only grab env variables from the autoexec.bat
The autoexec file is parsed on my Vista machines not sure why it isn't
being parsed on yours Andrew.
Now I didn't do the %path%, however the path statement in the autoexec was
just appended anyway.
Thanks,
Darrell Gorter[MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights
--------------------
|> From: "Andrew McLaren" <[email protected]>
|> References: <[email protected]>
<[email protected]>
<[email protected]>
|> In-Reply-To: <[email protected]>
|> Subject: Re: Autoexec.bat not working at restart
|> Date: Fri, 13 Jul 2007 12:53:55 +1000
|> Lines: 53
|> Organization: Not much ...
|> Message-ID: <[email protected]>
|> X-Priority: 3
|> X-MSMail-Priority: Normal
|> X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
|> X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16480
|> X-MS-CommunityGroup-PostID: {1E193615-B639-4F29-848B-206674D75DD7}
|> X-RFC2646: Format=Flowed; Original
|> X-MS-CommunityGroup-ThreadID: F3B5FBBF-920E-42E4-AF25-5D88C62A9071
|> X-MS-CommunityGroup-ParentID: 7B187BD4-9DA5-4B5C-88F0-C4CDBA233020
|> Newsgroups: microsoft.public.windows.vista.general
|> Path: TK2MSFTNGHUB02.phx.gbl
|> Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.windows.vista.general:134232
|> NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
|> X-Tomcat-NG: microsoft.public.windows.vista.general
|>
|> > The autoexec.bat is not run, however it will be parsed during startup
so
|> > that environment variables will be picked up.
|> > Commands in there are not run so the subst would be processed.
|> > However entries like path statements should be parsed as would items
like
|> > set statements where you would be setting variables.
|> > These entries should be appended to list of environment variables set
by
|> > the system.
|>
|>
|> Hi Darrell
|>
|> Well, you know I love you as a PSS brother-in-arms (retired, in my
case).
|> But I must respectfully disagree, on this particular matter.
|>
|> It is pretty easy to verify. On a Vista machine, edit C:\AUTOEXEC.BAT to
|> contain the following lines:
|>
|> REM ************ top ***************
|> SET FOO=BAR
|> SUBST U: C:\Users
|> PATH=%PATH%;C:\Users
|> REM ************ end ***************
|>
|> Now, reboot and log in.
|> Open a command prompt.
|> Run a "SET" command.
|> Observe that no %FOO% var is defined.
|> Ditto, no C:\Users has been appended to the %PATH%
|> And to confirm the SUBST had no effect, go to U: drive and observe the
"The
|> system cannot find teh drive specified" error mesage.
|>
|> In short, Windows has totally ignored the C:\autoexec.bat file. This is
a
|> Good Thing: autoexec.bat would be a vector for a million securty
exploits,
|> otherwise.
|>
|> Just for completeness, add a line to C:\Windows\System32\Autoexec.nt
saying
|> SET BAZ=BAR16
|> and reboot the system. Now go to a command prompt and do SET. Observe
there
|> is no %BAZ% variable; again the Win32 system has ignored this value. Now
run
|> the command "command" to start a COMMAND.COM session. Type a SET
command,
|> This will show you the environment for the 16-bit NTVDM, created to host
|> COMMAND.COM. Here, there *is* a variable %BAZ%, equal to BAR16. So the
NTVDM
|> does honour the autoexec.nt file - but not the C:\auotexec.bat.
|>
|> I'm happy to be proved wrong :) but that's how it looks to me (and how
I
|> understand Windows to work).
|>
|> Best regards
|> Andrew
|>
|>
|>
|>
 
A

Andrew McLaren

Hi Darrell,

Well, that's totally weird. Likewise, I respect your opinions highly,
because of your vast experience and deep knowledge. But I just tried it
again, using your SET and PATH example in C:\Autoexec.bat. They were
completely ignored, in both Windows and NTVDM/WoW environments. A SET
command showed no DDG var, and no C:\Tools appended to PATH, in either
CMD.EXE or COMMAND.COM. This was on a clean install of Vista Ultimate 32
bit, in a VM.

I guess if we sat down and worked through our method, we'd find some subtle
difference in what we're both doing.

Anyways, I dunno if anyone else is still listening, at this point :) I
think we'd both agree that the normal and natural place to set environmental
variables in Vista is in the Registry (preferably edited via the Control
Panel, System UI), *not* via autoexec.bat. And SUBST, etc command absolutely
have no effect from an autoexec.bat file!

Best regards
Andrew
 
D

Darrell Gorter[MSFT]

Hello Andrew,
I think I figured it out why we are seeing different results: it's UAC I am
willing to wager.
I have been opening elevated CMD prompts
When I open a CMD without elevation, I don't pick up the changes that are
in the autoexec.bat file.
When I open an elevated cmd prompt I see the changes from the autoexec.bat
file.
So are you opening elevated or non-elevated cmd prompts?

That is just strange.

Thanks,
Darrell Gorter[MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights
--------------------
|> From: "Andrew McLaren" <[email protected]>
|> References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
|> In-Reply-To: <[email protected]>
|> Subject: Re: Autoexec.bat not working at restart
|> Date: Sat, 14 Jul 2007 11:19:10 +1000
|> Lines: 23
|> Organization: Not much ...
|> Message-ID: <[email protected]>
|> X-Priority: 3
|> X-MSMail-Priority: Normal
|> X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
|> X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16480
|> X-MS-CommunityGroup-PostID: {9D44345E-0BE1-4CFE-BA89-19633D578E91}
|> X-MS-CommunityGroup-ThreadID: F3B5FBBF-920E-42E4-AF25-5D88C62A9071
|> X-MS-CommunityGroup-ParentID: 058CDAAD-4B5F-4F04-A5BF-6A7495EBE10C
|> X-RFC2646: Format=Flowed; Original
|> Newsgroups: microsoft.public.windows.vista.general
|> Path: TK2MSFTNGHUB02.phx.gbl
|> Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.windows.vista.general:134801
|> NNTP-Posting-Host: TK2MSFTNGHUB02.phx.gbl 127.0.0.1
|> X-Tomcat-NG: microsoft.public.windows.vista.general
|>
|> Hi Darrell,
|>
|> Well, that's totally weird. Likewise, I respect your opinions highly,
|> because of your vast experience and deep knowledge. But I just tried it
|> again, using your SET and PATH example in C:\Autoexec.bat. They were
|> completely ignored, in both Windows and NTVDM/WoW environments. A SET
|> command showed no DDG var, and no C:\Tools appended to PATH, in either
|> CMD.EXE or COMMAND.COM. This was on a clean install of Vista Ultimate 32
|> bit, in a VM.
|>
|> I guess if we sat down and worked through our method, we'd find some
subtle
|> difference in what we're both doing.
|>
|> Anyways, I dunno if anyone else is still listening, at this point :) I
|> think we'd both agree that the normal and natural place to set
environmental
|> variables in Vista is in the Registry (preferably edited via the Control
|> Panel, System UI), *not* via autoexec.bat. And SUBST, etc command
absolutely
|> have no effect from an autoexec.bat file!
|>
|> Best regards
|> Andrew
|>
|>
|>
 

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