Solved

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

Posted on 2004-09-03
16
1,588 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

734 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