Solved

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

Posted on 2004-09-03
16
1,584 Views
Last Modified: 2008-01-09
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.
0
Comment
Question by:jodyreid
  • 3
  • 3
  • 3
  • +6
16 Comments
 
LVL 57

Expert Comment

by:Pete Long
ID: 11975009
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

OR

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.
0
 
LVL 3

Expert Comment

by:SBPCGuru
ID: 11975051
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.
0
 

Author Comment

by:jodyreid
ID: 11975165
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.
0
 
LVL 28

Expert Comment

by:lesouef
ID: 11975405
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.


0
 

Author Comment

by:jodyreid
ID: 11976114
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.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 11976346
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?
0
 
LVL 24

Expert Comment

by:SunBow
ID: 11976413
[on the web..]
http://www.microsoft.com/technet/prodtechnol/exchange/55/support/upgrade2.mspx

SCHEDSMS.BAT [example of command use]

SOON.EXE \\EXCHSVR 5 /INTERACTIVE "C:\TEMP\INSTSMS.BAT"

http://www.robvanderwoude.com/index.html
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:
        CALL PMSLEEP.BAT 60
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 www.kixtart.org 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
        KIX32.EXE %TEMP%.\SLEEP.KIX
        DEL %TEMP%.\SLEEP.KIX
This Kix script will work in all 32-bit Windows versions, as long as Kix is installed.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 11976445
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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:mslunecka
ID: 11977787
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.

0
 
LVL 6

Expert Comment

by:mslunecka
ID: 11977809
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"
0
 
LVL 28

Expert Comment

by:lesouef
ID: 11980390
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.
0
 

Expert Comment

by:number_one
ID: 11983333
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.
0
 
LVL 1

Accepted Solution

by:
Catdaddy007 earned 250 total points
ID: 11984454
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.
0
 
LVL 28

Expert Comment

by:lesouef
ID: 11987669
true, my long NT4 experience has masked the new bits of 2000 & XP!
0
 
LVL 2

Expert Comment

by:meade470
ID: 12260073
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?
0
 

Author Comment

by:jodyreid
ID: 12260097
I dont know if it is a permissions issue because I am running it as the administrator.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now