Startup Script

  • Thread starter Thread starter Alle Swoner
  • Start date Start date
A

Alle Swoner

Is there anyway I can set a batch file to run each time Windows XP starts?

I notice an empty autoexec.bat in the root drive, is this still used for
Windows XP? Could I put some code in it?
 
That's AUTOEXEC.NT and is used to setup the environment for DOS applications running under
WinXP.

--
Dave




| Is there anyway I can set a batch file to run each time Windows XP starts?
|
| I notice an empty autoexec.bat in the root drive, is this still used for
| Windows XP? Could I put some code in it?
|
|
 
Once you've created the batch file, you can cause it to run at startup
several ways:

1) Place a link in the "Startup" folder of your start menu
2) Create a new string value in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run that points
to the batch file
 
There is NO AUTOEXEC.BAT in WinNT Based OS's and AUTOEXEC.NT is NOT processed at login.

--
Dave




"David Candy" <.> wrote in message Only set and path type commands in autoexec.bat are processed at user logon.
 
Show me a MS KB article, reference, or other MS document detailing how and when an
AUTOEXEC.BAT file is interpreted by NT based OS's (NT4, Win2K, WinXP and Win2003 Server) and
prove that I'm wrong.

--
Dave




"David Candy" <.> wrote in message Well you are wrong and I'm right as usual.
 
Two references:

1) http://support.microsoft.com/default.aspx?scid=kb;en-us;124551

Windows parses the AUTOEXEC.BAT file during startup by default, which
results in the appending of the path statement in the AUTOEXEC.BAT file to
the system path created by Windows.

APPLIES TO
.. Microsoft Windows 2000 Server
.. Microsoft Windows 2000 Advanced Server
.. Microsoft Windows 2000 Professional Edition
.. Microsoft Windows NT Workstation 3.5
.. Microsoft Windows NT Workstation 3.51
.. Microsoft Windows NT Workstation 4.0 Developer Edition
.. Microsoft Windows NT Server 3.51
.. Microsoft Windows NT Server 4.0 Standard Edition


2)
http://www.microsoft.com/resources/documentation/windowsnt/4/workstation/reskit/en-us/26_ini.mspx

How Windows NT Uses MS-DOS Configuration Files

During system startup, Windows NT adds any Path, Prompt, and Set commands
from the C:\Autoexec.bat file to the Windows NT environment variables and
then ignores the rest of the contents of C:\Autoexec.bat and C:\Config.sys.
If these files are not present when you install Windows NT, the Setup
program creates them. Setup also creates default Autoexec.nt and Config.nt
files.

John Eddy
Microsoft Newsgroups Administrator
 
Thank you John.

So it interprets the PATH statements, and only that, and will update the Registry with what
it finds and will do so at startup not at User Login.

So it is really there for legacy OS, upgrade reasons.

Now, the question is this.... Is
http://support.microsoft.com/default.aspx?scid=kb;en-us;124551 out of date and does not
reflect WinXP and Win2003 Server or is it that they don't parse AUTOEXEC.BAT and CONFIG.SYS
for PATH directives at all ?

--
Dave




|
| Two references:
|
| 1) http://support.microsoft.com/default.aspx?scid=kb;en-us;124551
|
| Windows parses the AUTOEXEC.BAT file during startup by default, which
| results in the appending of the path statement in the AUTOEXEC.BAT file to
| the system path created by Windows.
|
| APPLIES TO
| . Microsoft Windows 2000 Server
| . Microsoft Windows 2000 Advanced Server
| . Microsoft Windows 2000 Professional Edition
| . Microsoft Windows NT Workstation 3.5
| . Microsoft Windows NT Workstation 3.51
| . Microsoft Windows NT Workstation 4.0 Developer Edition
| . Microsoft Windows NT Server 3.51
| . Microsoft Windows NT Server 4.0 Standard Edition
|
|
| 2)
|
http://www.microsoft.com/resources/documentation/windowsnt/4/workstation/reskit/en-us/26_ini.mspx
|
| How Windows NT Uses MS-DOS Configuration Files
|
| During system startup, Windows NT adds any Path, Prompt, and Set commands
| from the C:\Autoexec.bat file to the Windows NT environment variables and
| then ignores the rest of the contents of C:\Autoexec.bat and C:\Config.sys.
| If these files are not present when you install Windows NT, the Setup
| program creates them. Setup also creates default Autoexec.nt and Config.nt
| files.
|
| John Eddy
| Microsoft Newsgroups Administrator
|
|
| David H. Lipman wrote:
| > Show me a MS KB article, reference, or other MS document detailing
| > how and when an AUTOEXEC.BAT file is interpreted by NT based OS's
| > (NT4, Win2K, WinXP and Win2003 Server) and prove that I'm wrong.
 
