Home · Compatibility Lists · Support Forums · FAQ · News Archive · Articles · Submit News/Upcoming News
NT Compatible
advertisement


Forum overview » Software » How do I make a script that will... (1/1)

Reply New Poll

How do I make a script that will...
Author Message
Lotus
Senior Member


Posts: 286
From: East Coast
Joined: 2001-07-17
Member No.: 6444
Icon 2003-03-12 15:01:48

How do I make a script that will restart my computer automatically say every monday morning?

I had at one time a simple batch file that would restart my computer using scheduled task manager to execute it, but I can't find it, and there must be some new way to script the same thing to do it more efficiently.

Any ideas?

I know this sounds odd, but there is a reason behind it. Lets just say we have an employee at another office 30 miles away who can't even begin to restart a computer EVEN with written directions..so my manager asked if there was a way to automate it.

Post #122317
Edit Quote Print Solution Plonk Delete
DosFreak
Moderator


Posts: 3494
From: Warner-Robins, Georgia
Joined: 2000-02-03
Member No.: 1729
Icon 2003-03-12 15:32:10

You'll still have to use Task Scheduler even if your write a VB script.

Post #122319
Edit Quote Print Solution Plonk Delete
DS3Circuit
Senior Member


Posts: 739
From: Northeast PA
Joined: 2002-12-11
Member No.: 16192
Icon 2003-03-12 15:51:25

"How do I make a script that will restart my computer automatically say every monday morning"


As long as the Task Scheduler Service is running

You can script an entire reboot using the commands AT and the shutdown.exe resource kit tool (native in XP).

It shouldnt take more then one or 2 lines for a batch file.

Still it is easier to use the GUI portion of the task scheduler and just copy and paste the task where it is needed.

HTH

Post #122320
Edit Quote Print Solution Plonk Delete
AlecStaar
Account Disabled


Posts: 51
From: A discrete point in the Space-Time continuum...
Joined: 2001-02-09
Member No.: 5224
Icon 2003-03-12 16:17:59

"How do I make a script that will restart my computer automatically say every monday morning?"


Use VB! It's simple to use, easiest programming language there is...

"I had at one time a simple batch file that would restart my computer using scheduled task manager to execute it, but I can't find it, and there must be some new way to script the same thing to do it more efficiently."


Like DosFreak said, it still would demand using taskscheduler app in 2k/XP etc. but it is doable this way too using Windows Scripting Host scraps of code & the runtime engine for it.

"Any ideas?"


Yes, again... Visual Basic!

1.) A timer on the form, that periodically checks the Date via its date function formatting with DateToStr and Time via the TimeToStr functions formatting it

2.) Have it lastly doing a comparison every second while it's running

