Talk:Batch file

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Computing (Rated Start-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
 

Suggestion of better example of external, non OS-supplied command (cp.exe)[edit]

Regarding:

  • The commands may be built into the command processor (COPY), supplied with the operating system but not built into it (XCOPY invokes the Microsoft DOS program XCOPY.EXE), or may be any program (cp invokes the program cp.exe if present, an .EXE port of the Unix cp command, with essentially the same functionality as XCOPY.EXE).

Probably would be a bit clearer to those likely to look up this article imho if an Windows-centric example was provided along with minor other changes, i.e.

  • The command may be an "internal command" built into the command processor (COPY, TYPE, SET), an "external command" supplied with the operating system but not built into it (e.g., XCOPY invokes the console program XCOPY.EXE), or may be any other program within any directory in the PATH environment variable (e.g., "winword" invokes Microsoft Word on Windows if installed). — Preceding unsigned comment added by 69.247.27.45 (talk) 18:56, 24 November 2011 (UTC)


10 useful batch commands slightly broken[edit]

The "10 Useful Batch Commands, B.Arthur" link is slightly broken.

== Confusing "SET" command description batch file The following sentence under the "Uses" heading is very confusing.

"They are mainly used to use the "set" command, which sets a string to another, during the time the batch file is being processed."

Possibly the author meant:

  • "Batch files can be used to set global environment variables."
    • However, a "DOS" command shell in a modern Windows platforms runs in a virtual space, so simple "SET" commands cannot be used to modify global environment variables.
  • "Batch files often use environment variables, which are string keys that map to string values."
    • This is possibly useful information, but it should be in its own section and requires more than one sentence of explanation.

If the sentence is not replaced with something more informative, does anyone take issue with deleting it?

Johngiors 05:01, 22 February 2007 (UTC)

External link on this page leads to site with Virus.[edit]

Link: Laura Fairhead's .BATs (chess!) URL: http://lf.8k.com/BAT/BAT.HTM

page bat.htm contains signature of the HTML scrpt virus"HTML/Dldr.Agen.QV.7

Not only that, I think that the examples of bad things that can be done is not such a good idea. I think that talking about how to do loops and access executables that are installed with Windows using switches to perform specific functions is a great idea for examples and is one of the big reasons to make batch files but we don't have to show how to create havoc, unless maybe in a context of "watch out for infinite loops" or some link to bad programming techniques. (Dan Apr.12.2008)

I agree. I'm going to take them out. If anyone has a good justification for their existence, please note it here. akaDruid (talk) 10:52, 22 May 2008 (UTC)

IExpress.exe[edit]

IEXPRESS.EXE (included with windows xp) can be used to convert .bat to .exe according to: http://renegadetech.blogspot.com/2006/07/how-to-convert-bat-file-or-vbs-file.html L CuRtiS 21:23, 30 August 2007 (UTC)

IExpress is a packager, like any other setup packager (NSIS, INNO etc) or self extracting archiver (Winzip, Winrar). It just compresses and you specify what to run when it is uncompressed and it is packaged within an exe file (which is the uncompressor and executor). I don't think IEXPRESS applies here.(Dan Apr.12.2008)

Some people make batch files for fun that look like security programs[edit]

Videos on youtube (such as: My greatest batch file, or batch anti virus program) are harmless uneffective batch files that imitate or create a fake fictional security programs on a batch file. I also made one myself but I can't place it on here because the preview page doesn't align the command-lines correctly. —Preceding unsigned comment added by The guardians27 (talkcontribs) 21:44, 31 May 2008 (UTC)

Conflict over external link[edit]

The reference http://commandwindows.com has an introduction and discussion of batch files in Windows that should be very helpful to those consulting the batch file page. Yet when I add it to external links it is removed without comment. Why? —Preceding unsigned comment added by Urparticle (talkcontribs) 20:50, 14 July 2008 (UTC)

Please read the Wikipedia external links guideline. You're repeatedly spamming links to this one single website into numerous computing related articles. I suppose you have a conflict of interest with this website you're promoting. We can not allow this kind of spamming because this encyclopedia would then turn into a huge external link mess. Thank you for your understanding. Ghettoblaster (talk) 15:31, 15 July 2008 (UTC)
I find the use of the term "spamming" not only incorrect but offensive. I am not the first or the only contributor to reference this site. Have you even looked at it? It has no advertising and is of higher quality than some the sites which you are apparently pushing. It has been favorably mentioned by a number of reviewers. It would be a highly useful site for anyone wanting to learn about the Windows command line or batch files. You are being arbitrary. How do you justify some of the sites which you are leaving in the references when they are far less comprehensive or useful than my suggestion? Your statement of repeated spamming has no basis. Are you saying that no one can suggest links for more than one page? I think you have an agenda of your own. How do I take this to a less biased arbitrator?

Urparticle (talk) 16:12, 15 July 2008 (UTC)urparticle

Looking at the edit history of some of the articles in question (see: Special:Contributions/70.106.114.2, Special:Contributions/Urparticle), I see that I'm apparently not the only one who thinks this way. The fact that there is no advertisement (just now) is IMHO not relevant. Also, I'm eager to learn from you which sites I am apparently pushing. From a neutral point of view, I think it is always better to add external links to various different and independent sources (if at all possible). I'm pretty sure there are thousands of sites out there with similar quality, I see no point in adding this specific site to (the top of) the external links section of several computing related articles. However, this does not mean that you're site should not be added at all here on Wikipedia (considering the dosage). Ghettoblaster (talk) 17:10, 15 July 2008 (UTC)
Note that I'm sorry if the term "spamming" offended you, but I still think it was correct in this situation. Please see the Wikipedia Spam guideline for more information on this topic. Ghettoblaster (talk) 18:12, 15 July 2008 (UTC)
I repeat my question- have you actually looked at the site in question? There are certainly not thousands of sites of similar quality on this particular subject. And there are very few other than Microsoft's which attempt anything like the scope. I assume that you want quality in your links. Should not the criterion for adding a link be that it adds value for the reader interested in the particular subject? Should you not be willing to consider a link either as an addition or as a replacement for another link if it serves the reader better? At no time have you said anything about the content of the suggested link. You simply label it as spam with no explanation other than referring to the general guideline. What is your specific objection? Look at the second link on the present list of external sites. It lists some but not all of the Windows XP commands. It gives descriptions of the commands but says little specifically about batch files. Batch files are the subject aren't they? The reference I am suggesting has considerably more material and has an extensive discussion of various ways to write and use batch files. Please explain why the suggested link is not better than this existing link. A Wikipedia reader interested in Windows batch files would find a lot more information there than in the present link. That is why I suggest adding a link (or replacing one). The goal here is to improve the Wikipedia article. I say adding this link accomplishes that goal. If Wikipedia is to be open to new information from everybody then you cannot arbitrarily reject suggestions without checking their merit. I understand that you must get a lot of self-serving suggestions but this is a legitimate effort to add value to the Wikipedia article. The least you can do is to judge the suggestion on its merits.

Urparticle (talk) 19:44, 15 July 2008 (UTC)

I had a look at the site in question and yes, I agree with you that quality of content is important. I hope that – after reading the above-mentioned guidelines – you also agree with me that having a broad selection of useful external links is one aspect of quality. Therefore I added to my comment that a link to this site can be added where it is appropriate and adds relevant information which is not already present in the article itself or in other sites that are already linked. Just don't add links to a single website to multiple articles just for the sake of adding a link to this website.
If a contribution is challenged or disputed, it is the contributors job to convince other editors, why the content in question is (more) valueable to the article (than other content that is currently in it). The reason why I labeled your link as spam was because that this is what it apparently was per definition in the Wikipedia guideline. This does not necessarily mean that I think that all the other linked websites are better sources of information. So, instead of edit warring to get a certain link added to articles in Wikipedia, one should just add the suggestion to the article talk page stating why it supposedly improves the article (as you did here), wait some time to get other editor's feedback and if no one objects, one might go ahead and add it. Thank you for your understanding. Ghettoblaster (talk) 20:53, 15 July 2008 (UTC)
Unfortunately, I am not clear on the status of the suggested link. Is it under consideration or are you still rejecting it?Urparticle (talk) 22:42, 15 July 2008 (UTC)
By the way, I have attempted to add links only a few times and I have never done so, as you put it, "just for the sake of adding a link to this website." I have only suggested a link when it was completely relevant to the Wikipedia article and when it contained useful information in addition to what was already present. Sites suggested have no advertising and already have substantial traffic and reputation. You would know that if you checked them. I have only recently tried contributing to Wikipedia and I was unaware of the proper procedure so I seem to have inadvertently tripped one of your spam triggers. I can understand that you have to fend off a lot of self-aggrandizing people but this legitimate attempt to be helpful has not received a very friendly reception. Urparticle (talk) 23:10, 15 July 2008 (UTC)
Well, for the moment it's back in - I've reverted my recent revert. The link is (a) excellent, (b) virtually unique, as you pointed out, (c) completely advt free. (I reverted it with the "rv spammer" comment - without checking the link - on the strength of your having immediatly "tried again" when reverted by Ghettoblaster. As he says, talk it through. Kudos for having done so now)... oh, and welcome to Wikipedia! Snori (talk) 10:27, 16 July 2008 (UTC)
Thanks!Urparticle (talk) 16:58, 17 July 2008 (UTC)

Cryptic variable on DOS batch file[edit]

I saw on some webpage that "%~d0" returns the drive where the batch file is, so a bat file containing the single line

echo "%~d0"

would print "C:\" if the bat file were c:\foo\test.bat and "F:\" if the bat file were f:\baz\test.bat (irregardless from which disk it's called, it returns the drive containing the bat file)

Now, I tried googling that, but there's about a gazillion of spurious results caused by "D0". Does anyone know a reference page where that trick is documented (and also other) ? -- m:drini 20:10, 2 August 2008 (UTC)

The documentation for this "trick" is (somewhat confusingly) documented with the "for" command. Simply start cmd and type "help for". There's plenty of interesting stuff under "help set" and "help if" too I think. Bathterror (talk) 22:46, 29 August 2008 (UTC)

This isn't true. The examples given in the FOR command help are for a different type of expansion that actually works differently in batch files (it will tell you to add %%n rather than %n). To learn more about this expansion use the CALL /? command which is the only help file that tells you about what %~d0 (the parameter expansion in batch files). It only prints "C:" BTW. If you wanted it to print C:\ then you'd use:

ECHO "%~d0\"

to get

"C:\"

I hope this helps. --Cribrad (talk) 10:44, 28 May 2009 (UTC)

batch files[edit]

what is a good example of batch file and name a feature that identifies the example as being of the category —Preceding unsigned comment added by 219.89.203.156 (talk) 22:11, 23 September 2008 (UTC)

differences between bat and cmd on xp[edit]

http://stackoverflow.com/questions/148968/dos-batch-files-bat-vs-cmd

—Preceding unsigned comment added by 150.101.166.15 (talk) 06:57, 6 November 2008 (UTC)

Ignore the preceding. The first link provides several competing explanations, none of which is correct, while the second is merely one step on the way to the correct answer. [1] is the definitive explanation. --Vrmlguy (talk) 04:17, 23 January 2009 (UTC)

syntax[edit]

can it have a list of commands usable in batch files (excluding dangerous ones)? —Preceding unsigned comment added by Superlinka (talkcontribs) 19:46, 21 December 2008 (UTC)

I think it might be good to include a few examples of commands that are specific to batch files like GOTO and CALL. I'll see if I can get a list together and put them in the form of an example and suggest the edit to here. --Cribrad (talk) 08:44, 30 May 2009 (UTC)


Messy article[edit]

This article is a complete mess; too many examples, history section all messed up. I'm gonna try and tidy it up, please post anything in regards to my changes here. Veltas (talk) 13:52, 28 July 2010 (UTC)

BTM Extension[edit]

The article is about batch files in Windows, DOS and OS/2, yet we have an extension listed for third-party software that may or may not be included with any of these systems. I don't see the reason for this, if the BTM extension needs a home it belongs in a separate article. Veltas (talk) 15:05, 28 July 2010 (UTC)

Code page mismatch...[edit]

I've just reverted a poorly written refenece t this in the lead. See http://blogs.msdn.com/b/oldnewthing/archive/2005/03/08/389527.aspx for some interesting stuff about the issue - but imho this isn't enough of an issue to be in the intro, and probably not in the article at all because problems only occur with characters from 128 to 255 (so-called "extended characters") Snori (talk) 06:24, 6 November 2010 (UTC)

This article and WP:NOT ... is a command reference allowed?[edit]

Is it acceptable for Wikipedia to act as a command reference for programming languages? I am not sure if that is permissible or not, since it would seem to fall under "Wikipedia is not a guide".

The exceptions section I started is mostly intended to cover notable limitations and weirdness in the programming language. The recent addition by User:Joey-das-WBF about the TIMEOUT command is especially valuable since that is apparently not documented clearly by Microsoft anywhere.

Googling for TIMEOUT, limiting to the microsoft.com site is particularly unhelpful: http://www.google.com/search?hl=en&client=firefox-a&hs=myF&rls=org.mozilla%3Aen-US%3Aofficial&q=%22timeout.exe%22+site%3Amicrosoft.com&aq=f&aqi=&aql=&oq=&gs_rfai=

It would seem worthwhile to make a summary section of what batch file commands are available in each edition of DOS / Windows.

I see TIMEOUT was an NT 4.0 resource kit command, yet it is a standard part of Windows 7. So when did it go from an add-on to standard equipment? Microsoft is not helpful, apparently, but a direct review of EXE's in NT 4 and Windows 2000, etc would show where the transition occurred.

DMahalko (talk) 14:58, 16 December 2010 (UTC)

A how-to-use-batch-files article is really for a Wikibook, and not for the encyclopedia. How much how-to are we supposed to give in this article? --Wtshymanski (talk) 15:47, 19 January 2011 (UTC)
I think this article in general is getting a bit big. It could do with being pared down quite significantly - much of the stuff here is Google-fodder really. a_man_alone (talk) 16:32, 19 January 2011 (UTC)

The language syntax is a total disaster[edit]

Can someone PLEASE explain just what the heck is going on here? The escaping rules for EventCreate seem to go against everything else.

This makes no sense:

Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "/"
Event log result: /
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\"
Event log result: "

The randomly disappearing backslashes:

Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\foo"
Event log result: \foo
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\\"
Event log result: \
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\\foo"
Event log result: \\foo

Backslashes and Escaped quotes... bad combo:

Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D " """ "
Event log result: "
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D " """\ "
Event log result: "\
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D " \"""\ "
ERROR: Invalid argument/option - ''.
Type "EVENTCREATE /?" for usage.
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D " \\"""\ "
Event log result: \"\

The disappearing, reappearing backslashes:

Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D " \\"""w\ "
Event log result: \"w\
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D " \\w"""w\ "
Event log result: \\w"w\

Piping doesn't need escaping? Or it can, but it doesn't matter? What?

Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\^|more"
Event log result: \\^|more
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\\|more"
Event log result: \\|more
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\\"|more"
Internal error.
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\\"""|more"
Internal error.
 
Eventcreate /T Warning /ID 1 /L Application /SO "Source" /D "\\"""^|more"
Event log result: \"|more


I think this is probably why most people just give up on batch programming, and try doing things with something else that less ridiculously undocumentedly buggy. DMahalko (talk) 20:46, 17 December 2010 (UTC)

Looks like EVENTCREATE, a pretty recent external command, has peculiar escaping logic. Also that piping doesn't work as consistently and logically as it does in Unix-like operating systems. Neither is that surprising, and explains why traditional batch files have generally been used for very simple tasks compared with shell scripts. Snori (talk) 04:41, 18 December 2010 (UTC)
There's nothing like documenting the undocumented on Wikipedia. Source? Ummmm, Windows (XP) itself. :-)
EVENTCREATE /L application /ID 100 /T INFORMATION /D "\A \B \C \D \E \F \G \H \I \J \K \L \M \N \O \P \Q \R \S \T \U \V \W \X \Y \Z \a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \w \x \y \z"
Result: \A \B \C \D \E \F \G \H \I \J \K \L \M \N \O \P \Q \R \S \T \U \V \W \X \Y \Z \a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \w \x \y \z.
EVENTCREATE /L application /ID 100 /T INFORMATION /D "\0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \- \= \` \[ \] \\ \; \' \, \. \/ \< \> \? \: \~ \! \@ \# \$ \% \^ \& \* \( \) \_ \+ \"
Result: \0 \1 \2 \3 \4 \5 \6 \7 \8 \9 \- \= \` \[ \] \\ \; \' \, \. \/ \< \> \? \: \~ \! \@ \# \$ \ \^ \& \* \( \) \_ \+ "
EVENTCREATE /L application /ID 100 /T INFORMATION /D "\\ \\""" \\""" \\"
Result: \\ \" \" \
It appears that the only case being handled weirdly is \" which can be fixed by doubling the backslash to \\"
Set foo=%foo:\"=\\"%
DMahalko (talk) 01:23, 20 December 2010 (UTC)

Too much HowTo[edit]

Code examples are great. But this page looks like you are making a BATCH tutorial for beginners. --Carrot Lord (talk) 15:56, 21 January 2013 (UTC)

Impact of Batch File[edit]

Batch files are used to execute the DOS commands and other executable files and/or windows
applications.

Batch file execution in VB 6.0
=========================

It is very easy to execute the batch files or DOS commands or .exe files in visual basic 6.0 by using the 'Shell' built-in function.
For example, shutdown the system;

  1. Open a new batch file
  2. Type "shutdown -s -f" into the file
  3. Save the file in someone location (For example, "D:\shutdown.bat")
  4. Open a new Visual Basic Project
  5. Add a command button in VB form
  6. Goto code window and type the following
 Private Sub Command1_Click()
 Shell("D:\shutdown.bat")
 End Sub

Save the project ans run it.
For Restart; "shutdown -r -f"
For Logoff; "shutdown -l -f"
This is a simple example. Definitely it is help for improving this article. --Ananthakumar Selvaraj, SeA Microsystems 16:26, 6 March 2013 (UTC)

the "Early Windows" section[edit]

The "Early Windows" section starts: "Microsoft Windows was introduced in 1985 as a GUI Operating System alternative to text-based operating and was designed to run on MS-DOS." Wouldn't "GUI Operating Environment" be more accurate? The difference between early (Microsoft) Windows and current (Microsoft) Windows was that the early (Microsoft) Windows was a GUI overlay onto DOS. The later (Microsoft) Windows are full fledged Operating Systems. JsunX (talk) 16:19, 19 March 2013 (UTC)

Links to website containing advice on how to construct malicious .bat files[edit]

There appears to be some disagreement as to if we should keep link to a page that provides advice on producing potentially problematic .bat files. Can we attempt to come to some sort of consesnus on the matter without having to take it to WP:DR? Amortias (T)(C) 20:21, 14 July 2014 (UTC)

Hi. There does appear to be such a disagreement but the consensus is definitely strong: Wikipedia is not censored. The only point worth mentioning here is NawlinWiki removal of the sample code, which corresponds WP:NOTMANUAL, as the code does not significantly increase the understanding of all readers; only a small minority.
Best regards,
Codename Lisa (talk) 13:31, 15 July 2014 (UTC)