Computing.Net > Forums > Programming > programming with batch files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

programming with batch files

Reply to Message Icon

Name: vande
Date: September 14, 2008 at 16:19:10 Pacific
OS: windows
CPU/Ram: amd
Product: Dell, Dell, Dell
Comment:

I wrote a batch file that does like this....... reminder this is for my grandma and i know you could do this task VIA scheduler

I wrote a simple batch file that starts defrag so that her computer defrags.....

What it does from the beginning is open a notepad and in that notepad I say this is about to defrag.... Now first thing is that to make the program finish and start defragging she needs to close the noptepad explaining to her that it is going to run..... How can I make the program just run?

Also there Is a CMD window behind it that if you close it , it will stop defragging but cant I stop this window from appearing by @echo off or something to that nature?


Also this is the simplest programming method I know of. How can I write some code besides a batch file that DOS can interperate by default ? Any free IDE's also ?

Learning in progress..........



Sponsored Link
Ads by Google

Response Number 1
Name: worldlibrary
Date: September 14, 2008 at 18:21:53 Pacific
Reply:

cls
@echo off
:start
echo You about to defrag
echo.
echo To defrag press a
echo To exit press b

SET Choice=
SET /P Choice= TYPE THE LETTER AND PRESS ENTER: -^>
IF NOT '%Choice%'=='' SET Choice=%Choice%
:: /I makes the IF comparison case-insensitive
IF /I '%Choice%'=='a' GOTO :go1
IF /I '%Choice%'=='b' GOTO :exit

echo "%Choice%" IS NOT VALID. PLEASE TRY AGAIN
cls
:GO1
your defrag instructions go here

goto start

:exit
cls


This is just a basic off the cuff for win xp

Save as defrag.bat and put a short cut on the desktop.


0

Response Number 2
Name: Mechanix2Go
Date: September 15, 2008 at 04:16:49 Pacific
Reply:

"OS: windows"

That narrows it right down.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: toast (by NoIdea)
Date: September 15, 2008 at 06:16:51 Pacific
Reply:

Save this as whateveryoulike.vbs

Dim fso, sh, r, s, pe
Set sh = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")

returnvalue = msgbox("Hi Nan! Do You Want To Defrag Now?",36, "Vande")
if returnvalue = 6 then
s = wshshell.Run("C:\WINDOWS\system32\dfrg.msc")
else
wscript.quit
end if


0

Response Number 4
Name: Mechanix2Go
Date: September 15, 2008 at 06:41:23 Pacific
Reply:

@echo off
choice defrag now ?
goto :%errorlevel%
:1
echo defrag
:2


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 5
Name: vande
Date: September 15, 2008 at 07:27:18 Pacific
Reply:

Save this as whateveryoulike.vbs

Dim fso, sh, r, s, pe
Set sh = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")

returnvalue = msgbox("Hi Nan! Do You Want To Defrag Now?",36, "Vande")
if returnvalue = 6 then
s = wshshell.Run("C:\WINDOWS\system32\dfrg.msc")
else
wscript.quit
end if


Vande: This post above looks like a scripting language that is not understood by default? Also in this below post
"@echo off
choice defrag now ?
goto :%errorlevel%
:1
echo defrag
:2"

Can you just say choice? will it understand yes or no?

Also I heard choice is not supported in win XP... I mean it seems to be working but........

Learning in progress..........


0

Related Posts

See More



Response Number 6
Name: Razor2.3
Date: September 15, 2008 at 10:05:53 Pacific
Reply:

sc config messenger start= demand
net start messenger
net send %computername% Defrag a go-go, baby.

Yes, I have been playing Viewtiful Joe all weekend, what of it?

0

Response Number 7
Name: toast (by NoIdea)
Date: September 15, 2008 at 11:04:47 Pacific
Reply:

Vande: This post above looks like a scripting language that is not understood by default?

Others will know but I believe on every machine since windows 98. Developed by microsoft.
All it does is open a message box like you see a million times a day and you click either yes or no. You don't think you could get away with posting malicious code on this forum do you?

Sorry worldlibrary your post seems to have got lost in the scrum


0

Response Number 8
Name: worldlibrary
Date: September 15, 2008 at 12:23:11 Pacific
Reply:

Oh I'm used to it.LOL

Say hasn't school started and homework being assigned. More batch file questions to come.

Off topic but funny:
______________________________
Last week at work a co-worker said he had lost his xp disk and couldn't reinstall xp pro.

They wanted to know where they could get one cheap.

I offered a brand new still in shrink wrap cd to him telling him the coa was missing but he could use the one off his pc.

For free......
A co-worker overhearing this piped up with yea but then you need to go get any missing drivers.

They then concluded that going to HP and ordering a cd was the best choice rather than my offer...what with the driver issue.

As the two walked away discussing going to hp and ordering the disk I could only laugh.

The disk I was offering was an HP disk.

:-) W.L.



0

Response Number 9
Name: vande
Date: September 16, 2008 at 14:57:59 Pacific
Reply:

sc config messenger start= demand

Ryan:

Well I was talking about this specific message posted above that this looks like a scripting language besides an MS-DOS one !!! Like a VBscript........ Hence the learning in progress :)

Learning in progress..........


0

Response Number 10
Name: vande
Date: September 16, 2008 at 15:04:37 Pacific
Reply:

Also what is meant by isn't homework offered? :) Im doing my homework by speaking with you guys, programming is new to me and I don't know where to start at all times :)
Also i believe NET SEND is one to transport messages over the network? Correct me if I am wrong . Lol Im working at a local level here so but I guess your theory could work right? You could just send the message locally like localhost or something to that nature?

Learning in progress..........


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: programming with batch files

Get last line with batch file www.computing.net/answers/programming/get-last-line-with-batch-file/17019.html

Installing with Batch File www.computing.net/answers/programming/installing-with-batch-file/15666.html

Open shortcut with batch file www.computing.net/answers/programming/open-shortcut-with-batch-file/16269.html