(That code goes right into the Timer control's ONTIMER event & using IF Then Else statements, you would either do nothing if the date & time do not match, OR restart the system (& there are TONS of examples of that restart or reboot the system code snippets out there online as freely available code in VB in fact, & even .OCX's you could use instead of looking it up in the Win32 API reference & having to do the #Declare statement for that API calls used.))

"I know this sounds odd, but there is a reason behind it. Lets just say we have an employee at another office 30 miles away who can't even begin to restart a computer EVEN with written directions..so my manager asked if there was a way to automate it."


That would do exactly what you want, without having to use WSH vb script  code in combination with taskscheduler...



APK

Post #122322
Edit Quote Print Solution Plonk Delete
CyberGenX
Senior Member


Posts: 642
Joined: 2000-09-15
Member No.: 4395
Icon 2003-03-12 16:55:26

Why is a person using a computer they cannot even restart! That's scary!

Post #122324
Edit Quote Print Solution Plonk Delete
Silver-Dagger
Senior Member


Posts: 138
Joined: 2002-04-07
Member No.: 8944
Icon 2003-03-12 18:09:42

I do this once a week after doing the autoupdate. I use task scheduler and a program called winkick.

Post #122329
Edit Quote Print Solution Plonk Delete
duhmez
Senior Member


Posts: 583
From: Canada, West siiiiiiiiiide!
Joined: 2002-04-26
Member No.: 9046
Icon 2003-03-12 18:48:14

they added a new command in 2k/XP. its called "shutdown"

!!

Just put shutdown in a batch file, and NAME THE BATCHFILE something OTHER than shutdown, like restart.bat

Then use task scheduler to run it.

Post #122331
Edit Quote Print Solution Plonk Delete
CyberGenX
Senior Member


Posts: 642
Joined: 2000-09-15
Member No.: 4395
Icon 2003-03-12 19:14:01

I tried to run shutdown.exe and nothing happens.

Post #122333
Edit Quote Print Solution Plonk Delete
mezron
Senior Member


Posts: 239
Joined: 2002-06-18
Member No.: 10530
Icon 2003-03-12 23:48:42

Try this...
Open a command prompt start->All Programs->Accessories->Command Prompt

then type in shutdown /?

that'll give you some options to use with shutdown. the /? option is pretty helpful when you need to use a command but aren't quite sure about how to use it. /? simply means help on this command.
Hope this helps

Jim

Post #122346
Edit Quote Print Solution Plonk Delete
Jasbo
Member


Posts: 46
Joined: 2002-12-01
Member No.: 15753
Icon 2003-03-13 04:11:14

%windir%\system32\shutdown.exe -r -t 00

Post #122351
Edit Quote Print Solution Plonk Delete
Tomay
Senior Member


Posts: 528
Joined: 2001-10-09
Member No.: 7238
Icon 2003-03-13 06:02:26

Any of you guys knows how to hibernate a computer. I can't do it with the shutdown command.

Post #122356
Edit Quote Print Solution Plonk Delete
Lotus
Senior Member


Posts: 286
From: East Coast
Joined: 2001-07-17
Member No.: 6444
Icon 2003-03-13 08:05:03

"Why is a person using a computer they cannot even restart! That's scary!"


Very scary hehe

Post #122359
Edit Quote Print Solution Plonk Delete
Lotus
Senior Member


Posts: 286
From: East Coast
Joined: 2001-07-17
Member No.: 6444
Icon 2003-03-13 08:18:38

"Try this...
Open a command prompt start->All Programs->Accessories->Command Prompt

then type in shutdown /?
Jim"


Is this a Win2k Server command? I can't get it to work for Win2k Pro.

Post #122360
Edit Quote Print Solution Plonk Delete
mezron
Senior Member


Posts: 239
Joined: 2002-06-18
Member No.: 10530
Icon 2003-03-13 09:28:26

Try this...
Open a command prompt start->All Programs->Accessories->Command Prompt

then type in shutdown /?
Jim

Is this a Win2k Server command? I can't get it to work for Win2k Pro.

It's not built in like it is with XP. It's in the resource kit though. Sorry about that... just kinda assumed you were using XP for some reason

Post #122367
Edit Quote Print Solution Plonk Delete
AlecStaar
Account Disabled


Posts: 51
From: A discrete point in the Space-Time continuum...
Joined: 2001-02-09
Member No.: 5224
Icon 2003-03-13 13:01:36

Try this...
Open a command prompt start->All Programs->Accessories->Command Prompt

then type in shutdown /?
Jim

Is this a Win2k Server command? I can't get it to work for Win2k Pro.

It's not built in like it is with XP. It's in the resource kit though. Sorry about that... just kinda assumed you were using XP for some reason

Heh, I do that ALL the time myself... I insert alot of extra commands into my %WinDir%\System32 folder & forget that they are not native to the OS itself...

(The ONLY ones I recognize off-the-bat is the UNIX ports I keep online here for UNIX nuts like my brother who has used my systems in the past & will probably again in the future... occasionally I do myself, like in batches that need extension with those &/or reskit commandline tools (or other 3rd party ones I d/l'd from places like jsiinc.com which is loaded w/ them) or console mode apps I build in Delphi if I cannot find a 'turnkey' solution to d/l...)



Thing is though, I don't know if it IS native to XP or not... I do have it online here, but this setup is coming up on a year old now & over time I have forgotten EXACTLY what I extended the OS with in that folder!

APK

P.S.=> So, don't "feel bad" about that, I do it all the time myself! apk

Post #122382
Edit Quote Print Solution Plonk Delete
mezron
Senior Member


Posts: 239
Joined: 2002-06-18
Member No.: 10530
Icon 2003-03-13 23:21:07

"Thing is though, I don't know if it IS native to XP or not... I do have it online here, but this setup is coming up on a year old now & over time I have forgotten EXACTLY what I extended the OS with in that folder!
"


Man, I can't even count the times anymore I've said that too! But, yes it is included in the default install of XP Pro. Probably is in home also, but I'm assuming that as well...

Post #122408
Edit Quote Print Solution Plonk Delete
AlecStaar
Account Disabled


Posts: 51
From: A discrete point in the Space-Time continuum...
Joined: 2001-02-09
Member No.: 5224
Icon 2003-03-14 07:35:17

Thing is though, I don't know if it IS native to XP or not... I do have it online here, but this setup is coming up on a year old now & over time I have forgotten EXACTLY what I extended the OS with in that folder!


Man, I can't even count the times anymore I've said that too! But, yes it is included in the default install of XP Pro. Probably is in home also, but I'm assuming that as well...

You're probably right...

That's one (the shutdown.exe program) program that I did not recall installing manually here into my %WinDir%\System32!

Again, I do pile a ton of them into there (mostly character mode/DOS console window ones, so they are immediately accessible, well almost immediately, following the rule of programs looking first (programs being the command processor in this case) inside their OWN folder first, then to %WinDir%\system32, then in the current directory the OS is in, & then the systemwide environmental variable %PATH% last).

NT based Os' by default, use different approaches for 32-bit versus 16-bit apps.

===============================================

1.) For 32-bit apps, Windows NT searches for implicitly loaded DLLs at:

a. The .exe file directory.

b. The current directory.

c. The %SystemRoot%\SYSTEM32 directory.

d. The %SystemRoot% directory.

e. The directories in your Path.

* BUT if a DLL is listed as a KnownDLLs at this hive key/folder location:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager

With a type of REG_SZ entry & Value Name of the DLL without the extension and a data value of the DLL with the .DLL extension, then the search order then becomes:

aa. The %SystemRoot%\SYSTEM32 directory.

bb. The .exe file directory.

cc. The current directory.

dd. The %SystemRoot% directory.

ee. The directories in your Path.

** KnownDLLs are mapped at boot time. Rernaming or moving during a session has no effect.

You can alter this behavior by including the 8.3 DLL name in the ExcludeFromKnownDlls entry, a REG_MULTI_SZ value, & one per line in that comma delimited listing.

(This makes NT believe that the DLL is not listed in KnownDLLs.)

-------------------------------------------------------------------------------------------------

2.) For 16-bit apps, Windows NT uses KnownDLLs for both implicitly and explicitly load DLLs. The value is at:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\WOW.

Here in that key, KnownDLLs is a REG_SZ value that lists 8.3 DOS formatted DLL names, & is separated by spaces.

Without a KnownDLLs entry, WOW searches:

a. The current directory.

b. The %SystemRoot% directory.

c. The %SystemRoot%\SYSTEM directory.

d. The %SystemRoot%\SYSTEM32 directory.

e. The .exe file directory.

f. The directories in your Path.

With a KnownDLLs entry, WOW only searches for them in the %SystemRoot%\SYSTEM32 directory.

-------------------------------------------------------------------------------------------------

3.) Windows 2000 Service Pack #3 (at least, & thus probably XP also) has instituted the SafeDllSearchMode Value Name, a REG_DWORD data type, at this hive key folder:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager.

