Getting a script to open when i logon to my computer.

I have a batch file i would like to open when i logon to my computer. I have entered it in the computer management program in the logon script box but when i reboot it does nothing.
Tha batch file is in a sub folder.
Folderis : Batch
Batch File is : StartUp.bat
What am i doing wrong, can anyone help me with this problem please.
jodyreidIT ManagerAsked:
Who is Participating?
The built in task scheduler in Windows XP allows tasks (or scripts) to be run at logon or when the computer starts.  Just go to start / programs / accessories / system tools / Scheduled Tasks.  Choose Add scheduled task and go through the wizard.  I believe the first screen allows you to select when the script should run.
Pete LongTechnical ConsultantCommented:
Running Batch files at Startup/Shutdown (Windows 2000)

You can run a batch file at either Startup or shutdown (or Logon/Logoff) from the Local Security Policy

Click Start >Run > type "gpedit.msc" {enter}

Navigate to the following location

Local Computer Policy >Computer Configuration >Windows Settings >Scripts


Local Computer Policy >User Configuration >Windows Settings >Scripts

In both locations you will see a set of scripts in the USER settings you set scripts for LOGON and LOGOFF. In the COMPUTER settings you will see scripts for STARTUP and SHUTDOWN

Add your .bat file to the appropriate script.
You could just add the batch file(or a shortcut to the batch file) to:
Start > All Programs > Startup.

This is the easy way to do it I would assume.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

jodyreidIT ManagerAuthor Commented:
I tried to add it to local security policy in startup but again the same result as adding it to the computer management. what could be stopping it from running. My computer is on a network running server 2000 and my computer is running windows xp. There is 1 script running to connect all paths to the  server. Would this stop the other batch file from running.
If yr script attempts to mount remote volumes, the network layer may not be ready yet while yr computer is already logged in, try to insert a delay before mounting drives. Just a hint... I have this here on 4 PC's, pretty slow to negociate their speeds with their hubswitch.

jodyreidIT ManagerAuthor Commented:
How can i delay my script from starting up. It is working fine now but it stops the network script from working. Is there a way to start my script 5 mins after the system starts up.
Thank you for all your help with this.
There are several methods, you could run your own time-killer, such as a very extended loop or a complicated display such as screensavers have, but many like to use a few of the tools in MS Resource Kit, which you may have or can D/L from MS website.  As you phrase it, I think the SOON command would be more to your liking, this schedules a job to run after #### (you specify) amount of time.  Some use a wait command, to wait/pause for a time time, others schedule AT for specific time.   Try SOON?
[on the web..]

SCHEDSMS.BAT [example of command use]

The Poor Man's Administrator Tools

[examples for SOON and SLEEP, extract follows]

If you ever need to create a fixed time delay in a batch file, but you do not have a copy of SLEEP.EXE from the NT Resource Kit available, just download PMSleep.bat (for Windows NT/2000) or PMSlpW9x.bat (for Windows 95/98).
These batch files use PING's -W switch to create a delay.
The following example will create a 1 minute delay in Windows NT and 2000:
Due to limitations in the MS-DOS 7 batch language, we need to add 1 to the number of seconds specified in Windows 95 and 98:
        CALL PMSLPW9X.BAT 61
This Windows 9x example will wait for 60 seconds, not 61.
You may also choose to download the latest Kix version from and use its SLEEP function within your batch file.
The following example will create a 1 minute delay:
        ECHO $RC = SLEEP 60 > %TEMP%.\SLEEP.KIX
This Kix script will work in all 32-bit Windows versions, as long as Kix is installed.
If interested in development, I recommend checking out KIX due to the extra enhancements that benefit the coder.  At one time it was at least an unsupported part of the MS Resource Kit, so it is not as suspect as some other 3rd party tools might be.
Do this.  Start ->  Run

Type:  regedit

Navigate to HKEY current user \ software \ microsoft \ windows \ currentversion \ run

Right click in the righthand pane.  Create a new string value.  Name it something

Right click on that string and click Modify.  Type in the absolute file path of your batch file. This will run every time you log on.

You might try adding the same key to hkey local machine as well.  The rest of the path will be the same.

As for scripting a delay into your file: create a .vbs file with the following code in it:

Set WshShell = WScript.CreateObject("WScript.Shell")
Wscript.sleep "xxxxxx"
'time in milliseconds...maybe 15000 or so - 15 seconds.
wshShell.Run "c:\path\batch.bat"
To delay, you can use the sleep.exe utility (from NT res kit) in yr script.
There is also an interesting utilty in this res kit which allows to start a script before you login, ie starting it as a service: autoexnt.exe. Let me know if you wanna know more, or if you do not have a copy of the sleep utility. But be sure yr pb is due to delays; are you sure it is even started? to check this, place a pause command in it, you should see it wait whatever happens since pause is a system cmd.
I'm not sure if the following would help, but it might at least be worth a try instead of trying to force a "sleep" or wait period on your script.

Set the following Group Policy values to "Enabled"

1) Computer Configuration\Administrative Templates\System\Scripts\:  Run logon scripts synchronously
2) Computer Configuration\Administrative Templates\System\Logon\: Always wait for the network at computer startup and logon

I have noticed a lot of network and script related problems that might be solved by one or both of these values being enabled.  You mentioned using WinXP on your local computer, so both of these options should be available in the Group Policy.  For Windows 2000 clients, only the first policy option is available because logons always wait for the network to initialize.
true, my long NT4 experience has masked the new bits of 2000 & XP!
While your logged into the computer, try navigating to the script, and see if you can run the script.  Couldn't it be a permissions issue?
jodyreidIT ManagerAuthor Commented:
I dont know if it is a permissions issue because I am running it as the administrator.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.