How to get help for a batch script - quickly!
Posted: 16 Jun 2024 11:39
(Until original post is restored - copied from Wayback machine) - mods please update/modify if required and stick it or even repost it with your username. Update link in this post viewtopic.php?p=49133#p49133 to link to this (or other) post.
(post #1 by foxidrive):
The fastest way to get code that is robust and efficient is to clearly describe what you need to do and then let the programmers decide the best way to handle the job.
State which tools you'd like to use in your script or which utilities you can't use or leave it up to the volunteers. Read below on how to give good information about your task so the script you are given doesn't fail!
Batch files are often specific to your task because your filepaths, text, filenames and data are often used to write code that is both simpler and more efficient.
It makes it easy for people if you provide accurate details. The script you are given is designed to work in your specific situation and they will often add extra code to handle aspects that you may not have thought of. Personal information in your question can be disguised and is mentioned below.
If you hide your details by using fake names and fake paths and fake file information then nobody knows if you are using things like non-latin characters, or unicode, or poison characters for batch scripts. In these situations the volunteers can't include appropriate code to handle your special situations because they aren't aware you need it.
By providing poor information about your task the code you are given stands a good chance of failing.
Batch code is often written by analysing the characters and the patterns in text/numbers/paths/filenames that are being handled by the batch script. Wrong analysis, when all you have is wrong data, just leads to wrong batch code.
The layout of your text, numbers, paths, and filenames is also important when writing code so type over the sensitive details in your examples to disguise them but don't change the layout or length of these lines.
Please show respect to those people who give their free time to provide you with code by giving them accurate information about your task.
Come back later and tell them if the code helped you, and saying thank you after you receive some help doesn't cause hairy palms or bad luck so give that a shot too.
(post #2 by aGerman)
What happens in a thread when incorrect or poor details are supplied: is that the volunteers write a script based upon that information and the next post often comes from the question writer saying "It doesn't work!"
Often a very long series of posts begins where we try to ascertain what the problem is and how the code fails and then what the real details of the task are. The script has to be rewritten, and that just wastes the time of those volunteers who are giving you free code and it is terribly frustrating and unsatisfying for volunteers to have to re-write a script for the same task again.
Don't do this.
(post #3 by aGerman)
Problems with batch scripts happen for many minor reasons on a computer. The time spent in question/answers to find out these things can be reduced to only minutes rather than spanning days for several messages to go back and forth asking you what these things are.
This script bundles a number of these key points of information in a simple text format in Notepad for you to copy and paste into a message. The volunteers can often begin writing a script for you immediately and you can have your answer very quickly.
1) Visit this link to copy and paste the script from the initial post into a bat file:
2) run that script
3) and copy/paste its output into the next post in your thread:
"info.bat"
viewtopic.php?f=3&t=7420&p=49133#p49133
Here is an example of the text from the script (it has code tags added automatically).
Bugs and suggestions can be reported in this thread: viewtopic.php?f=3&t=7347
FAQ about what information this script provides and why:
*) Does the script spy on my data?
No. The script is designed to give a range of non-personal information and not to harvest any kind of private or sensitive data. It is designed to help you receive a solution to your task quickly, by giving essential and useful details for people to help you with your script.
*) Why do you need hundreds of lines of code to gather this information?
The changes in each Windows version and also user settings and permissions need to be checked and handled in different ways. The extra code you see is for all the extra ways of obtaining the same information in different computer setups.
*) Could the script change or damage my computer?
No. The script is written to read information without changing any of it. It writes a plain text file showing the information that is gathered and makes it easy for you to copy it and paste it into a reply. The file is deleted automatically.
*) Why do you want to know these details?
The changes in Windows settings means information is needed to write code that handles things like dates and times, and newest and oldest filenames and folders, and filesize sorting and other aspects. This provides the details in a quick and easy way for you.
Microsoft made a mistake in not providing ways to run scripts in any language or regional settings when using things like dates and times and DIR listings etc. These things change across different computers and cause the most frequently asked questions in batch file scripting.
*) Enabling Extensions and Delayed Expansion
Some commands change the way batch file commands work so that detail is needed too.
The usage of exclamation marks '!' is changed when Delayed expansion is enabled and it alters how environment variables are written and used within program loops.
*) Language
The language/locale name and the code page number can affect the way text characters are handled in languages other than English and it can also change batch scripts themselves. Special allowences need to be made in some cases for a script to work.
*) Missing files and path elements
Some checks are made to show if batch file commands are missing or the way they are accessed has changed. If there are missing files or they can't be accessed in the usual way then it shows a significant problem, and you can be informed and also helped to fix the issue.
The environment variables %path% and %pathext% have entries that cause batch scripts to fail if they are missing and so they are checked too.
Examples of external commands that are checked are findstr.exe, timeout.exe, sort.exe, mode.exe, ping.exe
*) Windows version and release
Different versions of Windows and levels within each version can have different commands, so this information lets the volunteers write code for your version of Windows without any delay.
*) DIR listing and pagefile.sys
If pagefile.sys is present it is used for the DIR format listing where the date/time/filesize format gives the volunteers these details to help them write code which uses them.
The figure of virtual RAM and reboot time are only two of the many small indicators that are assessed together to rule out certain problems if scripts fail or if computer performance is affected.
*) Permissions information
Some commands require elevation to higher administrative permissions and we can tell here what pointers to provide when there is a problem with a script which is known to require higher access levels.
*) Running the script is, of course, optional.
If you can provide accurate and good sets of details regarding your question/problem then you will still get people willing and interested to help you.
(post #1 by foxidrive):
The fastest way to get code that is robust and efficient is to clearly describe what you need to do and then let the programmers decide the best way to handle the job.
State which tools you'd like to use in your script or which utilities you can't use or leave it up to the volunteers. Read below on how to give good information about your task so the script you are given doesn't fail!
Batch files are often specific to your task because your filepaths, text, filenames and data are often used to write code that is both simpler and more efficient.
It makes it easy for people if you provide accurate details. The script you are given is designed to work in your specific situation and they will often add extra code to handle aspects that you may not have thought of. Personal information in your question can be disguised and is mentioned below.
If you hide your details by using fake names and fake paths and fake file information then nobody knows if you are using things like non-latin characters, or unicode, or poison characters for batch scripts. In these situations the volunteers can't include appropriate code to handle your special situations because they aren't aware you need it.
By providing poor information about your task the code you are given stands a good chance of failing.
Batch code is often written by analysing the characters and the patterns in text/numbers/paths/filenames that are being handled by the batch script. Wrong analysis, when all you have is wrong data, just leads to wrong batch code.
The layout of your text, numbers, paths, and filenames is also important when writing code so type over the sensitive details in your examples to disguise them but don't change the layout or length of these lines.
Please show respect to those people who give their free time to provide you with code by giving them accurate information about your task.
Come back later and tell them if the code helped you, and saying thank you after you receive some help doesn't cause hairy palms or bad luck so give that a shot too.
(post #2 by aGerman)
What happens in a thread when incorrect or poor details are supplied: is that the volunteers write a script based upon that information and the next post often comes from the question writer saying "It doesn't work!"
Often a very long series of posts begins where we try to ascertain what the problem is and how the code fails and then what the real details of the task are. The script has to be rewritten, and that just wastes the time of those volunteers who are giving you free code and it is terribly frustrating and unsatisfying for volunteers to have to re-write a script for the same task again.
Don't do this.
(post #3 by aGerman)
Problems with batch scripts happen for many minor reasons on a computer. The time spent in question/answers to find out these things can be reduced to only minutes rather than spanning days for several messages to go back and forth asking you what these things are.
This script bundles a number of these key points of information in a simple text format in Notepad for you to copy and paste into a message. The volunteers can often begin writing a script for you immediately and you can have your answer very quickly.
1) Visit this link to copy and paste the script from the initial post into a bat file:
2) run that script
3) and copy/paste its output into the next post in your thread:
"info.bat"
viewtopic.php?f=3&t=7420&p=49133#p49133
Here is an example of the text from the script (it has code tags added automatically).
Code: Select all
--------------------------------------------------------------------------------
Windows version : Microsoft Windows [Version 10.0.10586]
Product name : Windows 10 Home, 64 bit
Performance indicators : Processor Cores: 4 Visible RAM: 3857100 kilobytes
Date/Time format : (dd/mm/yy) 09.09.2016 17:49:19,49
__APPDIR__ : C:\WINDOWS\system32\
ComSpec : C:\WINDOWS\system32\cmd.exe
PathExt : .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Extensions : system: Enabled user: Enabled
Delayed expansion : system: Disabled user: Disabled
Locale name : de-DE Code Pages: OEM 850 ANSI 1252
DIR format : 27.08.2016 13:35 4.026.531.840 pagefile.sys
Permissions : Elevated Admin=No, Admin group=Yes
Missing from the tool collection: debug
FAQ about what information this script provides and why:
*) Does the script spy on my data?
No. The script is designed to give a range of non-personal information and not to harvest any kind of private or sensitive data. It is designed to help you receive a solution to your task quickly, by giving essential and useful details for people to help you with your script.
*) Why do you need hundreds of lines of code to gather this information?
The changes in each Windows version and also user settings and permissions need to be checked and handled in different ways. The extra code you see is for all the extra ways of obtaining the same information in different computer setups.
*) Could the script change or damage my computer?
No. The script is written to read information without changing any of it. It writes a plain text file showing the information that is gathered and makes it easy for you to copy it and paste it into a reply. The file is deleted automatically.
*) Why do you want to know these details?
The changes in Windows settings means information is needed to write code that handles things like dates and times, and newest and oldest filenames and folders, and filesize sorting and other aspects. This provides the details in a quick and easy way for you.
Microsoft made a mistake in not providing ways to run scripts in any language or regional settings when using things like dates and times and DIR listings etc. These things change across different computers and cause the most frequently asked questions in batch file scripting.
*) Enabling Extensions and Delayed Expansion
Some commands change the way batch file commands work so that detail is needed too.
The usage of exclamation marks '!' is changed when Delayed expansion is enabled and it alters how environment variables are written and used within program loops.
*) Language
The language/locale name and the code page number can affect the way text characters are handled in languages other than English and it can also change batch scripts themselves. Special allowences need to be made in some cases for a script to work.
*) Missing files and path elements
Some checks are made to show if batch file commands are missing or the way they are accessed has changed. If there are missing files or they can't be accessed in the usual way then it shows a significant problem, and you can be informed and also helped to fix the issue.
The environment variables %path% and %pathext% have entries that cause batch scripts to fail if they are missing and so they are checked too.
Examples of external commands that are checked are findstr.exe, timeout.exe, sort.exe, mode.exe, ping.exe
*) Windows version and release
Different versions of Windows and levels within each version can have different commands, so this information lets the volunteers write code for your version of Windows without any delay.
*) DIR listing and pagefile.sys
If pagefile.sys is present it is used for the DIR format listing where the date/time/filesize format gives the volunteers these details to help them write code which uses them.
The figure of virtual RAM and reboot time are only two of the many small indicators that are assessed together to rule out certain problems if scripts fail or if computer performance is affected.
*) Permissions information
Some commands require elevation to higher administrative permissions and we can tell here what pointers to provide when there is a problem with a script which is known to require higher access levels.
*) Running the script is, of course, optional.
If you can provide accurate and good sets of details regarding your question/problem then you will still get people willing and interested to help you.