A value of 0 keeps the current search order, & a value of 1 makes Win2k & programs search for DLL's & programs in this order:

a. Their own folder first

b. %SystemRoot%\System32

c. %SystemRoot%

e. The current directory

f. The folders in your %PATH% environment variable.

===============================================

*

APK

P.S.=> So, if you ever want to change that, that's pretty much all the data you need to alter system-wide search paths for DLL's &/or EXECUTEABLES... apk

Post #122429
Edit Quote Print Solution Plonk Delete
mezron
Senior Member


Posts: 239
Joined: 2002-06-18
Member No.: 10530
Icon 2003-03-14 10:15:52

"So, if you ever want to change that, that's pretty much all the data you need to alter system-wide search paths for DLL's &/or EXECUTEABLES... apk"


Whoa! go easy on me there... I just woke up! haven't even had coffee yet!!

Thanks for the info though I never really knew how Windows dealt with search paths. I'll keep this though since I can remember a few times I've wondered what the order was for searching.

Jim

Post #122445
Edit Quote Print Solution Plonk Delete
AlecStaar
Account Disabled


Posts: 51
From: A discrete point in the Space-Time continuum...
Joined: 2001-02-09
Member No.: 5224
Icon 2003-03-14 10:29:42

So, if you ever want to change that, that's pretty much all the data you need to alter system-wide search paths for DLL's &/or EXECUTEABLES... apk

Whoa! go easy on me there... I just woke up! haven't even had coffee yet!!

Thanks for the info though I never really knew how Windows dealt with search paths. I'll keep this though since I can remember a few times I've wondered what the order was for searching.

Jim

Yup... having my coffee as I posted that (& as I reply to various job hunt sites etc. etc.)... nothing like a little "mental weight-lifting" to get your brain INTO GEAR!



* The nice part is, & not alot of folks know it, you can "tune" your system-wide hunt order for libraries & programs!

APK

Post #122446
Edit Quote Print Solution Plonk Delete

Related Threads RSS


Reply New Poll

Forum overview » Software » How do I make a script that will...

Legend
View   View profile
Solved   Mark this post as solution (topic starter only)
Quote   Reply with quote to post
Edit   Edit post
Delete   Delete post (admin only)

Moderator: Open / Close / Bump / Delete / Move / Merge

All products mentioned are registered trademarks or trademarks of their respective owners.
© 1998-2009 Esselbach Internet Solutions - All Rights Reserved. Terms and privacy policy
Website powered by Esselbach Storyteller CMS System