I'll let John E answer you.

You are the one disputing my statement. Therefore you are the one that would need to show proof. I specifically answered the person's question because I saw your wrong answer. However I did not contradict you but Replied to the poster.

Anyway typing autoexec in help gives this in The Command Shell Overview topic.

The following list describes the various types of variables in descending order of precedence:

1.. Built-in system variables
2.. System variables found in the HKEY_LOCAL_MACHINE hive
3.. Local variables found in the HKEY_CURRENT_USER hive
4.. All environment variables and paths set in the Autoexec.bat file
5.. All environment variables and paths set in a logon script (if present)
6.. Variables used interactively in a script or batch file
 
David said:
Thank you John.

So it interprets the PATH statements, and only that, and will update the Registry with what
it finds and will do so at startup not at User Login.

So it is really there for legacy OS, upgrade reasons.

Now, the question is this.... Is
http://support.microsoft.com/default.aspx?scid=kb;en-us;124551 out of date and does not
reflect WinXP and Win2003 Server or is it that they don't parse AUTOEXEC.BAT and CONFIG.SYS
for PATH directives at all ?
Hi

KB124551 applies to WinXP and Win2k3 Server as well, even if
it doesn't explicit state so.
 
Hi Torgeir:

What about the point of parsing. At startup or at User Login ?

--
Dave





| Hi
|
| KB124551 applies to WinXP and Win2k3 Server as well, even if
| it doesn't explicit state so.
|
|
| --
| torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
| Administration scripting examples and an ONLINE version of
| the 1328 page Scripting Guide:
| http://www.microsoft.com/technet/scriptcenter/default.mspx
 
With regards to 'So it interprets the PATH statements, and only that,' I
don't feel that is a proper statement, although it will end up being an
argument of semantics. The article does not state that that is all that
will happen.

I can tell you right now, in Windows XP, the autoexec.bat does not appear to
be used on startup, but is used on command.com, and regular set variables
are taken into account.

Here's what I did to test.

I have an autoexec.bat and an autoexec.nt. The autoexec.bat has a set
blah_dir to c:\blah, which is not reflected in autoexec.nt. That particular
entry has been there since I don't know when. If I check in Control Panel,
the blah_dir variable is not listed. If I start - run - cmd and run a
'set', it is listed.

So, as far as I can tell, XP is using that autoexec.bat, at least when
firing up a dos command window.

To answer your second question:
No, the article is not out of date, it simply does not directly apply to XP.
The autoexec.bat will be used when running command.com, and the
HKEY_CURRENT_USER:Software\Microsoft\Windows
NT\CurrentVersion\Winlogon\ParseAutoexec registry entry may very well work
to prevent that. Since the change may require a reboot, I haven't been able
to test it. It doesn't appear in my test that it does get read when the
machine boots up or when I log in.

So, maybe if the article was reworded to say that this particular registry
entry refers to the automatic processing of the autoexec.bat file in
general, then it could apply to XP too. I'm not looking at 2003 server at
all.

