Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripting using Domain Startup

Status
Not open for further replies.

sromine

Technical User
Apr 21, 2006
38
US
If there is a better forum for this question, please feel free to move it or let me know and I will do it.

We have set it up on our domain server so that it points to a batch file (staff_maint.bat) on another server upon startup. This is done under whatever permissions the domain uses, which I believe is the system account.

It works to some extent, meaning the following command runs fine which just logs that the script has been looked at:

echo %DATE% %TIME% %COMPUTERNAME% %systemroot% access>>\\dclib3\MaintScript\log\maint_log.txt

but when I start adding a little meat to this script, such as making a call to another batch script (called weekly_xp.bat) that executes command such as the following, it does not work. It just hangs at the calling of the .exe file.....can anybody help me work through this? is this just a permissions issue, meaning system account limitations, or is there another way to accomplish it that will work. Thanks for any help you can give!

This is the command I use in the first script (staff_maint.bat) to call the below script:

IF "%computername%"=="LIBRSBVRT1" call \\dclib3\MaintScript\winxp\weekly\winxp_weekly.bat

this is the script that is not working. it gets here, because it logs Defrag_Start, but it does not execute the command.

rem ******** defrag primary hard drive c **************

echo %DATE% %TIME% %COMPUTERNAME% winxp weekly Defrag_Start>>\\dclib3\tech\MaintScript\log\maint_log.txt

call \\dclib3\MaintScript\winxp\scripts\Auto_Defrag\Defrag.exe -o2

echo %DATE% %TIME% %COMPUTERNAME% winxp weekly Defrag_End>>\\dclib3\tech\MaintScript\log\maint_log.txt



 
The answer to life the universe and everything is 42, but for your case I would say that vbscript is the answer you seek.

I suggest moving away from the old bat files and use vbscript via GPO. You could have one script that does everything, icluding having a section that checks the day of the week and processes code based on that.

My FAQ on the subject is quite thorough, take a look at it. faq329-5798. If you have questions after that post them in the vbscript forum and I will be happy to assist you.

To get you started, here is code to check the day of the week and do something based on the day. In this case I am just reporting the day of the week.

Code:
Today = Weekday(Date)

Select Case Today
	Case 1
		WScript.Echo "Today is Sunday"
	Case 2
		WScript.Echo "Today is Monday"
	Case 3
		WScript.Echo "Today is Tuesday"
	Case 4
		WScript.Echo "Today is Wednesday"
	Case 5
		WScript.Echo "Today is Thursday"
	Case 6
		WScript.Echo "Today is Friday"
	Case 7
		WScript.Echo "Today is Saturday"
End Select

Also, I see that you are calling a script to defrag the hard disk, why don't you simply schedule this to run at night on Fridays?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
I suggest sticking with what you're comfortable with - if that's batch, stick to it, there's nothing wrong with it.

So, rather than altering your entire process, why don't we try to figure out what's wrong.

What is the "-o2" parameter?

You generally don't CALL executables - you CALL other batch files. So, try using START instead of CALL - and unless you know the -o2 is appropriate, remove it. (When I do a defrag /? on XP, I get this:

Code:
defrag <volume> [-a] [-f] [-v] [-?]
  volume  drive letter or mount point (d: or d:\vol\mountpoint)
  -a      Analyze only
  -f      Force defragmentation even if free space is low
  -v      Verbose output
  -?      Display this help text

So... either the defrag command is wrong as well, or you are using a different defrag program.
 
Thanks for the quick responses!

I need to update my scripting language. I am very comfortable with msdos, but I am starting to make the move the vbscript. Love all the wmi stuff you can do.

As it turns out, lwcomputing pointed out the issue. I changed the call to start, and viola it worked! Thanks!

I am testing a defrag utility I found on the web, that is why I am using switches that are not familiar. I was looking around for a lightweight, quick, defrag utility that could be run under the system account. The following looked promising, and so far test look good. One of the specific claims it makes is "optimizing" the defrag by moving folders to the front of the hard drive.


Once again, thanks for the input.
 
One of the specific claims it makes is "optimizing" the defrag by moving folders to the front of the hard drive.
Windows XP does this by default, going one step further and monitoring your program usage and putting the most frequently used programs to the fastest part of the drive.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
You guys were so helpful before, thought I would run something else by you.

I tried my first official Domain startup scripting project and it didnt work. What we were trying to accomplish is to make sure all of our systems time was in-synch with our domain server.....if it was a windows xp system, we called the following script. What happens is that it outputs TimeSynch Start into the log but never gets to TimeSynch_End...it seems to be hanging on the w32tm command...any ideas on why? do i not have it properly formatted? is this a command that cannot run during the domain startup phase? thanks for any help!

echo %DATE% %TIME% %COMPUTERNAME% TimeSynch_Start>>\\dclib3\tech\MaintScript\log\tslog.txt

w32tm /config /syncfromflags:domhier /update

echo %DATE% %TIME% %COMPUTERNAME% TimeSynch_End>>\\dclib3\tech\MaintScript\log\tslog.txt

 
Stop using a batch file for time sync.

The server holding the PDCe is your time source in your domain. All AD computers will automatically sync to that server every ~45 minutes. You need to just make sure that that server is syncing to an external time source. Using a batch file is causing the machines to sync more than they need to, and that's not recommended.

Configuring the Windows Time Service

Pat Richard, MCSE MCSA:Messaging CNA MVP
Want to know how email works? Read for yourself -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top