This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 6751. |
Solve : MS-DOS 6.22 w MS Client TCP/IP need to email from batch file? |
|
Answer» There's quite a few Win98 PC's in the business WORLD still... |
|
| 6752. |
Solve : Batch file to remove old pgms on Flash Drive? |
|
Answer» Sorry, that title was hard to write, to explain what I'm wanting to do. Thanks for the suggestion.yeah why add a program in a less than a minute when you can write a program/script to do nearly the same thing over the span of a day or two.... Well, I guess I can think of several reasons... Robocopy MAKES this fairly simple. you can use a /PURGE switch to delete files that aren't in source from the destination. I'm sure the functionality could be made into a batch file if needed for XP or earlier. I won't be the one writing it, though I was just looking for some help, not a verbal Reprimand. I thought this was the DOS section. Guess I was wrong. I'll look for help elsewhere. My post was just an alternative suggestion as i know that utility works great and I don't know much batch. I understand where you're coming from though and hopefully someone is able to help.TheShadow, Often there are many piratical solutions to a problem. Yes, this is the DOS section, but it is generally understood that a windows solution may be offered. Few are really using MS-DOS on a PC. Use pf 'RoboCopy' is along the spirit of a command line job. Quote Robocopy, or "Robust File Copy", is a command-line directory replication command. It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was first introduced as a standard feature in Windows Vista and Windows Server 2008. The command is robocopy.IMHO the suggestion of using Photocopy fills the requirement you specified. Photocopy, or even Robocopy does not do what I want. I'm sorry for wasting everyone's time. Moderator.. Please close this thread. I'm done here. This is called mirroring, or one-way sync. The syntax is like this for Robocopy: Robocopy [source] [target] /MIR [source] is the reference folder (or root of a folder tree) [target] is the folder (or root of a folder tree) you want to keep up-to-date by reference to [source] Quote I'd now like to write a batch file, to do my Flash Drive cleanup for me, by comparing what's in my "Output" folder Assuming your 'Output' folder is E:\Output and your pen drive is drive N the following should make the pen drive exactly like the Output folder. Robocopy E:\Output N:\ /MIR If the pen drive was blank, the first time you ran that command, it would create, on the pen drive, a copy of whatever was in E:\Output, including any subfolders and their contents. If the pen drive was not blank, any files or folders not in E:\Output would be removed. If you then removed a file or folder from E:\Output or a subfolder below it, then ran it again, then the corresponding items would be removed from pen drive N:\ If you added a file or folder to E:\Output and ran the command, then those items would be added to pen drive N:\ If you edited or updated a file in E:\Output or its tree, it would be detected and would replace a file of the same name in the same place on N:\ I just tested this on a hard drive folder (source) and pen drive (target) and as far as I can see it does what you were asking for, TheShadow, so I'd be interested to hear why it doesn't do what you want, so I could suggest a modification or some other command line solution. Quote from: TheShadow on June 03, 2013, 12:39:34 PM Photocopy, or even Robocopy does not do what I want. Odd. when I did Robocopy /? I got the opposite impression. You have two folders and you want to remove files not present in A that are present in B. PURGE can be used for this. If you want to sync the entire folder (add new files and delete ones not present in the source) there is also the /MIR switch noted by Salmon Trout. Unless of course you aren't after the desired functionality at all and are focussed on having some sort of batch file for this purpose for whatever reason.Quote from: TheShadow on June 03, 2013, 09:05:19 AM I keep my Output directory up to date, almost daily, and I remove old, out of date, entries (files). But my Yeah, you want the /MIR function of robocopy. This is extremely powerful and also destructive if you use the wrong folders. Be careful. "N:\data folder" is the target drive Code: [Select]@echo off robocopy "E:\output folder" "N:\data folder" /FFT /R:0 /MIR /NP /FP /NDL /NJH /NJS Quote from: foxidrive on June 04, 2013, 02:10:01 AM Yeah, you want the /MIR function of robocopy.Good advice foxidrive! I normally throw a '/nocopy' switch onto the command line when testing a Robocopy script prior to full implementation. Thanks Ocalabob - I didn't know about the /nocopy switch. It goes to show how some things don't sink in even when when you read about them.I think the OP decided to take his ball home. It's likely that he got the replies by email, and found out the info, even if he doesn't want to play. |
|
| 6753. |
Solve : CMD MODE vs Device Manager show different values? |
|
Answer» I have a question regarding the command MODE and setting COM port SETTINGS and the VALUES displayed via device MANAGER and the registry (which are not consistent)?! |
|
| 6754. |
Solve : Why is 'pause' command usually skipped in a batch file?? |
|
Answer» I found several times that 'pause' command was not executed as EXPECTED in my batch files. It's usually executed after execution of several following commands. If one of following commands is 'exit' or 'shutdown', I can't FIND it's executed. How come?Give at least one actual EXAMPLE of code, preferably more, not a summary or description, where this happened. |
|
| 6755. |
Solve : Problem Writing Over Existing Files? |
|
Answer» I wrote a batch file that exports all of the registry hives, |
|
| 6756. |
Solve : copy files of multiple folders and rename them? |
|
Answer» I have list of folders like this! I want extracting them in one folder without losing the order ([MFT]Nuit_119 to [MFT]Nuit_128)Quote from: foxidrive on August 02, 2013, 10:24:59 PM If that doesn't work then explain how you want the 01.jpg 02.jpg etc files to be renamed. The third image gives no clue as to how they should all appear in one folder, as the filenames don't relate to the first two images at all.I said that I want extracting them in one folder considering that I have a list of chapiter(Folders) of manga like narutochapter01 to narutochapter200 I wish extracting all of them at once in one volume folder which contains nautochapter01 to chapter200's pictures I use CDisplayEx to read manga and it doesn't support subdirectories READING pictures forcing me to switch from folder to folder therefore I have to extract file from chap01 and then rename chap02's files and extracting them .... it does not matter For the filenames I just have to use Windows to rename them in bulk Please clarify the adjustment of the code because I am a total beginner in coding and I just learned how to say hello in cmd PS : tell me if you find another solution like alternative softwareI forgot to thank the helpers Test this in an empty folder, that contains some test folders with the JPG pictures. It will move them all into the empty folder and rename them. Code: [Select]@echo off for /f "delims=" %%z in ('dir *.jpg /b /s /a-d ') do ( for %%a in ("%%~dpz%\.") do ( move "%%z" "%%~nxa_%%~nxz" ) ) |
|
| 6757. |
Solve : About fetching files in folder whose name containing blank? |
|
Answer» Below is my program for comparing files in two folders. It works well if no space character exists in folder names. But if there is a space in folder name, it goes wrong from loop of "FOR /d %%H in (*) DO ". I tested this program with c:\av1\11 vs c:\av1\22. There is a sub-folder "kk yy" under c:\av1\11. |
|
| 6758. |
Solve : How to get Startup folder in all versions of Windows?? |
|
Answer» There seems several ways to get location of startup; such as Since there is no general method to get it, it causes another issue: how to know the version of Windows? There must be a way to know the version of Windows and then we can determine the way to get the Startup folder.Type VER at a cmd prompt.In my Windows 7, I typed "ver" in DOS Command and I got "Microsoft Windows [Version 6.1.7601]" which I can't get infer from it that this is a Windows 7 system. In my POSReady 2009, I got "Microsoft Windows XP [Version 5.1.2600]".Quote from: Stan Huang on June 05, 2013, 01:42:37 AM I typed "ver" in DOS Command and I got "Microsoft Windows [Version 6.1.7601]" which I can't get infer from it that this is a Windows 7 system. Yes you can. 1. http://www.robvanderwoude.com/ver.php 2. http://en.wikipedia.org/wiki/Ver_(command) Windows 1.0 1.04 Windows 2.0 2.11 Windows 3.0 3 Windows for Workgroups 3.11 3.11 Whistler Server Preview 2250 Whistler Server alpha 2257 Whistler Server interim release 2267 Whistler Server interim release 2410 Windows NT 3.1 3.10.528 Windows NT Workstation 3.5 3.5.807 Windows NT Workstation 3.51 3.51.1057 Windows NT Workstation 4.0 4.0.1381 Windows 95 4.0.950 Windows 95 OEM Service Release 1 (95A) 4.00.950 Windows 95 OEM Service Release 2 (95B) 4.00.1111 Windows 95 OEM Service Release 2.1 4.03.1212-1214 Windows 95 OEM Service Release 2.5 C 4.03.1214 Windows 98 4.1.1998 Windows 98 Second Edition 4.1.2222 Windows Millenium Beta 4.90.2476 Windows Me 4.90.3000 Windows NT 5.00 (Beta 2) 5.00.1515 Windows 2000 (Beta 3) 5.00.2031 Windows 2000 (Beta 3 RC2) 5.00.2128 Windows 2000 (Beta 3) 5.00.2183 Windows 2000 5.00.2195 Windows 2000 Professional 5.0.2195 Windows XP (RC 1) 5.1.2505 Windows XP 5.1.2600 Windows XP, Service Pack 1 5.1.2600.1105-1106 Windows XP, Service Pack 2 5.1.2600.2180 Windows XP, Service Pack 3 5.1.2600 Windows XP Professional X64 Edition 5.2.3790 Windows .NET Server interim 5.2.3541 Windows .NET Server Beta 3 5.2.3590 Windows .NET Server Release Candidate 1 (RC1) 5.2.3660 Windows .NET Server 2003 RC2 5.2.3718 Windows Server 2003 (Beta?) 5.2.3763 Windows Home Server 5.2.3790 Windows Server 2003 5.2.3790 Windows Server 2003, Service Pack 1 5.2.3790.1180 Windows Server 2003 5.2.3790.1218 Windows Longhorn 6.0.5048 Windows Vista, Beta 1 6.0.5112 Windows Vista, Community Technology Preview (CTP) 6.0.5219 Windows Vista, TAP Preview 6.0.5259 Windows Vista, CTP (December) 6.0.5270 Windows Vista, CTP (February) 6.0.5308 Windows Vista, CTP (Refresh) 6.0.5342 Windows Vista, April EWD 6.0.5365 Windows Vista, Beta 2 Preview 6.0.5381 Windows Vista, Beta 2 6.0.5384 Windows Vista, Pre-RC1 6.0.5456 Windows Vista, Pre-RC1, Build 5472 6.0.5472 Windows Vista, Pre-RC1, Build 5536 6.0.5536 Windows Vista, RC1 6.0.5600.16384 Windows Vista, Pre-RC2 6.0.5700 Windows Vista, Pre-RC2, Build 5728 6.0.5728 Windows Vista, RC2 6.0.5744.16384 Windows Vista, Pre-RTM, Build 5808 6.0.5808 Windows Vista, Pre-RTM, Build 5824 6.0.5824 Windows Vista, Pre-RTM, Build 5840 6.0.5840 Windows Vista, RTM (Release to Manufacturing) 6.0.6000.16386 Windows Vista 6.0.6000 Windows Server 2008 6.0.6001 Windows Vista, Service Pack 2 6.0.6002 Windows 7, RTM (Release to Manufacturing) 6.1.7600.16385 Windows 7 6.1.7600 Windows 7, Service Pack 1 6.1.7601 Windows Server 2008 R2, RTM (Release to Manufacturing) 6.1.7600.16385 Windows 8, RTM (Release to Manufacturing) 6.2.9200.16384 Windows 8 6.2.9200 Windows Server 2012, Developer Preview 6.2.8102 Windows Server 2012 6.2.9200 Also... How to determine what version of Windows you are running in a batch file http://thelostartofbatchscript.blogspot.co.uk/2010/09/how-to-determine-what-version-of.htmlIf you keep giving them the fish they will never learn to use google to learn how to fish. Give a man a fish ...he will eat for a Day... Teach a man to fish...and he'll sit in a boat all Day drinkin Beer...More... http://www.quoteland.com/topic/Teaching-Quotes/140/ after you teach a fish to swim Quote from: patio on June 05, 2013, 04:35:54 PM Give a man a fish ...he will eat for a Day...Give a man faith and he will starve to death praying for a fish...Quote from: Squashman on June 05, 2013, 04:26:19 PM If you keep giving them the fish they will never learn to use google to learn how to fish. The answers I have given in this THREAD are so very obvious, viz: Google for pages about the ver command, and check out Wikipedia, that I think fishing lessons may be pointless. |
|
| 6759. |
Solve : Tasklist not outputting to file when run from batch? |
|
Answer» Tasklist isn't outputting to file when run from a batch file. It will CREATE the file, just won't write anything to it. tasklist /fo csv>output.txtHm, that still gave me an EMPTY file when ran from a batch file.Quote from: bbman12 on June 06, 2013, 06:51:04 PM Tasklist isn't outputting to file when run from a batch file. It will create the file, just won't write anything to it. It works fine here - copy and pasted. You batch file isn't called tasklist is it?Quote from: foxidrive on June 06, 2013, 07:44:34 PM You batch file isn't called tasklist is it?Wow, I WOULD have never imagined that would affect anything. That fixed it, thanks.GOOD CATCH Foxidrive!!! Quote from: bbman12 on June 06, 2013, 07:54:26 PM Wow, I would have never imagined that would affect anything. That fixed it, thanks. Of course it will affect plenty! When a batch script finds a command which is not an internal command like DIR etc, it first looks in the current folder for a executable program or script with that name, if that fails it then searches through the folders listed in the PATH variable. If you name the batch the same as a command, if the batch finds itself first, it will call itself. You couild avoid this by using the extension as well as the name - tasklist.exe - in a batch script but it is very bad idea to name batch scripts the same as Windows commands. I think that is the 3rd time I have seen SOMEONE make that mistake this week. |
|
| 6760. |
Solve : Batch file Searching for directories or exe's? |
|
Answer» Hi I would just like you guys you do an amazing job on these forum. This is my first time at looking at building a batch file or anything like it, my project is building a uninstaller for my FS2004 graphics upgrade program which is about 95% OVERWRITES, hence the need for a backup which my inno installer creates. |
|
| 6761. |
Solve : Create CSV from filepath.? |
|
Answer» Hello people I would also like the program to be able to go fetch files into sub-directories. Next time you post here, explain the entire task, because changing the task after you have got some tested code means more work changing the code, and more testing. Quote from: foxidrive on August 01, 2013, 10:15:26 AM Next time you post here, explain the entire task, because changing the task after You are right and i am sorry for this. Although i did wrote up in the basic example that it could occur that files could be in different sub-folders; From First post : txt1.txt,4,\test1\txt1.txt,999 txt2.txt,4,\test1\txt2.txt,999 txt3.txt,4,\test1\txt3.txt,999 txt4.txt,4,\test2\txt4.txt,999 We see that, in the third variable, the folder changes from test1 to test2. I should have been more clever on this and i am sorry. Don't take this as an insult i don't want to get you wrong on this, i accept the blame for not being specific enough. All in all, as the final thing, i would like the program to be able to fetch all the files into the specified folder, which means the third variable (File) could be very short or very long depending of the tree in which the program is in. The files may also be in root directory. Like this : txt1.txt,4,\txt1.txt,999 txt2.txt,4,\test1\txt2.txt,999 txt3.txt,4,\test1\test3\test5\test7\txt3.txt,999 txt4.txt,4,\test2\test8\test11\test15\test19\lemay\olddisk\backup\txt4.txt,999 I tested your code (which is great btw thanks again) and i've manage to understand the %%~nxa and %%~nxb and %%~nxc thing and so on which as far as i understand it is the filepath while %%~nxa stands for the file name and %%~nxb is the folder right before in the tree and so on but i just don't have enough experience to code the tree as a variable. In other words, if you get into terminal and then go into that specific directory, then issue this command : dir /a:-D /b /s I would like the .csv to have a line for all the entries that shows up, which means those in the root directory and also those in the sub-directories (also goes on to sub-sub-directories...) EDIT : Just so you know for double help i double thanked you EDIT 2 : I've manage to find out that if i input "/R" right after the first "FOR" i get a recursive operation (i don't know if it's the good term but it simply means the operation is also applied to files into sub-folders)!C:\Users\Lemonilla>for /? | find "%~" | find "I" %~I - expands %I removing any surrounding quotes (") %~FI - expands %I to a fully qualified path name %~dI - expands %I to a drive letter only %~pI - expands %I to a path only %~nI - expands %I to a file name only %~xI - expands %I to a file extension only %~sI - expanded path contains short names only %~aI - expands %I to file attributes of file %~tI - expands %I to date/time of file %~zI - expands %I to size of file %~$PATH:I - searches the directories listed in the PATH %~dpI - expands %I to a drive letter and path only %~nxI - expands %I to a file name and extension only %~fsI - expands %I to a full path name with short names only %~dp$PATH:I - searches the directories listed in the PATH %~ftzaI - expands %I to a DIR like output line Hum yeah, i tried to set something like IF /i "%%~nxa"=="%~nx0" ( Set "dir=%%~nxb" Just so for the program into the file it would once set the main directory you know, and then i would have tried to tell it to input everything until he FINDS out that "dir=%%~nx(something)" it would stop. But i failed miserably. Help this is harder than vba Still no answer yet. I really hope somebody comes and help me finish this cause i have no clue what to do. I just don't get the FOR function under batch. It's very hard...Asking for help by PM is not how this site works. Now, if you show actual paths to folders and explain which folder you are launching the batch file in, and the folders you are processing then you will usually get something that works for your situation. It's a sad fact that many people show folders and filenames that are made up - and as a result they get code that doesn't work for them, because they forget details like you did, or the filenames and foldernames are important in the batch file.The Problem becomes knowing where you want your folder structure to start for the output. It has to be constant for it to work. In other words we really need to know what the base folder is and from there we could output the correct path into your CSV. So basically the base path pretty much has to be hardcoded. |
|
| 6762. |
Solve : vbs help? |
|
Answer» I have some code that is suppose to find y VALUES for -10->10 for an input y=mx+b formula. And then run _graph.bat with said points as arguments. I'm getting a lot of errors when I try to run it with any equation (type mismatch [string " "]). It is not very consistent as to which string it decides to pick, mainly bouncing between " " and m. Any help would be much appreciated. |
|
| 6763. |
Solve : Reg Query for Key Name; grab the key name to use as variable? |
|
Answer» Hello - |
|
| 6764. |
Solve : Remove veriable? |
|
Answer» So I am creating a batch file that will create a graph of points input as arguments. The issue arose when I try to add a feature to change the display characters. For some reason, when I go to remove the verable, it doesn't work for some, but works the rest of the time. F:\test_it>graph 1.2 4.6 6.7 9.3Are the results what I should expect from the script? Thank you!if we check the point (1,2) we know that it will be 1 to the right (on the x axis) and 2 up (on the Y axis). If the bottom left point is (1,1) then we count up one to get to (1,2) and find the point (represented by a "+"). checking the next point: (4,6) we would count right 3, and up 5 (because the bottom right is (1,1) ) we get the 2nd highest point. From what I'm seeing, they all seem to work. EDIT: also if you change line Code: [Select]0>nul set /p"=!cord%x%.%y%!" to Code: [Select]0>nul set /p"=!cord%x%.%y%! " (found under the flag :display_y.loop, 3rd block from the bottom.) (added a space before the 2nd quotation mark) You will get a much nicer looking graph, as it appears to be more to scale Code: [Select] C:\Users\Lemonilla\Documents\prog\bat\table>graph 1.2 4.6 6.7 9.3 - - - - - + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - C:\Users\Lemonilla\Documents\prog\bat\table> Correct me if I am wrong but most X,Y graphs I have seen all start at ZERO.The 9,3 plotting point looks weird/wrong.fixed to start on (0,0) Code: [Select]@echo off setlocal EnableDelayedExpansion REM Declare default signs set cordinate=+ set space=- REM Find the number of arguments set num_args=0 :loop set findArg_value=%1 set f |find "%findArg_value%" 1>nul 2>&1 if "%errorlevel%"=="0" ( set /a num_args+=1 set arg!num_args!=%1 shift goto loop ) set findArg_value= REM Check for modifyers goto :Modifyers.start :Modifyers.end REM Seperate coordinates into X and Y values set a=0 :find_argX/argY set /a a+=1 for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do ( set argX%a%=%%B set argY%a%=%%C ) if not "%num_args%"=="%a%" goto :find_argX/argY REM Find the max X and Y values set argX_max=0 set argY_max=0 set a=0 :find_argX.max/argY.max set /a a+=1 call set workingArgX=!argX%a%! call set workingArgY=!argY%a%! if %workingArgX% GTR %argX_max% set argX_max=%workingArgX% if %workingArgY% GTR %argY_max% set argY_max=%workingArgY% if not "%a%"=="%num_args%" goto :find_argX.max/argY.max set workingArgX= set workingArgY= set a= REM Create coordinate veriables for /l %%D in (0,1,%argX_max%) do ( for /l %%E in (0,1,%argY_max%) do ( set cordx=%%D set cordy=%%E set "cord!cordx!.!cordy!=!space!" ) ) set cordx= set cordy= REM Assign arguments to coordinates set a=-1 :cord.arg.loop set /a a+=1 call set cord!arg%a%!=!cordinate! if not "%a%"=="%num_args%" goto :cord.arg.loop set a= REM Display table set /a y=%argY_max%+1 :display_y.loop echo. set /a y-=1 set x=-1 :display_x.loop set /a x+=1 0>nul set /p"=!cord%x%.%y%! " if not "%x%"=="%argX_max%" goto :display_x.loop if not "%y%"=="-1" goto :display_y.loop set y= set x= REM Remove veriables from memory and exit for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do ( set %%Y= ) for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do ( set %%Z= ) set space= goto :end :Modifyers.start set a=0 set b=0 :check.loop set /a a+=1 :: Space Char if "!arg%a%!"=="/s" set /a b=%a%+1 if "!arg%a%!"=="/s" call set "space=!arg%b%!" if "!arg%a%!"=="/s" set arg%b%=0.0 if "!arg%a%!"=="/s" set arg%a%=0.0 set b=0 :: Coord Char if "!arg%a%!"=="/c" set /a b=%a%+1 if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!" if "!arg%a%!"=="/c" set arg%b%=0.0 if "!arg%a%!"=="/c" set arg%a%=0.0 set b=0 :: Help if "!arg%a%!"=="/?" ( echo Graphs coordinates on a coordinate plane. echo. echo Graph ^[^/c ^<char^>^] ^[^/s ^<char^>^] x.y x.y x.y ... echo. echo /c Defines what character the coordinates will be shown as. echo /s Defines what character the empty spaces will be shown as. echo. echo %%^^^&^)^=^|^;^"^<^>^,^! Cannot be used with /c or /s. goto :end ) :: No arguments if not defined arg!a! echo The syntax of the command is incorrect. if not defined arg!a! goto :end if not "%a%"=="%num_args%" goto :check.loop set a= goto :Modifyers.end :end Code: [Select]7 - - - - - + - - - 6 - - - + - - - - - 5 - - - - - - - - - 4 - - - - - - - - - 3 - - - - - - - - + 2 + - - - - - - - - 1 - - - - - - - - - 0 1 2 3 4 5 6 7 8 9 Will work on MAKING the numbering automaticWhat if I want to input 0.5?Code: [Select] C:\Users\Lemonilla\Documents\prog\bat\table>graph 0.5 + - - - - - C:\Users\Lemonilla\Documents\prog\bat\table>graph 0.5 6.9 - - - - - - + - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C:\Users\Lemonilla\Documents\prog\bat\table> Though if you enter in a negative value, you get a blank Y axis.Lemon, You seem to be using y,x plotting points instead of the x,y notation. Is there a reason for that?Code: [Select]C:\Users\Lemonilla\Documents\prog\bat\table>graph 0.5 6.9 Y 9 - - - - - - + 8 - - - - - - - 7 - - - - - - - 6 - - - - - - - 5 + - - - - - - 4 - - - - - - - 3 - - - - - - - 2 - - - - - - - 1 - - - - - - - 0 - - - - - - - 0 1 2 3 4 5 6 X No, I am using (x,y). (0,5) would be right 0 on the X and up 5 on the Y. http://nces.ed.gov/nceskids/createagraph/default.aspx?ID=5e30cb9e4c5248e1a899869b2c1b16f8BTW ...it's variable. |
|
| 6765. |
Solve : MS DOS program froze, now black screen, white flashing cursor? |
|
Answer» New and inexperienced comp. user. Have old computer, windows7, run a DOS -based program that froze. Now have black screen, white flashing cursor. What do I do? Researched familiar topics, but didn't understand lingo, BIOS, etc. I was running the dos based program, The Therapist, a practice management program. I load it in Windows, then use it without cursor, as it is very old, but has worked well for our purposes for years. So Windows 7 was running while I was using the dos program. I could not close the dos program, it opens to the opening screen, then I cannot go any further, nor can I close or reboot. I have to turn off the computer. Even then, when I turned it back on it was frozen in the same place. Windows 7 cannot run a full screen dos session, so it would seem that you were running Windows XP or earlier and it matters which version of Windows you were running because the options change. Do as suggested and repeatedly tap F8 while booting just before the Windows screen would appear - in the XP boot MANU that would appear there is an option to load recent settings that worked. The fact that your machine is only displaying a black screen is an added complication which could indicate a failed hardware component like hard drive etc.Thank you guys! From the bottom of my heart! Followed your instructions, pushed F8 and then #3, safe mode and it is now running through some procedures, opened safe mode. By the way, you were right, looks like I have Windows 8 on this computer. So now that I am in safe mode, how do I get back into running Windows normally? What I see on the screen is larger and appears different, but same desktop with "Safe Mode" in the corners. My instinct is to select the DOS prompt and run the THFIX utility from the Therapist program that froze and caused the problems. Would you agree? Then how do I return to NORMAL, or out of safe mode? I'll wait a little while to see if one of you has some opinion on what I should do next. Thanks again for helping! That's odd. Windows 8 doesn't have a full screen dos prompt either. Remove "the Therapist" from the startup and then boot normally to see if it's ok. You can then TRY launching "the Therapist" manually to see if it will run.He may also want to DLoad and install the XP compatibility pack from MS to run older apps... |
|
| 6766. |
Solve : reg query; 7 vs xp? |
|
Answer» Hello - |
|
| 6767. |
Solve : How to supress "Compare more file (Y/N)?"? |
|
Answer» In my system, it doesn't support 'fc' command. The only way I can do is to use 'comp' instead. But 'comp' always prompt "Compre more file (Y/N)?" which is not what I want. I want only its return code 'errorlevel'. How can I SUPPRESS its prompt?Quote from: Stan Huang on June 10, 2013, 05:23:45 AM In my system, it doesn't support 'fc' command. The only way I can do is to use 'comp' instead. What do you get when you type FC ? Is there something broken on your computer in this regard, like when you claimed that pause didn't work on your computer? Why can't you use FC?I typed 'fc' and the responsed message is: " 'fc' is not recognized as an internal, EXTERNAL command, operable program or batch file. My system is POSReady 2009. Something could be missed in system build. I APOLOGIZE again for the mistake about 'pause' last time.I used the following to supress any prompt and message: echo n > NNNN comp file1 file2 < nnnn > nul 2> null I works.Quote from: Stan Huang on June 10, 2013, 06:58:50 PM I typed 'fc' and the responsed message is: " 'fc' is not recognized as an internal, external command, operable program or batch file. Which version of Windows is it? What does it print when you type VER Quote from: Stan Huang on June 10, 2013, 07:23:25 PM I used the following to supress any prompt and message: STDERR is going into a file called null and you meant to use nul I presume.ver ==>> "Microsoft Windows XP [Version 5.1.2600]" null is typo of nulQuote from: Stan Huang on June 11, 2013, 01:32:09 AM ver ==>> "Microsoft Windows XP [Version 5.1.2600]" FC.EXE is in every NORMAL copy of XP according to google. Is your XP version a special build, or is it corrupted and files are missing? You can run SFC.EXE to check and replace the system files.That's not my PC. Its owner took my program to run. So, I don't know why it doesn't have popular command like 'fc.exe'. Anyway, I copied it from other system and it worked.In case it's not general knowledge, FC is not reliable in text mode. I think you are using it in binary mode but wanted to make that comment just in case. Here are some KB articles XP http://support.microsoft.com/kb/953929 http://support.microsoft.com/kb/953930 Vista/2008 http://support.microsoft.com/kb/953932 http://support.microsoft.com/kb/953931Quote from: Stan Huang on June 10, 2013, 07:23:25 PM I used the following to supress any prompt and message:IF IT WORKS, USE IT! |
|
| 6768. |
Solve : Script terminating without error? |
|
Answer» So my program is stopping without telling me the error (if there is one). So my program is stopping without telling me the error (if there is one). Replace that ::------------ line with PAUSE. See if it executes the pause or not. If it does then PLACE PAUSE further down. The call set command doesn't need a call though, does it?@No need for 'call set' No I guess it doesn't, good catch. @pause It does execute the pause, just not anything after it. Is there a limit on how many else if statements you can use? Code: [Select]pause if "!arg%a%!"=="/s" ( pause does first pause, not 2nd. EDIT: I managed to get it to run. It still isn't doing what it's suppose to though. Code: [Select]if "!arg%a%!"=="/c" set /a b=%a%+1 if "!arg%a%!"=="/c" call set "cordinate=!arg%b%!" if "!arg%a%!"=="/c" set /a c=%a%+2 if "!arg%a%!"=="/c" if not "!arg%c%:~0,1!"=="/" ( set arg%a%=!arg%c%! set arg%b%=!arg%c%! ) || ( set /a c+=2 if not "!arg%c%:~0,1!"=="/" ( set arg%a%=!arg%c%! set arg%b%=!arg%c%! ) || ( set /a c-=4 if not "!arg%c%:~0,1!"=="/" ( set arg%a%=!arg%c%! set arg%b%=!arg%c%! ) ) ) set c=0 It is suppose to look to the right and left 2 arguments and copy those. so '_graph.bat 1.3 /c o' would change "/c o" to "1.3 1.3"So I jumped through some hoops for this one, but I got it working. Code: [Select]@echo off setlocal EnableDelayedExpansion REM Declare default signs set cordinate=+ set space=- set zero=^& REM Find the number of arguments set num_args=0 :loop set findArg_value=%1 set f | find "%findArg_value%" 1>nul 2>&1 if "%errorlevel%"=="0" ( set /a num_args+=1 set arg!num_args!=%1 shift goto loop ) set findArg_value= REM Check for modifyers goto :Modifyers.start :Modifyers.end REM Seperate coordinates into X and Y values set a=0 :find_argX/argY set /a a+=1 for /f "tokens=1,2 delims=." %%B in ('call echo !arg%a%!') do ( set argX%a%=%%B set argY%a%=%%C ) if not "%num_args%"=="%a%" goto :find_argX/argY set a= REM Find the max X and Y values set argX_max=0 set argY_max=0 set a=0 :find_argX.max/argY.max set /a a+=1 call set workingArgX=!argX%a%! call set workingArgY=!argY%a%! if %workingArgX% GTR %argX_max% set argX_max=%workingArgX% if %workingArgY% GTR %argY_max% set argY_max=%workingArgY% if not "%a%"=="%num_args%" goto :find_argX.max/argY.max set workingArgX= set workingArgY= set a= REM Find the min X and Y values set argX_min=0 set argY_min=0 set a=0 :find_argX.min/argY.min set /a a+=1 call set workingArgX=!argX%a%! call set workingArgY=!argY%a%! if %workingArgX% LSS %argX_min% set argX_min=%workingArgX% if %workingArgY% LSS %argY_min% set argY_min=%workingArgY% if not "%a%"=="%num_args%" goto :find_argX.min/argY.min set workingArgX= set workingArgY= set a= REM Create coordinate veriables for /l %%D in (%argX_min%,1,%argX_max%) do ( for /l %%E in (%argY_min%,1,%argY_max%) do ( set cordx=%%D set cordy=%%E set "cord!cordx!.!cordy!=!space!" ) ) set cordx= set cordy= REM assign 0 for /l %%A in (%argX_min%,1,%argX_max%) do ( for /l %%B in (%argY_min%,1,%argY_max%) do ( if %%A == 0 set "cord%%A.%%B=%zero%" if %%B == 0 set "cord%%A.%%B=%zero%" ) ) REM Assign arguments to coordinates set a=-1 :cord.arg.loop set /a a+=1 call set cord!arg%a%!=!cordinate! if not "%a%"=="%num_args%" goto :cord.arg.loop set a= REM Display table set /a y=%argY_max%+1 :display_y.loop echo. set /a y-=1 set /a x=%argX_min%-1 :display_x.loop set /a x+=1 0>nul set /p"=!cord%x%.%y%! " if not "%x%"=="%argX_max%" goto :display_x.loop if not "%y%"=="%argY_min%" goto :display_y.loop set y= set x= echo. REM Remove veriables from memory and exit ::for /f "tokens=1 delims==" %%Y in ('set a ^| find "arg"') do ( :: set %%Y= ::) ::for /f "tokens=1 delims==" %%Z in ('set c ^| find "cord"') do ( :: set %%Z= ::) ::set space= ::set zero= endlocal goto :end :Modifyers.start set a=1 set b=0 set c=0 set err=0 :: Help if "!arg%a%!"=="/?" goto :help :: No arguments if not defined arg%a% goto :help call :loop.findpoint :check.loop :: Space Char if "!arg%a%!"=="/s" set /a b=%a%+1 if "!arg%a%!"=="/s" set "space=!arg%b%!" if "!arg%a%!"=="/s" set /a c=%a%+2 if "!arg%a%!"=="/s" ( set arg%a%=%arg_rep% set arg%b%=%arg_rep% ) set c=0 set b=0 set err=0 :: Coord Char if "!arg%a%!"=="/c" set /a b=%a%+1 if "!arg%a%!"=="/c" set "cordinate=!arg%b%!" if "!arg%a%!"=="/c" set /a c=%a%+2 if "!arg%a%!"=="/c" ( set arg%a%=%arg_rep% set arg%b%=%arg_rep% ) set c=0 :: Zero Char if "!arg%a%!"=="/z" set /a b=%a%+1 if "!arg%a%!"=="/z" set "zero=!arg%b%!" if "!arg%a%!"=="/z" set /a c=%a%+2 if "!arg%a%!"=="/z" ( set arg%a%=%arg_rep% set arg%b%=%arg_rep% ) set c=0 set /a a+=1 if not "%a%"=="%num_args%" goto :check.loop set a= goto :Modifyers.end :loop.findPoint for /f "tokens=1,2 delims==" %%A in ('set arg') do ( call :findpoint %%A %%B ) goto :loop.findpoint.end :findpoint for /f "tokens=1,2 delims=." %%B in ("%2") do ( if not "%%C"=="" set arg_rep=%2 ) goto :eof :loop.findpoint.end goto :eof :help echo Graphs coordinates on a coordinate plane. echo. echo Graph ^[^/c ^<char^>^] ^[^/s ^<char^>^] ^[^/z ^<char^>^] x.y x.y x.y ... echo. echo /c Defines what character the coordinates will be shown as. echo /s Defines what character the empty spaces will be shown as. echo /z Defines what character the axis will be shown as. echo. echo %%^^^&^)^=^|^;^"^<^>^,^! Cannot be used with /c, /s or /z. goto :end :end exit /b Ex: Code: [Select] C:\Macros\In The Works>_graph 1.2 -5.3 7.0 9.5 0.-3 - - - - - & - - - - - - - - + - - - - - & - - - - - - - - - + - - - - & - - - - - - - - - - - - - - & + - - - - - - - - - - - - - & - - - - - - - - - & & & & & & & & & & & & + & & - - - - - & - - - - - - - - - - - - - - & - - - - - - - - - - - - - - + - - - - - - - - - C:\Macros\In The Works> That's a neat batch. |
|
| 6769. |
Solve : Modifying file name by adding a suffix? |
|
Answer» Hi All, DOS Noob here. I have been working on a problem that unfortunately has me stumped. I have a jpg file name I WANT to convert the file to a png file which I can do with xcopy however I am having a lot of trouble in adding _small to the filename. The resultant should be *_small.png. My code gets me to *.png_small.png I have tried many different THINGS (variations) and I cannot find an answer for it. Please help. I have a jpg file name I want to convert the file to a png file which I can do with xcopy XCopy cannot and will not change a file's internal organization. Changing a file extension does not give you a new type of file. For instance, changing a file extension to XLS does not convert the file to an Excel workbook. Best practices indicate reading the contents of the file into a variable, then saving the contents with the new file type. Powershell can do this (see below) This LITTLE blurb shows how to write your for statement (execution at command prompt): The code syntax will rename the file correctly but will not convert PNG to JPG. Code: [Select]for /f "delims=" %F in ('dir /b/s *.png') do echo %~dpnxF %~dpnF_small.jpg Powershell script to change PNG file to JPG file: Code: [Select]#Requires -Version 2.0 Add-Type -AssemblyName System.Drawing $imageFormat = "System.Drawing.Imaging.ImageFormat" -as [type] $sourceFile = "C:\temp\razr_product_red.jpg" $saveFile = "C:\temp\razr_product_red_small.png" $image = [drawing.image]::FromFile($sourceFile) $image.Save($saveFile, $imageFormat::png) Happy Days, just a clarification, if the file names you are working with you in the for loop contain spaces it could error. i would recomend putting quotations around the %~pdnxF as well as the %~pdnF_small.jpg.thanks for your input guys. Even if I did not change the file type I still cannot add the SUFFIX, even after your suggestions. My knowledge of DOS is extremely limited and I am not sure where to go from here. Anymore ideas?Give this a shot. The free graphics viewer/editor Irfanview is able to convert from JPG to PNG using a command line interface and batch file. Code: [Select]FOR /f "delims=" %%F IN ('dir /b /s /a-d *.png') do REN "%%F" "%%~nF_small.png"Is the OP WANTING to crate a photo album for a web site? There are programs that do all the work for you. It is a feature in Dreamweaver as well as other WYSIWYG editors. http://www.youtube.com/watch?v=YlB_IZqKg_o Thankyou everybody for their efforts. Foxidrives' solution did the trick. I will look into irfanview. |
|
| 6770. |
Solve : DOS from CNET Download? |
|
Answer» If you need a copy of DOS, you may find it on the CNET download site.
Example: If you GET a 'Public Domain' program and merely change the name and sell it or exchange it representing it as your product, you are commuting fraud. The site is http://download.cnet.com/windows/ To clarify: no Microsoft operating system whatsoever, and this includes every version of MS-DOS, has ever become "abandonware". All Microsoft software ever released REMAINS copyrighted. Although there may be web sites which offer copies of such software for download, they are operating illegally. I agree... Topic CLOSED. |
|
| 6771. |
Solve : How to rename the file with file size using dos command? |
|
Answer» Hi, Hi What error message do you get? Quote from: what is the meaning of GTR in the qury ? It means greater than |
|
| 6772. |
Solve : Delete Folders With a Specific Name or With Specific Contents? |
|
Answer» I am interested in adding to an EXISTING batch script some code that will look for folders with a particular name and delete them. In this case the folders are named like this: I found it strange that I couldn't remove the %%A directories without referencing the full path to them The bare folder names will not be found by the batch unless you are running it in the folder "%userprofile%\AppDATA\Local\Temp Quote from: powlaz on June 13, 2013, 12:17:05 PM Code: [Select]for /f "delims=" %%A in ('dir "%userprofile%\AppDATA\Local\Temp" /b ^| find ".tmp"') do rd /s /Q "%userprofile%\AppDATA\Local\Temp\%%A" 2>NUL You will GET errors trying to RD a filename. |
|
| 6773. |
Solve : AMI BIOS password reset/remove on Asus K40IJ? |
|
Answer» hey guys, i think this is what i will do but isnt there any way You can keep asking but you won't get another answer. Portable computers are easily stolen and it often happens. This is a well known fact. Robust password security is thus necessary (this is also a well known fact!) and it is therefore very foolish to set a password and then "forget" it. If passwords were easy to alter or remove this would very useful to thieves and those who buy from them. And for people trying to steal information or pry into the affairs of friends, relatives or others, or to play pranks on them. So at least you can be happy your data is safe. If there was a special method known to techies we would, for the foregoing reasons, be very irresponsible to publish it here. |
|
| 6774. |
Solve : read .txt file by line? |
|
Answer» i am creating a batch file that requires me to read a random line in a .txt file. Girl creature is attacking you! This is the one I prefer. @echo off setlocal enabledelayedexpansion set linecount=200 set /a randnum=%random% %% %linecount%+1 set tempnum=1 For /f "delims=" %%L in ('type test.txt') do ( if !tempnum! equ %randnum% ( set line=%%L goto next ) set /a tempnum+=1 ) :next echo %line% This is better than my previous effort, which would never show the first line of the input text file. |
|
| 6775. |
Solve : Things to Program? |
|
Answer» Maybe I was too brief. @Salmon Trout Devcon is a Microsoft COMMAND line utility that is not a standard part of Windows; you have to download it. It is a developer tool, a command line EQUIVALENT of Device Manager, and I should think that used carelessly by someone with LITTLE knowledge or sense of responsibility it could seriously disrupt a computer. However you can reboot the computer with no need for extras in one line like this: Code: [Select]@shutdown /r /t X where X is the number of seconds you want to wait before rebooting, 0 (zero) being immediately. beaten by page 2 Quote from: Ocalabob on June 14, 2013, 07:08:23 PM @Salmon TroutWhy wouldn't you just use the SHUTDOWN command.Quote from: Squashman on June 15, 2013, 05:15:19 AM Why wouldn't you just use the SHUTDOWN command. Welcome to the chorus... Code: [Select]::Devcon.exe from microsoft @echo off Devcon Reboot There wouldn't have been any comment if the path wasn't there and the point it was from Microsoft was made. After all, this thread is about figuring out different ways to write batch files... |
|
| 6776. |
Solve : Issues come from comparing two trees? |
|
Answer» Below is my program for comparing all files and folders under two specified folders, dir1 & dir2. It works if two folders contain only one layer. That is, it succeeds if each folder contains only ordinary files and no sub-folders. In case each dir1/2 contains sub-folders, it goes WRONG. For example, SUPPOSE dir1 contains one ordinary file 1.txt and dd sub-folder containing 11.txt. This program will compare dir1\1.txt to dir2\1.txt. That's fine. But it will further compare dir1\11.txt to dir2\11.txt. That's SURELY wrong because what it is supposed to do is to compare dir1\dd\11.txt to dir2\dd\11.txt. |
|
| 6777. |
Solve : vbs, powershell, or java script?? |
|
Answer» So I've decided to learn a new scripting LANGUAGE, and was wondering which one you guys would recommend and if you had any good online material to learn from.Your said: vbs, powershell, or java SCRIPT?If your interest is mostly Windows, then VBScript is your best bet. Otherwise, I would have said PHP or Java. (Never confuse Java with JavaScript). Still, VB cript is an excellent pick. There are a NUMBER of tutorials on on the major languages in current use. Once you pick one, come back here and ask for HELP. CH is free and even better than a paid-for tutor. BTW, if you work as an administrator in a Windows environment, you need to know power-shell. DOS is dead.Quote from: Geek-9pm on July 28, 2013, 07:51:41 PM Otherwise, I would have said PHP or Java. You just did...Quote from: BC_Programmer on July 28, 2013, 08:31:10 PM You just did...Not I... it was the spell check monster. |
|
| 6778. |
Solve : Changing IP address to Static in DOS 6.22 for SLIP connection for file transfer? |
|
Answer» I am looking to make a SLIP communication connection between a host PC (Windows 7) to 4 Industrial machines running on basic Dos. I have a 4 to 1 adapter on the back of my pc and RS 232 cables attached to each machine. I am looking to find/change the address of the machines so I can send a ping from the PC to the machines. I am not very familiar with the DOS commands of the machine. I am a student engineer working for the summer. I appreciate any help!Quote ...Welcome to the CH forum. Please help us understand what SLP is. What 4 to 1 adapter do your have? RS232 is an older method used to interface with slow data rate DEVICES. Typically 8600 baud or even much lower. Also, all old DOS programs will be the 8086 real-mode program model. The programs are often called "16 bit programs" because they are not compatible with the mode used in Windows 7. I do not WANT to ruin your project. What I am here SAYING is you should consider the feasibility of using the hardware and software resources you have. Many industrial applications do not run on Windows 7, expect with a VM (Virtual Machine), which adds another level of complexity to want you want to do. To get to my point. Find and old PC with older serial ports and an old version of DOS. Older PCs run four RS-232 ports. My comments are a general observation based on information you gave. BTW: I did a little work on industrial automation a long time ago. Thanks for the response. I am sending the programs from a host PC to four identical machines. At the moment I am loading programs onto a floppy and physically transferring the data to each machine. We have a switchbox (A/B switch) as an opption but we are looking to create communication with 4 machines simultaneously. The adapter from the pc goes from one 25 pin port to four 9 pin ports. I can send and revceive files for a dedicated line. However, I am looking into a basic Serial Line IP instead of Point to Point Protocol because we don't need anything more from the link but straightforward small file sharing. I believe if I can change the static IP addresses of each machine I can link each to an individual connection witht he PC, I am just unfamilar with the DOS commands that would ALLOW this connection. Thanks again. Note: It might not be RS-232, I did have to short two wires from my null modem to match the adapter diagram from testing with a multimeter. But I have tested that the file transfers are correct. -I am running virtual machines from another computer to other machines and I understand most of the compatability issues. This PC is simply for transferring the files to the machines.Good. Now what hour are doing makes sense. You have four machines that communicate directly with a host over some form of serial lines. Logically, some implementation of RS232 hardware. Or are you using an Ethernet cable? With network adapters? But SLP is a software thing. It is not inherently part of RS232, a hardware lathing. SLP, serial Line Protocol is defined here: http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol Quote The Serial Line Internet (or, Interface) Protocol (SLIP) is an encapsulation of the Internet Protocol designed to work over serial ports and modem connections. It is documented in RFC 1055 Notice the association with TCP/IP. That is often RJ-45 hardware. But fom my dim memory, X25 was used on serial devices with RS323 hardware. This is now getting beyond my ability. Are you making the assumption that the serial ports have drivers that support SLP? I don't think so. Hey anybody! I need some help here. to the OP: Do you have communication established from the serving PC to one of the industrial control machines using SLIP, and it works to send a file? You really need to get that proof of concept before adding a serial hardware 1 to 4 splitter and attempting to get it all working at the same time. The hardware device is sharing one serial port to 4 serial ports and that could complicate the situation.Geek: I really appreciate your interest in my networking struggle. I am young and have not worked on these older machines and I am an Industrial Engineering major and my tech understanding in general is much under the general audience of this site. You raise a point that I have been struggling about myself when it comes to the serial ports not having drivers that support SLIP. I also have been curious of how that I will call to the different machines to send the files if I can get the communication lines running: is there software needed, or will I just send the files to the different addresses via command prompt on my PC? I have looked through the articles you have attached and I am continuing to explore my resources to attack the problem. I will keep you posted on my findings and solution. I found an article that talks about the use of the slattach tool to convert the serial line into SLIP mode but am unaware if this has to do with communication to a modem (which I will not be using). http://k12linux.mesd.k12.or.us/nag2/x-087-2-slip.operation.html Quote A simple way to convert a serial line to SLIP mode is by using the slattach tool. Assume you have your modem on /dev/ttyS3 and have logged in to the SLIP server successfully. You will then execute: Foxidrive: I have connected to the machine from the back of any of the 1 to 4 splitters off the PC. I have both sent and received files without any issues. I am now ready to attempt to set the 4 lines up to run simultaneously.Maybe you have RS232 hardware Many industrial control and telemetry jobs use a serial communication method slower that Ethernet, which is 10 to 100 Megabits. Rather that RS-232, a better interface, RS-422, is used with multiple devices. I think you should use RS-422 hardware. http://en.wikipedia.org/wiki/RS-422 As mentioned in the article, up to ten devices can tenon one twisted pair over a moderate distance Quote RS-422 (also EIA-422) is a technical standard that specifies electrical characteristics of a digital signaling circuit. Differential signaling can transmit data at rates as high as 10 million bits per second, or may be sent on cables as long as 1500 meters. Some systems directly interconnect using RS-422 signals, or RS-422 converters may be used to extend the RANGE of RS-232 connections. The standard only defines signal levels; other properties of a serial interface are set by other standards...It is a hardware protocol, not software. Quote from: connor3 on June 16, 2013, 07:44:30 PM Foxidrive: I have connected to the machine from the back of any of the 1 to 4 splitters off the PC. I have both sent and received files without any issues. I am now ready to attempt to set the 4 lines up to run simultaneously. How? Using a terminal program? You just mentioned in the same message that you haven't done it using SLIP and then you mention what is apparently a Linux tool: slattach as /dev/tty3 is linux terminology. |
|
| 6779. |
Solve : How to stay at DOS after exit from a batch file launched by doubling clicking?? |
|
Answer» I would LIKE to launch a batch SCRIPT program in Windows by double clicking and stay at DOS command after it exits. I know 'pause' can have it stay at DOS, but one click will close DOS BOX. What I want is to stay at DOS box after the end of the batch program. In such way, I can continue to USE DOS commands and see previous execution result.This will open a cmd prompt and run a command, and LEAVE the cmd window open. |
|
| 6780. |
Solve : grammar? |
|
Answer» I don't have a computer with me, but try ^! goto :eofd That is not in the right place. What you WANT it to mean? Are your thinking about a CASE statement? Batch does not have a CASE statement, not does it lend itself to a graceful way of making something like a CASE or SELECT structure. i put goto :eof because i dont want it run all not necessary script. ----------------------------------------------------------------------------------- i put value to each set set bI=1 set bwash=2 set bthe=3 set bcar=4 set byesterday=5 went i run this script below if "%word%"=="I" do ( set /a bI=%bI%+1 set "bI=!tset! !tbword!=!bI!" echo !bI!>>"bword.txt" ) goto :eof if "%word%"=="wash" do ( set /a bwash=%bwash%+1 set "bwash=!tset! !tbword!=!bwash!" echo !bwash!>>"bword.txt" ) goto :eof if "%word%"=="the" do ( set /a bthe=%bthe%+1 set "bthe=!tset! !tbword!=!bthe!" echo !bthe!>>"bword.txt" ) goto :eof if "%word%"=="car" do ( set /a bcar=%bcar%+1 set "bcar=!tset! !tbword!=!bcar!" echo !bcar!>>"bword.txt" ) goto :eof if "%word%"=="yesterday" do ( set /a byesterday=%byesterday%+1 set "byesterday=!tset! !tbword!=!byesterday!" echo !byesterday!>>"bword.txt" ) goto :eof ------------------------------------------------------------------ this script should make each set +1 from this to plus 1 each of set set bI=1 1+1=2 set bI=2 set bwash=2 2+1=3 set bwash=3 set bthe=3 3+1=4 set bthe=4 set bcar=4 4+1=5 set bcar=5 set byesterday=5 5+1=6 set byesterday=6 but output on bword.txt becomes like this set bI=2 set bwash=2 set bthe=2 set bcar=2 set byesterday=2 you know how to solve this?Just remove all of goto :eof and it might work.it not work it just going run all script... output on bword.txt becomes set bI=2 set bI=3 set bI=4 set bI=5 set bI=6 set bwash=2 set bwash=3 set bwash=4 set bwash=5 set bwash=6 set bthe=2 set bthe=3 set bthe=4 set bthe=5 set bthe=6 set bcar=2 set bcar=3 set bcar=4 set bcar=5 set bcar=6 it run all not necessary script. if "%word%"=="I" do ( set /a bI=%bI%+1 set "bI=!tset! !tbword!=!bI!" if i remove goto :eof its will be run all not necessary script below echo !bI!>>"bword.txt" ) goto :eof if "%word%"=="wash" do ( set /a bwash=%bwash%+1 set "bwash=!tset! !tbword!=!bwash!" echo !bwash!>>"bword.txt" ) goto :eof if "%word%"=="the" do ( set /a bthe=%bthe%+1 set "bthe=!tset! !tbword!=!bthe!" echo !bthe!>>"bword.txt" ) goto :eof if "%word%"=="car" do ( set /a bcar=%bcar%+1 set "bcar=!tset! !tbword!=!bcar!" echo !bcar!>>"bword.txt" ) goto :eof if "%word%"=="yesterday" do ( set /a byesterday=%byesterday%+1 set "byesterday=!tset! !tbword!=!byesterday!" echo !byesterday!>>"bword.txt" ) goto :eofThis is as FAR as I can help you. This term "%word%" is a persistent entity in the code you gave. It does not wear mutilate or change value by itself. When the test of == meaning really equal to, is used, the result is exclusive for a persistent entity tested on unique values., but not null null values. You were supposed to learn that back in Programming 101 some time ago. Sorry, if you don't grasp this, I can not help you. The script you gave has blocks that are mutually exclusive, so a break is not needed. Take out all the gooto. @echo off setlocal enabledelayedexpansion echo 1 scan document echo 2 create document echo 3 reset document set/p "pilih=^>" if %pilih%==1 goto :scan if %pilih%==2 goto :create if %pilih%==3 goto :reset :reset set bI=0 set bwash=0 set bthe=0 set bcar=0 set byesterday=0 goto enter :create set bI=1 set bwash=2 set bthe=3 set bcar=4 set byesterday=5 if "%word%"=="I" do ( set /a bI=%bI%+1 set "bI=!tset! !tbword!=!bI!" echo !bI!>>"bword.txt" ) if "%word%"=="wash" do ( set /a bwash=%bwash%+1 set "bwash=!tset! !tbword!=!bwash!" echo !bwash!>>"bword.txt" ) if "%word%"=="the" do ( set /a bthe=%bthe%+1 set "bthe=!tset! !tbword!=!bthe!" echo !bthe!>>"bword.txt" ) if "%word%"=="car" do ( set /a bcar=%bcar%+1 set "bcar=!tset! !tbword!=!bcar!" echo !bcar!>>"bword.txt" ) if "%word%"=="yesterday" do ( set /a byesterday=%byesterday%+1 set "byesterday=!tset! !tbword!=!byesterday!" echo !byesterday!>>"bword.txt" ) goto :eof :enter echo enter text and enter set /p input=: :savebword :scan set /p input=file name with (.txt) : type "%input%" echo. echo. :loop for /f "delims=" %%A in ('type "%input%"') do ( for %%B in (%%A) do ( echo %%B call :set "%%B" call :save "%%B" call :create "%%B" echo. ) ) goto :end :set echo set " %~1 " as echo 1 (pronoun) echo 2 (noun) echo 3 (verb) echo 4 (adverb) echo 5 (adjective) echo 6 (preposition) echo 7 (subject) echo 8 (object) set/p "cho=^>" if %cho%==1 goto SOMEWERE if %cho%==2 goto SOMEWERE if %cho%==3 goto SOMEWERE if %cho%==4 goto SOMEWERE if %cho%==5 goto SOMEWERE if %cho%==6 goto SOMEWERE if %cho%==7 goto SOMEWERE if %cho%==8 goto SOMEWERE echo Invalid choice. goto :eof :save set "word=%~1" set "if=if" set "tword=word" set "code=word" set "tset=set" set "tbword=b!word!" set "techo=echo" set "simbol=^!" set "output=!if! "%%!tword!%%"=="!word!" goto !tbword!" set "outputt=:!tbword!" echo !output!>>"word.txt" echo !outputt!>>"word.txt" set "output2=!tset! !tbword!=0" echo !output2!>>"setword.txt" set "output3=!tset! /a !tbword!=%%!tbword!%%+1" echo !output3!>>"word.txt" echo (set /a bword=%bword%+1) set (bof=%bof%) set "output4=!tset! !tbword!=%%!tbword!%%" set "output6=!tset! "!tbword!=!simbol!tset!simbol! !simbol!tbword!simbol!=!simbol!!tbword!!simbol!"" set "output7=!techo! !simbol!!tbword!!simbol!>>"bword.txt"" set "output8=goto :eof" echo !output6!>>"word.txt" echo !output7!>>"word.txt" echo !output8!>>"word.txt" echo word " %~1 " now save if "%~1"=="" goto nothaveit goto :eof :end echo END OF CODE pause>nul this full script i make so far... the problem is here if "%word%"=="I" do ( set /a bI=%bI%+1 set "bI=!tset! !tbword!=!bI!" echo !bI!>>"bword.txt" ) goto :eof if "%word%"=="wash" do ( set /a bwash=%bwash%+1 set "bwash=!tset! !tbword!=!bwash!" echo !bwash!>>"bword.txt" ) goto :eof if "%word%"=="the" do ( set /a bthe=%bthe%+1 set "bthe=!tset! !tbword!=!bthe!" echo !bthe!>>"bword.txt" ) goto :eof if "%word%"=="car" do ( set /a bcar=%bcar%+1 set "bcar=!tset! !tbword!=!bcar!" echo !bcar!>>"bword.txt" ) goto :eof if "%word%"=="yesterday" do ( set /a byesterday=%byesterday%+1 set "byesterday=!tset! !tbword!=!byesterday!" echo !byesterday!>>"bword.txt" ) goto :eof it should create output like this set bI=2 set bwash=3 set bthe=4 set bcar=5 set byesterday=6 but set bI=2 set bwash=2 set bthe=2 set bcar=2 set byesterday=2 !bI!, !bwash!, !bthe! ,!bcar! and !byesterday! all =2... why? this is the problem that i need help to solveTry changing your set /a to Code: [Select]Set /a %var%+=1 Quote if "%word%"=="wash" do ( 1. There is no IF .... DO in batch language. (Are you making the syntax up as you go?) I am amazed you have not seen lots of error messages (or are you running batch scripts by double clicking them?) 2. To alter, or set and then read a variable inside parentheses you need delayed expansion. (Read about it). I suggest you read the documentation for each command or keyword, either from the prompt by typing the command FOLLOWED by /? (example: if /?) or you can use a site like ss64.com http://ss64.com/nt/ Start with simple scripts and learn how each command or keyword works. You are just making up code by guesswork, and that will just lead to very long threads like this one. |
|
| 6781. |
Solve : Delete all the files in folder except one type of file? |
|
Answer» Is there a way to delete all the files in folder EXCEPT one type of file extension (*.zip) USING batch fileCode: [Select]@echo off |
|
| 6782. |
Solve : Cross Reference Company Name and Computer Name? |
|
Answer» Sorry if the title was misleading, I'm not really sure how to word what I want to do. I would like to add a command to a tool I use to manage our servers every day. The logic is this: Squashman - I imagined using a text file - FarmID.txtAnd the format of this file will be???We can tell you how to compare parts of a string (set /? has INFO) but to give you something that will work for you depends on the file format, as Squashman said.Sorry, I disappeared. I've been very sick. I don't THINK I really put much thought into what was going to be in the file, just that there would be a file. Hmmmm . . . I'm not really sure how the file should read. Could something like this work: TS888-101=Widget Company TS888-102=Widget Company TS899-101=Gadget Company etc.? If not, can you suggest a format? Thank, MJThis should work with the format you listed above. It's untested: Code: [Select]@echo off set "name=%computername:~0,5%" set "coname=" for /f "tokens=1,2,* delims==-" %%a in ('type "companylist.txt") do if "%name%"=="%%a" set "coname=%%c" if defined coname ( echo from %name% the company found was "%coname%" ) else ( echo no company name was found ) pause |
|
| 6783. |
Solve : MSDos Password has been forgotton? |
|
Answer» Afternoon! |
|
| 6784. |
Solve : Can I execute commands when the window closes?? |
|
Answer» I have been programming a chatroom for me and my friends on BATCH. You can have an exit script that it can run in the background, but this would have to remain open while the chat service is running I'm sorry, I don't understand what you mean. I don't know how to run it in the background. The batch itself is called Chatroom.bat and the LOG is called ChatLog.txt, if this helps at all.If you were to MAKE chatroom.bat into a .exe program, then you would use Code: [Select]@echo off :loop tasklist | find "CHAT.exe" if %errorlevel% == 0 goto loop echo ^/^/ %username% has left. >>ChatLog.txt REM this is where you resend your chatlog. exit /b Otherwise, you would have to make a logout option/command within the chat system. Code: [Select]REM say we are using %input% as our veriable that would get entered into chatlog.txt if "%input%"=="$logout" ( echo ^/^/ %username% has left. >>ChatLog.txt REM this is where you resend your chatlog. ) this would not happen if they were to just x out of the program. |
|
| 6785. |
Solve : Need help with a Batch file to copy and rename files? |
|
Answer» I have a large quantity of movies that are in separate folders. Each folder has a FILE named 'moviename-poster.jpg'. I would like to make a copy of that file and rename it 'folder.jpg' in each of those folders. I hope there is a way to do so that doesn't require that I DROP the batch file in each folder and run it. I would prefer to be ABLE to run the batch file from the root folder and have it go into each movie folder and do the copy/rename PORTION for me. Thanks in advance for any assistance.Place script in root folder and try script. Remove ECHO if happy. |
|
| 6786. |
Solve : Archiving Files Using Copy/Move Command?? |
|
Answer» Hello, |
|
| 6787. |
Solve : Create a batch file to automatically backup folder to my flash drive? |
|
Answer» Hi everyone, |
|
| 6788. |
Solve : Help with code to delete file when not in use? |
|
Answer» I was helped recently with my question regarding opening a *.ts file in my video conversion project, which worked well. |
|
| 6789. |
Solve : Filename Glitch with "FOR" When Directing Output of Decompiler to TXT File? |
|
Answer» This should be a piece of cake for you folks, I'm trying to use "FOR" to decompile a bunch of files using a 3rd party decompiler. What I'm using works, but the filename of the output isn't coming out like I want it to, here's my command: I guess in this case it's %~nf just because I used %f rather than %I as my variable? Yes, Jim. Glad to see it helped.Quote from: JRobinson on June 22, 2013, 02:46:52 AM I guess in this case it's %~nf just because I used %f rather than %I as my variable? In the examples in the FOR documentation, the character I (upper case i) is used as a placeholder for whatever letter you choose to use. Quote from: Salmon Trout on June 23, 2013, 06:22:56 AM In the examples in the FOR documentation, the character I (upper case i) is used as a placeholder for whatever letter you choose to use. It's funny that. I learned in programming never to use an i I l 1 or o 0 O as a variable name because in in some fonts you can't tell which is which. Programmers of today don't seem to have learned that - and it being MICROSOFT makes it even more of an oversight. Quote from: foxidrive on June 23, 2013, 07:02:55 AM I learned in programming never to use an i I l 1 or o 0 O as a variable name because in in some fonts you can't tell which is which. I have noticed that lots of example code uses lower case i or j as loop counters... I just confirmed you can use a pipe symbol in cmd provided you escape it: Code: [Select]for %^| in (*.*) do @echo %^| Code: [Select]@echo off for %%^| in (*.bat) do echo %%^| That's surprising. I hate when people use things like %%# and especially %%? to confuse the newbies with wildcards.Quote from: foxidrive on June 23, 2013, 07:59:50 AM That's surprising.But Jeb writes some pretty wicked batch files.That's for sure. |
|
| 6790. |
Solve : "SET" Command and Editing a BAT? |
|
Answer» Hello GUYS, |
|
| 6791. |
Solve : Newbie Batch file question? |
|
Answer» Newbie here. |
|
| 6792. |
Solve : need an echo loop? |
|
Answer» hey guys. Quote from: Salmon Trout on July 16, 2013, 10:49:52 AMQuote from: jofspades on July 16, 2013, 02:57:30 PM1. You left a final parenthesisNothing is wrong with FOR /L, I just... find it hard to figure out... ummm xD And excuse me for the flaws. I was half asleep at 6 AM. This is a help forum, not a chat room. You should only post code that you have actually tested. |
|
| 6793. |
Solve : Comparing variables? |
|
Answer» I have written the following MS Dos Batch File |
|
| 6794. |
Solve : How to copy all the files to a folder which has created using command ?? |
|
Answer» ECHO TYPE THE DATE AND PRESS ENTER, |
|
| 6795. |
Solve : [Bat]Find path in registry and copy files to this path.? |
|
Answer» HELLO, Need a batch script. The task is: find in REGISTRY path to the program, copy files (with other extensions) from folder where i have batch file and paste copied files to folder from path . Possible ? I hope that was understood. Sorry for my english What is the registry key?Thanks for reply. I'm not sure I understand the question correctly....(translator) Quote What is the registry key?In example : HKEY_LOCAL_MACHINE\SOFTWARE\7-ZipOn my machine it's HKEY_CURRENT_USER\Software\7-Zip Ok, in example can be. (on mine is in this two places ) ===== I try to do this on my own in that way : Quote for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do CD /D %a or Quote for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do set Path=%a but i dont know how to copy files, or how to refer to correct paths. I find something like that : Quote set OLDDIR=%CD%(cmd=%,batch=%%) But dont know how to, and I'm probably wrong ...1. Do not use Path as a variable name. This name is already USED for a system variable and you will cause lots of problems! 2. Why do you need to copy ADDITIONAL files into a program directory? This is bad security practice. 1. Path in this command this is string value - REG_SZ > Path > C:\Program Files\7-Zip 2. Program directory is only example. Quote for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do set Path=%a Your code uses Path as a variable name. Use something else e.g. Mypath Now %Mypath% contains a path copy some files into that folder copy *.txt "%Mypath%" I cant use Mypath in this example, becouse name of string value is "Path" . In other cases it can be InstallPath or InstallLocation etc. Is not a problem I check this in cmd with command: SET , and everything is fine with system "Path" 7-Zip is only example, because there was a high probability that someone who try to help will have this program Quote The task is: find in registry path to the program, copy files (with other extensions) from folder where i have batch file and paste copied files to folder from path . Possible ?Quote Your code uses Path as a variable name. Use something else e.g. Mypath Thats it ! Working like a charm. THANK You very much Quote from: Bzik on July 16, 2013, 01:14:19 PM I cant use Mypath in this example, becouse name of string value is "Path" You can use anything you like. You are not understanding that Path is the name (in the registry) of the registry key. In your batch you can use any variable name you like to hold the string value of the registry key. Code: [Select]@echo off for /f "tokens=1-2*" %%A in ('reg query HKEY_CURRENT_USER\Software\7-Zip /v path ^| find "REG_SZ"') do set MyPath=%%C echo The path string value is "%MyPath%" If you did set Path=%%C you would find that all external commands would stop working in that command session. Yes, You right. Mypath is working. Thanks again. |
|
| 6796. |
Solve : how to copy if the folder name contains space? |
|
Answer» copy *%input%*.* Z:\asfas asa\asdf AAF |
|
| 6797. |
Solve : Help with replaceable parameters? |
|
Answer» Hello, |
|
| 6798. |
Solve : Command 'grep' and 'awk'? |
|
Answer» Hi guys, gpdcreport my_run.report -gm -m 1 | gprofile -vs -resample -d 50 -N 50 | grep -v "#" | awk '{print $2,$1}' | gphistogram -y-min 150 -y-max 3500 -x-min 1 -x-max 50 -x-count 50 This works just fine, till the command grep and awk Anyone knows how to solve this? Probably it's a dumb question. I'm a newbie in Ms-dos. ThanksWelcome to the CH forum. There are no dumb questions. Programs grep and awk COME from UNIX, not MS-DOS. Some versions of those two programs have been adapted to run as Windows command line programs. Some questions for you: Which version of Windows or DOS you your have? Which version of awk? Which of grep? What is the error message you get? Answers to the above will help us help you. grep and awk are not "ms-dos" commands; they are part of Unix and related operating systems, such as Linux etc. To use them on a Microsoft Windows system you will have to install Windows versions ("ports"). Google for "Windows grep" and "Windows awk". The Gnuwin32 utilities include versions of grep and awk for Microsoft Windows command prompt (which is not MS-DOS). http://gnuwin32.sourceforge.net/packages/grep.htm There are various Windows versions of awk called gawk including Gnuwin32: http://gnuwin32.sourceforge.net/packages/gawk.htm Or there is the unxutils package which has grep and gawk http://unxutils.sourceforge.net/ A warning: you may find that the Windows versions do not use exactly the same syntax as the UNix originals and you may NEED to modify the command line you are USING. Would you care to EXPLAIN why you are trying to run that command on a Windows or MS-DOS system without preparation or prior study? As Geek says, exactly what operating system are you using? |
|
| 6799. |
Solve : Batch PrintScreen + Save? |
|
Answer» I was going to make a batch to "TRACK" someone else's account on my PC. Don't question it xD Why not? |
|
| 6800. |
Solve : Save/load help? |
|
Answer» Ok I need some help with a test file to load data from a save state after checking if it even exist. if exist "tsgb%name%.txt" goto loader instead of if exist ("tsgb%name%.txt") goto loader Ok that sort of worked. Now I get a whole new issue. The output on the :loader screen now reads Environment variable tsgbjasperjester.txt not defined. Done. Please check stats to verify. just as a note i tried removing the () around the Code: [Select]for /f %%a in ("tsgb%name%.txt") do set %%a but it just closed immediately. thank you again for the helpCode: [Select]for /f "usebackq delims=" %%a in ("tsgb%name%.txt") do set myvar=%%a If that text file just has one line of text in it and you are trying to assign it to a variable then just do this. Code: [Select]set /p myvar=<tsgb%name%.txtQuote from: Squashman on July 12, 2013, 08:15:29 PM Code: [Select]for /f "usebackq delims=" %%a in ("tsgb%name%.txt") do set myvar=%%a Uh, I'm not sure what that was supposed to do but it did no load the changed variables at all. I am actually trying to change 5 in this test game, but there 12 variables in the full game.Quote from: Jasperjester on July 12, 2013, 08:10:43 PM The output on the :loader screen now reads Yes, that is a different command and has different syntax and it should be: Code: [Select]for /f "delims=" %%a in ('type "tsgb%name%.txt" ') do set variable=%%a but this will only populate the variable to the last line in the file Quote from: foxidrive on July 13, 2013, 04:07:03 AM but this will only populate the variable to the last line in the file ok but if one player has 7 stats to track and each player gets up to 3 companions each will ever changing stats that have to be saved and loaded, this will require me to enter the same line at least 8 times for each player totaling 36 times and creating 36 small files for each player stats alone not including the money and inventory systems I have in place. I need all this in a maximum of 6 pages. There are already 4 people here who are testers and react differently and that would seriously bloat the folder in which the files are saved.1. Writevals.bat @echo off REM save values set name=Joe set money=1000 set energy=50 set friend1=Mary set friend2=Jim set friend3=Peter if exist "%name%.values" del "%name%.values" echo money=%money% >> "%name%.values" echo energy=%energy% >> "%name%.values" echo friend1=%friend1% >> "%name%.values" echo friend2=%friend2% >> "%name%.values" echo friend3=%friend3% >> "%name%.values" 2. Joe.values money=1000 energy=50 friend1=Mary friend2=Jim friend3=Peter 3. Readvals.bat @echo off REM read values set name=Joe set money= set energy= set friend1= set friend2= set friend3= for /f "delims=" %%A in ('type "%name%.values"') do ( set %%A ) echo name=%name% echo energy=%energy% echo friend1=%friend1% echo friend2=%friend2% echo friend3=%friend3% 4. Output of Readvals.bat name=Joe money=1000 energy=50 friend1=Mary friend2=Jim friend3=PeterQuote from: Jasperjester on July 14, 2013, 01:18:43 AM ok but if one player has 7 stats to track and each player gets up to 3 companions each will ever changing stats that have to be saved and loaded I was pointing out that your syntax was wrong and it would not read a file at all.Quote from: foxidrive on July 14, 2013, 05:05:37 AM I was pointing out that your syntax was wrong and it would not read a file at all. Oh, I apologize for the misunderstanding. I hope you may forgive my ignorance on the matter. I am still learning Quote from: Salmon Trout on July 14, 2013, 02:49:42 AM for /f "delims=" %%A in ('type "%name%.values"') do ( Had an issue where it wouldn't read the files at first, but it turned out, I forgot the tsbg before the %name%.values Kudos for all the help!!!!!!!!!!!!!What is a 'tsbg'? Quote from: Salmon Trout on July 14, 2013, 07:05:51 AM What is a 'tsbg'? tsbg was a prefix I added to make sure i never mixed up the test save batch game with the real game save files. example: Code: [Select]tsbg%name%.values vs Code: [Select]realgame%name%.values |
|