As far as I can tell, while I may not have fufilled your request for an
article, reference or whatnot proving that autoexec.bat will get used by
Windows XP (as well as the other NT based OS',) I do think I've provided
enough evidence that it is indeed used. If not, well, I'm sorry, this is
all I have to say on the matter.

Frankly, I don't know why I actually tried to talk about something outside
my role. I generally know better.

John Eddy
Microsoft Newsgroups Administrator
 
David said:
Hi Torgeir:

What about the point of parsing. At startup or at User Login ?
Hi

I don't know, but I tend to trust David Candy more than Microsoft's
documentation, so my bet would go to the "user logon" part.
 
They are applied AFTER user variables.

Also note that a variable in autoexec won't override a user or system variable. It has to be a new variable. For the path statement it is appended to the end of the existing path.
 
But you are right.

You could always ask Raymond C, his tweakui has this setting in it.

If you delete the autoexec.bat the userenv log goes spastic over it. If it's present then (for empty ones anyway) userenv makes no mention of it. Userenv is your logon activity. NT4 Resource Kit explains it in some detail.

NT3.51 Wks RK - says logon

ParseAutoexec REG_SZ 0 or 1

If the value is set to 1, AUTOEXEC.BAT is parsed when you log on to Windows NT. If the value is set to 0, AUTOEXEC.BAT is not parsed. This has no effect on the parsing of AUTOEXEC.NT or CONFIG.NT.


NT4 Wks RK - says startup

Files
Use in Windows NT



C:\Autoexec.bat
Path and environment variables are added to the Windows NT environment at system startup.




NT4 Wks RK - also says this
If any conflict exists between environment variables, Windows NT Workstation and Windows NT Server resolve the conflict in this way:

a.. System environment variables are set first.
a.. User environment variables defined in the System dialog box are set next and override system variables.
a.. Variables defined in Autoexec.bat are set last, but do not override system or environmental variables.


Note

Path settings, unlike other environmental variables, are cumulative. The full path (what you see when you type path at the command prompt) is created by appending the path contained in Autoexec.bat to the paths defined in the System option in Control Panel.


Autoexec.bat does NOT get read for command.com. But it's entries are already in the environment.
 
Thank you John !

--
Dave




| With regards to 'So it interprets the PATH statements, and only that,' I
| don't feel that is a proper statement, although it will end up being an
| argument of semantics. The article does not state that that is all that
| will happen.
|
| I can tell you right now, in Windows XP, the autoexec.bat does not appear to
| be used on startup, but is used on command.com, and regular set variables
| are taken into account.
|
| Here's what I did to test.
|
| I have an autoexec.bat and an autoexec.nt. The autoexec.bat has a set
| blah_dir to c:\blah, which is not reflected in autoexec.nt. That particular
| entry has been there since I don't know when. If I check in Control Panel,
| the blah_dir variable is not listed. If I start - run - cmd and run a
| 'set', it is listed.
|
| So, as far as I can tell, XP is using that autoexec.bat, at least when
| firing up a dos command window.
|
| To answer your second question:
| No, the article is not out of date, it simply does not directly apply to XP.
| The autoexec.bat will be used when running command.com, and the
| HKEY_CURRENT_USER:Software\Microsoft\Windows
| NT\CurrentVersion\Winlogon\ParseAutoexec registry entry may very well work
| to prevent that. Since the change may require a reboot, I haven't been able
| to test it. It doesn't appear in my test that it does get read when the
| machine boots up or when I log in.
|
| So, maybe if the article was reworded to say that this particular registry
| entry refers to the automatic processing of the autoexec.bat file in
| general, then it could apply to XP too. I'm not looking at 2003 server at
| all.
|
| As far as I can tell, while I may not have fufilled your request for an
| article, reference or whatnot proving that autoexec.bat will get used by
| Windows XP (as well as the other NT based OS',) I do think I've provided
| enough evidence that it is indeed used. If not, well, I'm sorry, this is
| all I have to say on the matter.
|
| Frankly, I don't know why I actually tried to talk about something outside
| my role. I generally know better.
|
| John Eddy
| Microsoft Newsgroups Administrator
 
My apologies, you are correct !
Albeit there is some confusion of when it is used in WinXP.

--
Dave




"David Candy" <.> wrote in message They are applied AFTER user variables.

Also note that a variable in autoexec won't override a user or system variable. It has to be
a new variable. For the path statement it is appended to the end of the existing path.
 
It is a compatability feature. So old software won't refuse to install. And if installed it's likely to work.

Microsoft's staff only know a little bit about windows. A programmer may be expert in memory management but know nothing more than you or I about any other aspect of Windows. It is a big program and beyond a single human's comprehension.

I suspect that something may happen at system startup. If you want to see get Srvany.exe: Applications as Services Utility from http://www.microsoft.com/downloads/...69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en and set up something like this

cmd /c set > c:\set.txt

This will list the variables when noone is logged on. Beware of security.

Also I would suspect setup, if upgrading, does stuff as well but I'll let you do multiple installs of XP to see exactly what.
 
Back
Top