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.
| 1151. |
Solve : who knows to create a script to stop my tool.exe process when i get a type of er? |
|
Answer» who knows to create a script.bat to stop my tool.exe process when i get a type of error 12 times in a row? You aren't learning anything having all these .bat files written for you...Just sayin... Interesting to view his posting history. Just sayin... Hi If you know what is the exit code from your tool.exe, you can of course deal it with a batch file Quote from: DaveLembke on May 20, 2017, 08:18:42 AM Curious how your thinking of implementing this with batch. What will be used as a flag that an error happened 12 times. Do you have a log file that is created to where a batch can monitor this log file for 12 instances of an error and then perform a taskkill to tool.exe when 12 instances of some error message is found? i use AlwaysUP to schedule and run my tool.exe As system service,please take a look here ,u think is possible? https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForError this is the error code: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Dropping connection limit due to connection error to: Now stop MyTool.exe when finds more then 10 errors in a row Hi You can give a try for this script : Code: [Select]echo off Mode con cols=80 lines=5 & color 9E set "MyProcess=MyTool.exe" Title Monitoring the process "%MyProcess%" for error by Hackoo 2017 Set "StopProcess=StopProcess.log" Set "MyLogFile=Log.log" Set "ErrorMsg=Dropping connection limit due to connection error to" :MainLoop cls Set /a "ErrorLimit=10" Set /a "Count=0" For /f %%A in ('Type "%MyLogFile%" ^| find /I "%ErrorMsg%"') Do ( Set /a Count+=1 ) SET Count=00%Count% SET Count=%Count:~-2% echo( echo Monitoring the process "%MyProcess%" for error echo The Counting of error message until now is = "%Count%" echo The ErrorLimit is set by the script = "%ErrorLimit%" for stopping this process If "%Count%" GEQ "%ErrorLimit%" ( Goto KILLPROCESS ) else ( echo The counting of error = %Count% > "%StopProcess%" Timeout /T 60 /Nobreak >nul ) Goto MainLoop ::**************************************************************** :KILLPROCESS echo The counting of error is reached to %Count% > "%StopProcess%" Taskkill /IM "%MyProcess%" /F >> "%StopProcess%" 2>&1 Timeout /T 60 /Nobreak >nul & Goto MainLoop Exit /b ::**************************************************************** A brief note about programming languages. If the OP has a hard time with batch files, he might consider looking into an approach that makes things easier. There are a number of tools that have been created to make it easy to perform some kinds of update and maintain things res on a PC. Here are just a few better programming tools to save time and reduce unwanted errors. They all begin with the Letter P. P# Pearl PHP Pizza PL/M PostScript Powershell Prolog Python All the above have features that could make programming easier if you get STUCK with a batch file problem. Some experts say you can not mix one language with another. I disagree, that is what I used to do years ago and I believe that kind of approach is still a good idea. Some experts do not like it because it is not "Pure". Well, there is a language called "Pure" and it is tolerant. [Pure is a small language designed from scratch; its INTERPRETER is not large, and the library modules are written in Pure.] But even "Pure" will let you invoke other stuff if need be. The pint I wish to make is the OP might consider looking around and trying to add to his skills. I will stop here. Just saying that the OP ought to do wider study of programming. Looking at another language might help. Quote from: Geek-9pm on May 20, 2017, 10:18:31 PM A brief note about programming languages. I use AlwaysUP to run my tool.exe and ... alwaysup have this option too can u help me config. please? https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForError Quote from: Hackoo on May 20, 2017, 09:05:42 PM Hi ok thank you, i will try your script Hackoo i use AlwaysUP scheduler to run my Tool.exe As System and we have this option can u try to configure it please?take a look here https://www.coretechnologies.com/products/AlwaysUp/Plugins/#CheckLogFileForErrorThere's no need to Quote all the replies to your posts... Thank You.can u stop also cmd.exe and my tool.exe too?karlosss, CMD.EXE is a part of Windows and is used to start batch files. tool.exe is not identified as a standard item in Windows. Some say that is the name used by malware. Please explain where you got the tool.exe program, because we just can not guess what it is supported to do. Here is just one of many links about tool.exe. https://www.tenforums.com/software-apps/45148-software-reporter-tool-exe.html So such a generic name makes for confusion. i have a Script.bat who runs my tool.exe Quote from: karlosss on May 21, 2017, 12:03:58 PM i have a Script.bat who runs my tool.exeWhat is tool.exe? If it is from a credulous PUBLISHER, it would have documentation that would help. |
|
| 1152. |
Solve : Use a special command to stop the application?? |
|
Answer» USE a SPECIAL COMMAND to stop the APPLICATION? Its about AlwaysUP application and i use it to run other tools As System, i would like to STOP IT only when the Output.txt CONTENT finds the word FINISHED. http://imgur.com/a/4sy7f |
|
| 1153. |
Solve : Btch with exe parameter? |
|
Answer» Good morning Can you give more specific examples of what you are trying to do? ++1 shift Quote from: strollin on June 03, 2017, 11:52:13 AM Generally speaking, you have the right idea. You can use %1, %2, etc... as parameters to a batch file and you can output the results to a file using the > direct the output. There is a lot more to it than just those 2 aspects though, especially when you are interacting with an exe as you mentioned. Often an exe will handle it's own output so invoking an exe from a batch file and attempting to redirect the output to a file will not work. Good day I'm SORRY for the late reply. I wasn't able to check my email yesterday... The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters. So, for instance, I would call; mybatch.bat myexe.exe param1 param2 would run myexe.exe with the parameters 1 and 2 and send the output to a file (results.txt): myexe.exe param1 param2 > results.txt The exe would be a "parameter" to the batch, but to run. Kind regards, Kepler Quote from: kepler on June 03, 2017, 11:19:05 PM The idea is this: I want to create a batch file, that can call a executable (by means of a parameter) and its repectives parameters.That might work, provided the exe was WRITTEN to accept command line parameters, and it writes text output to the console (to STDOUT if you want to get technical.) A QUICK question: why don't you just try it? Hi No, it wasn't working.... because the bat file was in utf8!!!... Jesus... I'm sorry for the trouble. Have a nice weekend. Kepler |
|
| 1154. |
Solve : Add prefix to existing file name using UNC path? |
|
Answer» I am trying to add a prefix to existing files within a UNC path. For some reason my code is changing the first character of the file name instead of appending it This topic describes how to create and define a Microsoft SQL Server Agent job step in SQL Server 2017 that uses an executable program or operating system command by using SQL Server Management STUDIO, Transact-SQL or SQL Server Management OBJECTS. The rename command in Windows 7 CMD does not have an explicit insert operator. But I think it allows you to rename a file with a longer name. (For simplicity, I will not use paths and extensions in the EXAMPLES.) Say I have wanted five files named: ass0 ass456 ass4567 ass45678 Plus three files a little different in the current directory asw456 aws0 aqs456 I can use this to see of the first three letters identify the files I want DIR äss* /b (Forum rules require me to use äas instead of *censored*.) Yes, it shows only the five files, not the others. Now I rename using Code: [Select]REM äss* Sass*(Change ä to a in above.) That will insert the letter S at the start of each name. Is that what you want? |
|
| 1155. |
Solve : Documentation for String Length? |
|
Answer» I was on SO and came across this post that asked how to break a string by delimiter and then count how many strings exist. The given answer(at the time) was this: I'm just wondering how the person who posted the answer was able to figure it out.It's just putting basic batch stuff together. They knew these things: 1. This is an example of batch string replacement: %string:.= % It means "the variable %string%, with each period (dot) changed to a space" 2. The replacement makes 17.09.01.04.03 become 17 09 01 04 03 3. A simple FOR command repeats once for each space-separated token 4. The variable %count% is set to 0 (zero) at the beginning. 5. Each time FOR repeats, the set /a count+=1 adds 1 (one) to the value of %count% 6. At the end, %count% is equal to the number of tokens. |
|
| 1156. |
Solve : Running old batch files on Win 10? |
|
Answer» Hard drive died. Got a new PC with windows 10 installed. The previous batch FILE routine to compile C++ code WORKED fine on the old machine. Now they don't work. I get the "external internal command not recognized etc. error message. I assume Win 10 comes with a C++ compiler in Visual Studio and there is a path statement in the bat file. Also I am familiar with changing the system path in the environment variables but I' :'(m not SURE what goes where. Has anyone else had this problem when changing over to wWin 10 Windows 10 doesn't come with Visual Studio or C++.Curious why you need to compile C++ from WITHIN a batch file. What IDE did you write your code in, you should be able to compile it there.... or do you have a batch file that dynamically generated the .cpp and then called to a command SHELL level compiler and then called to the EXE that is produced to execute it with dynamic info as part of the generated .cpp file? Try out Visual Studio Community for a fully-featured and extensible IDE; An updated alternative to Visual Studio Express.It incldues a C++ IDE. Can you post the source code of your batch file and explain more what's your issues ? Thank you ! |
|
| 1157. |
Solve : How to get on videos folder with command line for any windows system ?? |
|
Answer» Hi You COULD hack it to get it working in batch, as there are some registry keys that contain this information. You can find them in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders. "My Video" would be the needed value.Thank you BC_Programmer, you put me on the right direction Code: [Select]echo off Set "ShellFolderKey=HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" Set "MyKey=My Video" For /f "tokens=4,* Delims= " %%A in ('Reg Query "%ShellFolderKey%" /v "%MyKey%" ^| Findstr /C:"%MyKey%"') Do ( echo "%%A" ) pause |
|
| 1158. |
Solve : ctrl+c before process being killed?? |
|
Answer» batch SCRIPT for windows OS, to press ''ctrl+c'' automatically before process being killed? |
|
| 1159. |
Solve : ms dos 6.22 in dosbox problem? |
|
Answer» I have a problem with the virtual ms dos 6.2.2 install in the dosbox |
|
| 1160. |
Solve : Triple boot Dos,win xp,win7 help? |
|
Answer» Hi, |
|
| 1161. |
Solve : Batch file that generates lots of text? |
|
Answer» Hi, |
|
| 1162. |
Solve : Using vaiables in a path? |
|
Answer» Hey guys, |
|
| 1163. |
Solve : this program cannot be run in dos mode? |
|
Answer» Okay so i'm trying to USE attrib.exe in ms dos but it says "this program cannot be run in dos mode". Thank you for replying. But how would I get a 16 bit version of attrib?From the MS-DOS install disk set. It's on Disk 1 I think. Correct... |
|
| 1164. |
Solve : vbr(volume boot record) to floppy disk? |
|
Answer» The ms dos boot DISK can be created by creating a volume boot record in the volume boot sector of the disk. This automatically makes some program in windows or cmd, dos shell with format / s or sys command. My question is ..... i could create vbr with hex \ disk editor and with ASSEMBLER maybe ......? It is not clear what you need to do. Is this for educational uses? Is this needed for a useful project? MS-DOS has been retired for some TIME and is not often used for any new application. When people come here with MS-DOS questions is is often about maintenance to an OLD system that must be kept running. If you are USING a computer that needs a boot floppy disks that can boot, the process is done at the time you format the floppy. First you have to boot up with a floppy that already has both the system and the needed utilities. You insert a new or old floppy in the B: drive and issue a command to format and systematize the floppy in the second drive. format b: /s The will write the needed data into the proper place on the floppy. Is that what you wanted to know? |
|
| 1165. |
Solve : one disk drive? |
|
Answer» How to write commands to MS dos when it has one disk drive on the computer MS-DOS/PC DOS since version 5.0, and later operating systems, assigns drive letters according to the following algorithm: You can't do what you want with only 1 drive...period. Quote from: patio on August 24, 2017, 01:04:33 PM You can't do what you want with only 1 drive...period.Are you sure? A RAMDrive could be created and scandisk copied to that if it fits within the limited size of the RAM Drive. This allocates a section of RAM to act as a virtual hard drive. You can then scan disk the next disk in the drive from say the RAMDisk drive of E: So from E: you would run scandisk A: or with whichever switches you want to use with it for disks placed into A: https://books.google.com/books?id=u7oN-5y7nGsC&pg=PA175&lpg=PA175&dq=ramdrive.sys+dos&source=bl&ots=j6i62HQrs-&sig=flW8BOAJYi7Kc36RcrqXlSDNN9o&hl=en&sa=X&ved=0ahUKEwjn-s_g0vDVAhXG7YMKHUUwBHgQ6AEIUjAH#v=onepage&q=ramdrive.sys%20dos&f=false You need a bootable floppy with DOS 6.22, then configure it for the RAMDRIVE to be active at next boot. Reboot computer and RAM Drive is created. Next copy scandisk to the RAM Drive such as at letter E: and then remove the bootable floppy from A: and insert the disk you want to scan into the drive at A: and from E: run scandisk with whatever switches if any and A: *Is this a homework project? In regards to what salmon said... I do recall many years ago being able to call to a single drive at both A: and B: and it read the disk and I never understood why. I thought that it was messed up somehow since only 1 drive was present. Curious how the A: to B: method would work in a single drive system since the disk removed would take scandisk away with it. RAMDrive is only method I can think of to make this work with scandisk remaining in RAM to be called. Quote from: Salmon Trout on August 24, 2017, 01:10:08 PM Are you sure? He never stated 2 drives...so i'll stick to what i stated...unless we get the full story...Salmon Trout's method works. I wasn't familiar with it so I just gave it a shot in VMWare under MS-DOS 6.22. The VM I have only has one floppy drive. I was able to use chkdsk on a bootable floppy image and run it against a separate image that had only data files using the "Phantom drive" approach. A simple "scandisk B:" when A: is the current drive seemed to do the trick. It PROMPTED for the disk for B:, and I swapped in the data diskette. LKooks like you can also change to the data diskette directly via B: and then run A:\scandisk B: and it prompts for the A: diskette, then the B: Diskette, and the program runs against B:.I can still remember when I upgraded my Epson Equity II XT PC from MS-DOS version v3.3 to v5.0, thanks to a pal who had a spare set of 5.25" floppies. QBasic! the editor! And of course the phantom floppy thing I mentioned above. It had one 5.25" 360K floppy drive. You could run WordPerfect off A: and keep your documents on B: , and the system told you when to swap the disks. Quote from: BC_Programmer on August 24, 2017, 03:07:35 PM Salmon Trout's method works. I wasn't familiar with it so I just gave it a shot in VMWare under MS-DOS 6.22. !!!!!!!!!!!!!!!!! Very Cool on the A: (Phantom B:) approach. Easier than a RAMDrive and your method supports older DOS than 6.22 also. |
|
| 1166. |
Solve : How to count the underscore in a filename variable ?? |
|
Answer» Hi Thank you, both for your reply!You completely missed the fancy way aGerman showed you how to accomplish your task. His code has no GOTO commands so it literally counts it all in one pass. http://www.dostips.com/forum/viewtopic.php?f=3&t=8071#p53604 Quote aGerman showed you how to accomplish your task Knows its praise, but ( a German ) just has a strange tone to its label. Not sure if its because I'm half German myself etc and had issues with people years ago in elementary school jabbing at my ancestry etc when sharing family tree info etc. Knows its praise and not a bad label etc. Thinking stating Salmon Trout would have been sufficient. Maybe Salmon Trout and Squashman are at some joking around level that makes this less odd in reading. But concerned that passer bys might FIND that not so much a praise and maybe offensive. Just my thoughts. While not jewish, family members ( my great grandfathers brothers and sisters ) died trying to escape the war, 2 of which when pressured to join the nazi army left the world on their own terms vs joining as a nicer way of explaining a bad situation as to how they died. I am not offended by squashman... all is cool but just my concerns about passerbys who might not understand a friendship joking jingle with that label. The aGerman thing is a mystery to me. I think maybe that is the username of someone on the dostips forum, that is linked to in squash man's reply.OHHHHHHHHHHHHHHHHHHHHHHHHHHHHhhhhhhhhhh hhhhhhhhhhh I was thinking it was cause you were German and you ended up helping him. Just went to dostips and sure enough there is a username of aGerman... well now passer bys wont be confused and accidentally offended with what may be looked at as a label vs a username. I saw it as a typo missed space and ( a German ) basically. Laughing at myself in not seeing the connection of aGerman with a username and going in the wrong direction. I'm not German, I'm English! All these years I thought you were German when referring to europe and seeing this. Quote Völlig losgelöst Oh that! It's some words of a song, "Major Tom (Coming Home)" by Peter Schilling (who is German!) It was the theme tune of a German TV series called "Deutschland 83", a spy drama set in 1983. I really liked it. The song was a big European hit in that year. So was the TV series in 2015. I just thought it was cool to put some of the words in my signature. The series premiered on 17 June 2015 on the SundanceTV channel in the United States, becoming the first German-language series to air on a US network.COOL and now it all makes sense Glad we got that all cleared up. For many years I thought my ancestors were from Germany but it turned out they were actually from Austria but they spoke German. |
|
| 1167. |
Solve : Copy files toa folder, add suffix to prevent overwrite.? |
|
Answer» I have seen it done. Somehow there is a way of putting files in one folder and ADDING a number to the end of the NAME to prevent overwrite. But how do I tell a copy utility to do that? Or is there a special utility that will do that? Hackoo, Thanks.Geek-9pm You are welcome Don't forget the link to thank me + Hackoo !Anyone who begs for thanx doesn't deserve them.Beggars can't be choosers. Quote ...widely held medieval opinion that if you asked for and received a gift you should be grateful for it. The 'gift horse' proverb was recorded first, in Heywood's 1546 version of A dialogue conteinyng the nomber in effect of all the prouerbes in the Englishe tongue.http://www.phrases.org.uk/meanings/beggars-cant-be-choosers.html Quote from: patio on August 08, 2017, 04:41:17 PM Anyone who begs for thanx doesn't deserve them. And did you think this really in my case ? i spend my time to WRITE a special code over the night to help him to achieve his aim, and you post me something that discourage me Thank you for your nice reply and for your encouragementYou've been thanked for contributions...i was stating asking is a bit of a reach. But if thats what's important...go for it.I did thank. |
|
| 1168. |
Solve : Rename files from a string in random places from a text file? |
|
Answer» I am trying to rename a bunch of .m3u files based on the text between ", and (s. The text might contain characters INCLUDING Code: [Select]& (random text) . : ! | - |
|
| 1169. |
Solve : rename xml using specific node variable position.? |
|
Answer» HELLO friends I am trying to rename a group of xml files based on a specific node, which always changes position. So far I have the following CODE that always works and cueando the position is fixed but as I say the position I need is variable. The node that I need is the ONE that I set in image noIdentificacion = this work with same position echo off for /f "delims=" %%Z in ('dir /b *.xml') do ( for /f "tokens=12 delims== " %%A in ( 'find /i "noIdentificacion=" ^< "%%Z"' ) do REN "%%Z" "%%A.xml" ) I hope and they can support me. Thank you. [attachment deleted by admin to CONSERVE space] |
|
| 1170. |
Solve : How to insert the '&' Symbol in variables? |
|
Answer» I wanted to MAKE something like this, |
|
| 1171. |
Solve : Merging External Hard Drives together batch question? |
|
Answer» Big Mess... It would also be possible to do something fancy, like instead of doing nothing, it creates a hard link to the file that was found in the other folders. This would result in the directories all preserving exactly what they looked like on the drive, but all duplicated files (based on the hash) would share the same data. and not take up any additional space. Or it could write up a "report" for each target listing the file paths that weren't copied and where they already existed.Hard links work via NTFS. Basically, NTFS file structures basically have a MFT entry that SAYS what the file is named and points at where the data for the file is. Hard Links are when more than one MFT Entry points at the same data. Of course there are caveats- changing one changes all other "files" pointing at that data for obvious reasons- though those might be desirable side effects anyway. Thanks for your clarification on how hard links work BC. I always thought that the links were system bound and not part of the master file table. While the MFT has an index of all data I always thought the system that the drive connects to keeps track of hard and soft links. I think I am going to just manually go through and target the larger redundant files and work my way down from there using CCleaner's duplicate finder feature. CCleaner has ability to select search for duplicates of greater than a specific size that I can specify. I set it to greater than 100MB and then found duplicates of Linux ISO's and stuff that I dont need to have 6 copies of Linux Mint 9 LTS. I was messing around with some ideas and then put a stop to them when I realized that for each duplicate my routine was going to have to search through the entire drive with every pass and its slow and very inefficient. CCleaner has a export to text file for duplicates and I was going to use this as a cheat sheet for my program to know what and where to target duplicates but realized that I probably should just manually pick away at this, as well as there is some data I am finding that I really dont need to keep around anymore so I am trashing some stuff ENTIRELY that I dont have a purpose for such as Open Office installer Version 3.2.1 so I guess I will pick away at it. |
|
| 1172. |
Solve : Send commands to open application from command prompt? |
|
Answer» I was hoping someone might be able to help me with sending commands to the applications I just opened. I know each application is different perhaps you could teach me how to find these commands? I want to EVENTUALLY be able to call a single batch file and launch a game or application (let's use STARCRAFT for an example) then log in, and start a game and run commands to play the game. I am under the understanding this is POSSIBLE with MS-DOS. However, in the meantime perhaps we should just start with this example. I would like to launch VS2015 Command Prompt and MAKE a call to unlock a file. I cannot seem to figure out how to make a call to the VS Developer Command Prompt after it is opened. Can you please help me with this please echo off set "pathA=C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2015\Visual Studio Tools\" set path=%path%;%pathA% start /max "Developer Command Prompt for VS2015".lnk cd "C:\Program Files (x86)\Microsoft Visual Studio 14.0\" echo. "C:\temp\Test.txt" Quote from: Skylark on September 14, 2017, 06:24:36 PM I am under the understanding this is possible with MS-DOS.No and very doubtful you are using MS-DOS. A batch file cannot INTERACT with Graphical User Interfaces. If you need to do that try using Vbscript with Sendkeys method or use a program like AutoIt or AutoHotkey.Thank you for saving me a boatload of time. I appreciate your help, I will start learning vb now. |
|
| 1173. |
Solve : Batch for closing 2 instances of software? |
|
Answer» Is it possible to close two instances of the same programs if found running in process, like two myprogram.exe. This kills all my instances of notepad it doesn't leave any up. That's what you asked for. Quote from: Skylark Thank you, exactly what I need. Apparently a different user who didn't read the OP original requirements. Quote from: BC_Programmer on September 15, 2017, 12:26:58 PM Apparently a different user who didn't read the OP original requirements.This statement is pretty cut and dry in English English or American English. Quote from: Salmon Trout on June 28, 2017, 01:27:23 PM if that number is greater than 1 kill them all.Quote from: BC_Programmer on September 15, 2017, 12:26:58 PM Apparently a different user who didn't read the OP original requirements.I didn't notice it was a different user. I did think that 2 and a half months was a bit long to decide it didn't do what they wanted. Currently have a similar ISSUE with a product called FIRESTORM Viewer and I have been just manually going in to task manager and killing the extra instances of a executable that stays active when the viewer exits. I didnt catch this issue until opening and closing Firestorm Viewer about 5 times and then noticed some unexpected lag where the cores get weighed down with extra instances running but no window active for them etc. It seems as though this Viewer has a bug where it doesnt kill all threads on exit and starts to stack multiples. The biggest issue when killing the other instances is that if you select the WRONG one you kill the currently active session vs the orphan remaining exe's that you want gone. So I just kill all of them now, and start fresh. Killing all instances of the exe that acts up and then relaunching is the best method I found. If you used tasklist in a batch with the /v (verbose) and /fo:csv switches you could catch the window title in full This is the header: "Image Name","PID","Session Name","Session#","Mem Usage","Status","User Name","CPU Time","Window Title" For example, this session of Firefox right now shows up: "firefox.exe","3292","Console","1","711,312 K","Running","MIKEANDBARBIE2\Mike","0:08:51","Preview - Re: Batch for closing 2 instances of software - Mozilla Firefox" You can use for /f with comma delim and catch the various tokens, e.g. Code: [Select]for /f "tokens=1-10 delims=," %%a in ('tasklist /v /FO:CSV ^| find /i "firefox"') do echo PID %%b WIN title %%j Code: [Select]PID "3292" Win title "Preview - Re: Batch for closing 2 instances of software - Mozilla Firefox" You could present the PID (token 2) and window title (token 10) of each one to the user in a list and then invite them to type a PID to kill using taskkill if each instance of Firestorm Viewer has a different window title that WOULD work but if the orphaned threads have not got active windows I guess you'd need some other way to ID the ones you want to kill. I think the window title would show up as "N/A". However if the image name contained "Firestorm" maybe you could just nuke that PID. This here is the bug... https://jira.phoenixviewer.com/browse/FIRE-17876 llceflib_host is the executable that starts to stack multiple instances. I have been just closing out the active window and going into task manager and sort alphabetical and kill all llceflib_host processes. Then relaunch firestorm viewer and its ok again. It only seems to happen when the viewer is exited and relaunched again as if there is a issue with garbage clean up at shutdown of services. No windows open with these services. I looked to see if there was a way to associate which one goes with the active window and which ones are orphan but its just pretty simple to close out the viewer and go to task manager sort alphabetical and kill all of the llceflib_host processes, then launch a fresh launch of firestorm. |
|
| 1174. |
Solve : How can you tell an old program to use shrt names?? |
|
Answer» Yes, I am talking about very old programs. Some will choke on a long file name or a file name with some odd chars in it. |
|
| 1175. |
Solve : how to avoid pop up box for password in windows batch script? |
|
Answer» I am trying to encrypt and decrypt a file using a GPG software using BATCH SCRIPT. Every thing goes FINE for encryption but when i try to decrypt it prompts for password which comes as a message box but i want to avoid this because this script has to be called in some other application and we cannot automate this unless we provide the password in actual script itself. Can some one help me in this regards.GPG has a passphrase option. |
|
| 1176. |
Solve : A Path with date variables? |
|
Answer» HELLO everyone. I would like to OPEN a folder with DATE variables inside. How can I do that ? Example I am trying Y:\Folder\%yyyy%\%mm%.%yyyy%\ where yyyy is the year of the system (windows 8.1) and mm is the month Y:\Folder\2017\08.2017 Best Regards Here we go : Code: [Select]echo off Title GET DateTime with Wmic for /f "tokens=2 DELIMS==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YYYY=%dt:~0,4%" set "MM=%dt:~4,2%" set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" set "Min=%dt:~10,2%" set "Sec=%dt:~12,2%" Set "DateTimeVar=%YYYY%%MM%%DD%%HH%%Min%%Sec%" echo YYYYMMDDHHMinSec = %DateTimeVar% echo Y:\Folder\%yyyy%\%mm%.%yyyy%\ pauseThanks a lot Hackoo Best Regards |
|
| 1177. |
Solve : script file to add date to file name? |
|
Answer» Hello Folks, |
|
| 1178. |
Solve : Getting "!" and other difficult characters to encrypt.? |
|
Answer» I've managed to get most the special characters but Possible work arounds?Actually learn what you are doing instead of copy-pasting from incompetent youtubers?Code is very much changed from original source and this was for personal use, also I asked him if it was ok. I know what everything in the source does line for line so what do you mean actually learn what your doing?The source is clearly not just copied and paste, it clearly has been greatly modified for more useful purposes, the algorithm isn't even entirely the sameYou don't have to criticize I have zero intention of stealing credit from other youtubers. Like it seriously offends me how you make such a claim. I've been breaking this script down and modifying it and you just act like all I did is copy, paste, added some REM statements and happy faces and boom a brand new script. Like you could at least have looked at the differences in the scripts. I'll go somewhere else for help jesh.I get your like an expert and all but I have been trying to learn, and your completlying dising on me and I've done nothing wrong. There is a difference from borrowing a script, modifying it, etc, from just taking the script and copy and pasting, I even told you who the original algorithm came from so like Im not plagiarizing or anything. All I did is paraphrased his source and made it much more advanced than the original.If the source is nearly 70% changed then I have been learning from what i code.if you knew what you were doing you would not be having issues determining why certain characters were causing problems . I wasn't even intending to accuse you of stealing. They provide it for free, after all. Regardless of how much it may have been altered though, it started with a rotten base- The 'incompetent youtuber" part is probably the major takeaway there. I doubt they even wrote the batch file to start with anyway. There are innumerable youtube channels started by upstart teenagers who's parents and family have told them all their life they will be the next "Bill Gates" because they can log in to face book or use the Command Prompt. Some of them take it to heart and start pretty much writing their memoirs before they are out of high school, like that guy. I mean, at least I had the good sense to wait until I was 21 to be a smartass know-it-all. In any case * and ! are not inherently different than any other character when it comes to these kind of transformation algorithms, so I'd guess that it is related to ! and * having special meaning within the Command Prompt itself, possibly caused entirely by the many layers of unnecessary indirection that are present here, where it constructs accessory batch files and scripts via echo commands. You might start by changing it to not delete these accessory files and examining the batch and VBScript files it creates as they may be where the issue lies, likely in the form of unescaped characters. I wasn't saying you was accusing me of stealing I was just pointing out that I wasn't. I understand but what you mean, with the whole youtube and where it came from, I do agree, but i have no where to learn from. I do understand what this script does, i learned it line for line. what I don't understand is the whole trying to escape "!" I have tried adding "^^!", I know how to escape it, just not in this situation. I only have general knowledge of the language, And I know like a fair amount of cmd now, but don't understand everything in entirety, i can read some code and understand it well and other scripts I just can't figure out what I'm looking at. Like honestly I put a decient amount of work in the above script, almost more than the original script even had. But I don't know everything, I'm not a mastermind coder. I only applied what I knew I could do to the script, that's why I was asking questions here. Because I'm trying to learn and it's difficult when there is so little information anywhere on the Internet about command line, YouTube is filled with horrible noob tutorials, every website that helps individuals require at least that person to create his source before they can actually help that person. It's not necessary a big issue, but when i first started out trying to learn, it made it almost impossible to learn anything because I wasnt allowed to learn from others code or have had the knowledge to create my own. Im a person who learns from books, and there is very few books on commamd line that I've found. You say I should learn but I really have been teaching myself a lot more than my old lazy bad habit days, I've been on dos tips breaking down scripts trying to understand them and such. I just do this because I'm really interested in it, but even with all the tutorials, breaking down code, and etc, I'm still not learning how to stretch it into something that I can create by scratch.And I'm not even trying to be a smartass, I'm just trying to learn, honestly, and I was only going to use the script personally. I don't think for a split second that I'm possibly even as remotely close to being as good as you guys or even the guys at dos tips. But where do I go when there isn't anything good anywhere, all tutorials just show the basics and never get into deep details. Again, you were not the smartass to which I referred, but rather the youtuber. They are unreliable as a resource, as they barely understand the material themselves. This tends to be the case for the majority of youtube channels who create tutorials like this, unfortunately. As I mentioned, The script creates additional scripts as part of it's operation. I would suspect the issue lies there, If you REMOVE the segments of code responsible for deleting those helper files, and then you can examine the contents of the files generated and make sure there are no characters that aren't escaped when they should be, or otherwise test/validate those segments of the entire operation. |
|
| 1179. |
Solve : Usinf CMD line for advanced search.? |
|
Answer» The standard search in Windows, apparently, has few options of AND with NOT. D:\searchtest\,g1.txt,1 KB,TXT File,21/09/2017 20:46:57,23/09/2017 15:27:23,23/09/2017 15:27:23,1,1,[email protected] Column headings Path, Filename, Size, Type, Modified date, Created date, Last accessed, Hit Count, Line number, Line text |
|
| 1180. |
Solve : INSERT FLASHING OR REPEATING LINE IN FILE? |
|
Answer» I'm batching a series of 'Call' commands to back up critical files to multiple devices (external drives, etc) and would like to display a line saying ". . . working . . ." that repeats or flashes until a called program completes. My users complain that because the screen shows nothing during lengthy file-backups, they're not SURE anything's happening. |
|
| 1181. |
Solve : file sorting by size? |
|
Answer» hi |
|
| 1182. |
Solve : Converting Batch script to powershell? |
|
Answer» Hi Guys, |
|
| 1183. |
Solve : Dos command to move files that contain a particular word from source to target? |
|
Answer» I need to move files from source to target folder that contain in the file text a particular word, (not file name) |
|
| 1184. |
Solve : Game freezing in DOS? |
|
Answer» Guys, Why not just play it inside DOSBox? Because I prefer the way it is in real DOS. I don't want to accidentally go to Windows. |
|
| 1185. |
Solve : DOS on a WYSE Thin Client? |
|
Answer» I installed DOS 7.1 onto a WYSE S30 thin client but it won't boot from the IDE flash. Says missing operating system despite it being correctly installed onto an active, primary partition. Tried DOS 6.2 yet ? ?...force IDE in BIOS ? ? All that can be changed in the WYSE Sx0 BIOS is the boot order of IDE, PXE, USB, and how much video RAM is allocated.But you stated the IDE timing out was the issue...It's not timing out, it won't allow operating systems to boot from it unless they have whatever tweak WYSE used in their Windows CE, Linux, or XP Embedded releases, or what the guy with the parkytowers site did to linux. I just tried installing FreeDOS 1.2 Lite from a 512 meg USB drive onto a WYSE S30. Result? Failure. It boots and launches the setup. First is says there's no fixed disk, then is says drive D: is not partitioned. So I have it partition and reboot. Repeats this exactly the same. It's apparently blocking writes to IDE when booted from a USB that's not prepared with the WYSE utility for making an updater flash drive.So my link above was no help ? ?This may be useful. It describes how/where to get the software that is used for creating a WYSE USB Image stick. However, it looks like it wants the image file to be an RSP file, and I've not found a reliable source on what exactly that EVEN is.I just now tried a "MS-DOS 7.1" boot floppy with a USB floppy drive. I was able to wipe and repartition the DOM with FDISK then reboot and format c: /s then reboot to a DOS prompt off the DOM. Then I tried the Lite USB install of the latest FreeDOS, same exact failure as before. I have made Windows CE and WYSE Linux installers. First I UPDATED all three of my S30's to the last WYSE release of Windows CE, along with their BIOS. Then I figured out how to put their Linux on one. They're locked to the OS they shipped with but knowing that WYSE offered an XP Embedded kit to upgrade any Sx0 (except the first version with soldered RAM) to S90, I figured there had to be a back door to cross-upgrade the OS. It's simple, there's a configuration file that's put on the USB stick, with a "key" that the install matches to what's embedded SOMEWHERE in the hardware. So to put WYSE Linux on an S30, just make both a WinCE and a Linux update stick then find the WinCE key and replace the Linux key with it. I'd bet all the older WYSE thin clients are done the same way. WYSE ThinOS is a different beastie. That was the S10 model and ThinOS goes into the BIOS chip. the other models may or may not have a larger BIOS chip and in any case you just can't simply download the latest/last update for it. |
|
| 1186. |
Solve : Batch script problem:splitting a big txt file into many 4000 lines? |
|
Answer» Batch script problem:splitting a BIG txt file into many 4000 lines Not sure what your NULL issue is. As far as I know, batch cannot generate a null character on its own. Were both on same page with that one. That's why I also asked what is generating this text file. |
|
| 1187. |
Solve : Copy files between specific dates? |
|
Answer» Hello everyone, |
|
| 1188. |
Solve : How to return success/failure from a batch file?? |
|
Answer» Hello, If one of b.bat's commands fails because of an error then it will set errorlevel to 1 and exit the batch program, returning to a.bat. Not quite. Not all MS commands fail with errorlevel 1. XCOPY, for instance can fail with errorlevels 1 to 5. This type of compare ("%errorlevel%=="0") becomes dubious at best. B.bat can use the exit statement to pass a return code (errorlevel) back to a.bat. Quote Quits the CMD.EXE program (command interpreter) or the current batch Quote from: Sidewinder on September 09, 2008, 06:12:06 PM Quote from: fireballs on September 09, 2008, 04:23:57 PMIf one of b.bat's commands fails because of an error then it will set errorlevel to 1 and exit the batch program, returning to a.bat. yes there are instances where the errorlevel won't be 1 choice returns 254 if there's an error. exit requires that you use the same if error gtr 0 but with exit as the command FB Quote exit requires that you use the same if error gtr 0 but with exit as the command Don't really understand this. I was thinking more along the line where b.bat would abort EARLY based on some condition: b.bat Code: [Select]if not exist c:\file.ext exit 7 if not defined userprofile exit 9 exit 0 a.bat could the query the errorlevel and proceed accordingly, which is what I interpreted the OP requested. Quote from: Sidewinder on September 09, 2008, 06:51:56 PM Quoteexit requires that you use the same if error gtr 0 but with exit as the command sorry i've beed drinking so my post contained several spelling mistakes, what i meant is that you'd still have to SPECIFY under what conditions to exit with a specific exit condition using the if command. it requires a finite amount of things that could be an error. if you use Code: [Select]if errorlevel gtr 0 exit /b [1] anything over errorleve==1 would exit with exit code 1 FByou can use: Code: [Select]&& if success || if fail example: Code: [Select]set /a var=1/0 && echo A set /a var=1/0 || echo A Quote from: Sidewinder on September 09, 2008, 06:12:06 PM Quote from: fireballs on September 09, 2008, 04:23:57 PMIf one of b.bat's commands fails because of an error then it will set errorlevel to 1 and exit the batch program, returning to a.bat. That's exactly what I was looking for! Thanks a lot! Works like a charm! Gabor C:\>A.bat "Hello World" "Call B.bat" "We are in B.bat." "Return exit code from B.bat" "errorlevel=77" 77 Press any key to continue . . . C:\>type A.bat ECHO OFF echo "Hello World" echo "Call B.bat" Call B.bat echo "Return exit code from B.bat" echo "errorlevel=%errorlevel%" echo %errorlevel% pause C:\>type B.bat REM return exit code to Batch A.bat ECHO OFF echo "We are in B.bat." exit /B 77 C:\> a little late to the party, methinks... Quote Reply #9 on: September 10, 2008, 09:45:23 AMQuote from: grevesz on September 09, 2008, 02:31:33 PM How do I return 0 for success ate the end of an MSDOS batch file? The most direct way is via exit /b value, However, in Windows 8.1 at least, that doesn't support && and || in the invoking command. To make those operators work, exit via the end of the batch file, where you place a cmd /c exit value, e.g., Code: [Select]echo off setlocal set E_FAIL=2147500037 set exit_code=%E_FAIL% set /p a=Pretend to succeed (y/n)? if "%a%"=="y" goto succeed :fail set exit_code=%E_FAIL% & goto finish :succeed set exit_code=0 & goto finish :finish cmd /c exit %exit_code% For example, if that file is called cmd_status.bat, then you can test it with Code: [Select]cmd_status && echo OK || echo Bah The Topic is 6 Years old... Don't think he'll return. Quote from: diablo416 on September 09, 2008, 03:25:36 PM heres an example |
|
| 1189. |
Solve : A batch file to delete files based on time created/modified? |
|
Answer» I am trying out some time lapse photography to capture building work over the next 18 months. Unfortunately the software I am using cannot be scheduled so I am getting photos 24/7. I thought the simplest way to deal with this would be a daily batch file to delete the photos taken between 0000 & 0800 and 1700 & 2359. However, I can only find how to create a batch file based on the date, but not on the time. Can anyone help? Alternative solutions are also welcome. I am using Windows 8.1Are the image files themselves named with date/time or do the names follow some other scheme? However it has occurred to me that it is quite easy, in Windows Explorer, to delete files created in a time range by choosing Details view and then sorting in date created order, using a mouse left click to select the first file to be deleted, then extending the selection by using the SHIFT and the down arrow keys until the last file to be deleted is reached, finally pressing the DEL key. Then the files will move to the Recycle Bin and can be recovered if needed, or SHIFT + DEL will remove them forever. Of course if there are lots of folders to be treated or if there are files from many days a scripted solution might be preferred. Reading down the list of replies etc, I came to same idea that Salmon did with why not just sort by date and select the range to delete. However if there is a need to automate the clean up of files, then i can see using a scripted method. In the past I had a script that would delete data from computer class lab computers in which we initially use to reimage them clean after each course was completed to make sure that they were all clean and fresh for the next class starting that next monday after completion on that friday, and instead of reimaging all the 20 systems, it was decided to just restrict the users on the lab systems to user privileges so that they couldnt install anything and very unlikely to get hit with malware, and give them a specific folder to save their work to with no other path to save to under privileges. Then instead of having to wipe entire systems clean and reimage which takes time, floods the network for about an hour or so on a Saturday and overworks the hard drives of each of the systems, its just a matter of running a quick batch routine from my system that would wipe out the data from that one folder on all 20 systems and REPLACE the pdf's in that folder with the course content for that monday depending on what they were going to be learning. Verses prior reimaging each system to make clean and delete old student data and then repopulating the system with the course content data that is local to each system for students to be able to edit and highlight SECTIONS in their PDF's etc. This could have been added to a scheduled task etc instead of a manual start of the batch that ran out to all 20 systems with the folder shared for me to wipe clean and repopulate with clean copies of the course content vs the prior content that was altered with highlighted sections and personal notations. Quote from: foxidrive on October 04, 2014, 11:08:28 AM foreach( $item in (Get-ChildItem -file)) {if( $item.LastWriteTime -ge '08:00' -and $item.LastWriteTime -le '17:00' ) Won't that select those files whose last write time is 8 AM or after - and - earlier than or at 5 PM. i.e. the ones taken during the working day (the ones he wants to keep?) Incidentally, Alan (if I can call you that?) I see you specify deleting images taken between midnight and 8 AM, and between 5 PM and 11:59 PM, which is slightly ambiguous. Do you want to keep or delete files taken at 8:00 AM or 6:00 PM? Quote from: Salmon Trout on October 04, 2014, 11:21:34 AM Won't that select those files whose last write time is 8 AM or after - and - earlier than or at 5 PM. i.e. the ones taken during the working day (the ones he wants to keep?) yeah, I was editing and changing stuff and lost track of what was what. Thanks for the warning - I changed the POST above. Quote from: DaveLembke on October 04, 2014, 11:17:19 AM why not just sort by date and select the range to delete. That could be done but it's not going to be as straight forward and needs to consider both 12 and 24 hour time formats (also assuming that the files in the folder are from the current date). If we could just get a sample of %%~t from the OP, we'd know the local date/time format & it would just be something simple like if %hour% LSS 8 and if %hour% GTR 17, so if you are still there, Alan, let's hear from you! More OP's get abducted by aliens here than any other section of the Forums... Quote from: patio on October 04, 2014, 03:40:45 PM More OP's get abducted by aliens here than any other section of the Forums...No officer, there is nothing in my trunk. Quote Quote from: patio on Today at 07:40:45 AM Quote from: Squashman on October 04, 2014, 04:31:32 PM No officer, there is nothing in my trunk. Beware the ana1 probe... Quote from: foxidrive on October 04, 2014, 06:09:41 PM Beware the ana1 probe... Don't knock it if you haven't tried it... Code: [Select]echo off setlocal enabledelayedexpansion echo Set fso = CreateObject("Scripting.FileSystemObject") > fhour.vbs echo Set f = fso.GetFile(trim(wscript.arguments(0))) >> fhour.vbs echo wscript.echo Hour (f.DateCreated) >> fhour.vbs for %%A in (s:\tdate\*.jpg) do ( for /f "delims=" %%B in ('cscript //nologo fhour.vbs %%~dpnxA') do ( set "action=Keep " if %%B lss 8 set action=Delete if %%B geq 17 set action=Delete echo !Action! %%~tA %%~dpnxA if "!Action!"=="Delete" del "%%~dpnxA" > nul ) ) Yours is a better solution Salmon Trout, as it handles any days files. You've done the hard work, I just polished it at the edges. I altered your code slightly so that the batch file can reside in the same folder, and removed the need for delayed expansion and the .vbs file is created in %temp% echoing the date/time stamp could be confusing because the last modified time can be different, so I removed that also. Code: [Select]echo off :: (modified) original code by Salmon Trout - Oct 2014 :: - deletes files with creation time earlier than 08:00 and after 16:59 (on files from any day) :: > "%temp%\fhour.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject") >> "%temp%\fhour.vbs" echo Set f = fso.GetFile(trim(wscript.arguments(0))) >> "%temp%\fhour.vbs" echo wscript.echo Hour (f.DateCreated) for %%A in ("c:\folder\*.*") do ( for /f "delims=" %%B in ('cscript /nologo "%temp%\fhour.vbs" "%%~fA"') do ( set "action=" if %%B lss 8 set action=Delete if %%B geq 17 set action=Delete if /i not "%%~fA"=="%~f0" if defined action echo deleting "%%~fA" & del "%%~fA" ) ) pause |
|
| 1190. |
Solve : Batch file to unblock files copied from internet? |
|
Answer» Batch file to unblock files copied from internet?i found this: https://stackoverflow.com/questions/15263523/batch-file-to-unblock-files-copied-from-internet |
|
| 1191. |
Solve : Need help with a few commands from my command line class? |
|
Answer» I need help with the following question: Microsoft Windows [Version 6.1.7601]The Internet was not created so that you could dump your homework assignments verbatim into a Q&A forum for someone to do it for you. You will never learn to do anything for yourself if that is how you want to get through life. Quote from: Squashman on November 19, 2017, 03:06:21 PM The Internet was not created so that you could dump your homework assignments verbatim into a Q&A forum for someone to do it for you. You will never learn to do anything for yourself if that is how you want to get through life. Ok, well I never asked for someone to do it for me. I just wanted a guide from a more personal source because the 2nd question was very specific and I still wasn't able to figure it out after reading through the my textbook and researching online. Also, I don't believe it is your place to decide how the Internet should be used. In fact, the Internet was created to ENABLE computers to connect and share information between universities, but obviously, that has changed over the YEARS. I did not know where else to turn to for help, so instead of trying to belittle me and giving me a life lesson, you could have shared another place I could have gone to for this, or not say anything at all. Sorry if I offended anyone with this post.What is strange is why anybody would tell anybody to study DOS batch scripts for any reason. It is a skill that will die like magnetic memory bead threading. Might as well teach students Latin. Thinking about it, , Latin has more promise Image for Wikipedia. Quote from: Sooshi4u on November 19, 2017, 05:01:05 PM I still wasn't able to figure it out after reading through the my textbook and researching online.So you didn't read the help file? Code: [Select]Microsoft Windows [Version 10.0.15063] (c) 2017 Microsoft Corporation. All rights reserved. C:\Users\Squashman>copy /? Copies one or more files to another location. COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination [/A | /B]] source Specifies the file or files to be copied. /A Indicates an ASCII text file. /B Indicates a binary file. /D Allow the destination file to be created decrypted destination Specifies the directory and/or filename for the new file(s). /V Verifies that new files are written correctly. /N Uses short filename, if available, when copying a file with a non-8dot3 name. /Y Suppresses prompting to confirm you want to overwrite an existing destination file. /-Y Causes prompting to confirm you want to overwrite an existing destination file. /Z Copies networked files in restartable mode. /L If the source is a symbolic link, copy the link to the target instead of the actual file the source link points to. The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless COPY command is being executed from within a batch script. To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format). C:\Users\Squashman> Ignore all the command line switches for the copy command and the help file says. Code: [Select]copy source destination source Specifies the file or files to be copied. destination Specifies the directory and/or filename for the new file(s). So lets break that down. Essentially copying a file you have to know the SOURCE of the file and the DESTINATION of the file. The source and destination are clearly defined in your homework assignment. SOURCE: On your C: drive you have a directory named HOMEWORK, in the HOMEWORK directory you have a directory named ENGLISH. In the ENGLISH directory you have a directory named STUFF. You have your final presentation paper in the STUFF directory named english.txt. DESTINATION: copy the english.txt file to your usb drive which is drive e:\. On drive e:\ you have a directory named PRINT. copy the english.txt file to the PRINT directory on the e:\ and name it efinal.txt. So tell me what your source and destinations are? Quote from: Geek-9pm on November 19, 2017, 06:15:16 PM What is strange is why anybody would tell anybody to study DOS batch scripts for any reason. It is a skill that will die like magnetic memory bead threading.A) They are NOT DOS batch scripts any more. B) Saying that is like telling a Unix admin they can't write BASH scripts anymore. C) CMD.exe and Windows have a lot more commands to play with then DOS did. D) My department generates $16 Million dollars a year in revenue off of the automation I design using batch files. E) I went to a Catholic High School. They stopped teaching Latin at my high school in the 80's! He closed his account... Quote from: Squashman on November 19, 2017, 07:18:31 PM
so... copy c:\HOMEWORK\ENGLISH\STUFF\english.txt E:\PRINT\efinal.txt ?? I'm not sure how to RENAME itC:\Save xcopy bob /s /h |
|
| 1192. |
Solve : Batch file to show or delete a numbered task names? |
|
Answer» Hi Answered on DosTipsThank you very much for your help |
|
| 1193. |
Solve : Batch Script- padding a “0” into script as well as few bug fixes? |
|
Answer» Currently there are a few problems I am experiencing with the BATCH file I created.: |
|
| 1194. |
Solve : Coomnd to unzip a folder full of ZIP files?? |
|
Answer» On this PC I have downloaded a bunch of ZIP files. You have 3 OS's on that PC ? ?Yes, It has a 500 GB hard drive, which is more than enough for three OS and lots of stuff I like to have at hand. I is an old refurbished dell 755 I got on eBay. I put in the 500 GB drive and installed the three OS on it. Do you have any ideas about how to automate the ZIP extraction? Would Windows 10 do it faster, better or easier? It is rather slow in Windows XP. and I start to fall asleep. With Zipware (free) you can select multiple Zip files in Windows Explorer, then right click the ensemble and select Zipware from the context menu & CHOOSE to unzip each archive to a separate folder named after the zip file, or all in the same folder, or somewhere else... System Requirements Windows 10 Windows 8.1 Windows 7 Windows Vista Windows XP Windows Server 2016 Windows Server 2012 Windows Server 2008 Windows Server 2003 Windows 32/64 bit Windows .NET 4.0 Web page https://www.zipware.org/ Click to enlarge image Salmon Trout, Thanks, Zipware is what I need. And it is free! Great! I can afford free. 7-Zip also has a batch option to unzip multiple files. My guess would be that most of the 3rd party archive tools have that ability.Thanks, I have used different zip programs before, but this is the first time I had to unzip forty folders at one time. The program Salmon gave does the job very well. Each zip folder had a lot of stuff inside, so I wanted to make sure it all went into the right place. The check it out, I have it do a set of five at a time. That worked GOOD, so then I had it do all the rest. Thanks for responding. If you have 7-Zip you can do the exactly same thing - extract each zip archive to a separate folder (which will be in the same folder as the archives), but you need to do 2 things 1. Make 7-Zip show its context menu when right clicking multiple zip archives: a. Open 7-Zip b. Choose Options c. Choose the 7-Zip tab d. Make sure "Integrate 7-Zip to shell context menu" is checked/ticked (it isn't in the picture) e. Click OK 2. Use the correct context menu choice. Select one or more zip archive(s) in Windows Explorer and right click them and a 7-Zip entry is in the context menu. If you have only selected one archive, it offers to extract to a folder named for/after the archive; If you selected more than one, the option to extract each to its own folder is rather baffingly named "Extract to "\". Salmon Trout, Another thanks. Good Post I did not know you could put 7-Zip into the shell menu That makes the thread of greater value to others. So, for anybody who already has 7-Zip, follow the steps shown by Salmon Trout above. Make sure you find the place where it says: "Integrate 7-Zip to shell context menu" And you will be ready to go. You can also select that option when installing 7Zip....I have found that 7-Zip has an advantage over Zipware. If you select one or more zip archives, and then right-click and drag them into another different folder, when you let go the right mouse button, you get the context menu, and the 7-zip entry offers its options but applying to that destination folder. Zipware does not do this. |
|
| 1195. |
Solve : Do you really need EXIT at the end of a BAT file?? |
|
Answer» I leave off EXIT, and the BAT file works fine. I don't notice any problems. Thanks! When do you ever want to set an "exit code"? . . . Also, if the .BAT file ran, why would there be an error? Don't think of it as always an indication of an "error". Sometimes it is just an "exit code". Historically, going right back to MS-DOS in the Microsoft world, programs and scripts have been able to leave behind a code, that is a number, in memory, which another script or program can read. It was called "ERRORLEVEL" and the name has stuck. Here are two simple EXAMPLE scripts. Put them both in the same folder and run test1.bat (1) test1.bat Code: [Select]echo off echo Running test2.bat... call test2.bat echo Back from test2.bat if %errorlevel% equ 255 echo Answer was "yes" if %errorlevel% equ 128 echo Answer was "no" pause (2) test2.bat Code: [Select]echo off :loop set /p a="Are you happy (answer y or n)? " if /i "%a%"=="y" exit /B 255 if /i "%a%"=="n" exit /B 128 echo Answer y or n! goto loop You can catch errorlevels returned by other languages: Put these in the same folder as each other and run test3.bat (1) stringlen.vbs Code: [Select]wscript.quit len(wscript.arguments(0)) (2) test3.bat Code: [Select]echo off :loop set /p str="Enter a string: " if "%str%"=="" echo String cannot be empty & goto loop wscript stringlen.vbs %str% echo String has %errorlevel% character(s) pause This would be better... copes when string has spaces... (2) test3.bat Code: [Select]echo off :loop set /p str="Enter a string: " if "%str%"=="" echo String cannot be empty & goto loop wscript stringlen.vbs "%str%" echo String has %errorlevel% character(s) pause |
|
| 1196. |
Solve : Batch file for deleting files outside of time window? |
|
Answer» Hi folks, Q. I have some old pictures, mostly JPGs, that I have copied to my wife’s PC, and the dates for the files are different on her PC than on mine. Why is that and which ones are correct? My PC is running Windows XP, and hers has Windows 7.The above article goes on to explain the special case of JPEG files. Thanks for the reply Geek, sounds like "date taken" may be an option. Data can be viewed in windows explorer by "date taken". I'm less convinced now that my problem is in fact the "date created" issue because I copied a bunch of photos (at 1pm), ran the macro, and it deleted the photos DESPITE appearing to pass the "keep" criteria of being created between 8am and 5pm. In order to get the macro working I had to change the file path and add an action to the FOR loop. In its original version the macro simply has Code: [Select]set "action=" and will hang up until something is added after the equals sign. I'm not sure if that's part of my problem as well. So the macro I'm currently trying to run is as follows: Code: [Select]echo off :: (modified) original code by Salmon Trout - Oct 2014 :: - deletes files with creation time earlier than 08:00 and after 16:59 (on files from any day) :: > "%temp%\fhour.vbs" echo Set fso = CreateObject("Scripting.FileSystemObject") >> "%temp%\fhour.vbs" echo Set f = fso.GetFile(trim(wscript.arguments(0))) >> "%temp%\fhour.vbs" echo wscript.echo Hour (f.DateCreated) for %%A in ("c:\349GOPRO\*.*") do ( for /f "delims=" %%B in ('cscript /nologo "%temp%\fhour.vbs" "%%~fA"') do ( set "action=Keep" if %%B lss 8 set action=Delete if %%B geq 18 set action=Delete if /i not "%%~fA"=="%~f0" if defined action echo deleting "%%~fA" & del "%%~fA" ) ) pause FYI photos are being taken with Gopro Hero 3 and 4's and I'm running a couple PCs, one with windows 7 and one with windows 10. Currently it is deleting everything regardless of date created/modified/taken. If anyone knows what my problem is I'd greatly appreciate some help. Thanks! The set "action=" was there for a reason, as you've discovered With each file, it unsets the variable via set "action=", then it sets that variable if the hour of the DateCreated is less than 8 or greater than 18. Since you've changed it to always set the variable, it now deletes every file. I'd expect that what is seen as a hang may be that it is processing many files which do not meet the criteria. It will only output information when it deletes files. Also, regarding your original notes regarding modification dates, You can change the DateCreated line reference to this to change the date being used: Code: [Select]>> "%temp%\fhour.vbs" echo wscript.echo Hour (f.DateLastModified)Holy crap you're right and it works! I have been SAVED many hours of manual deleting. Thanks a ton for the response. JeremyI suppose if you would have read the code and took the time to understand it you could have seen how obvious it was to fix. https://ss64.com/vb/filesystemobject.html |
|
| 1197. |
Solve : Batch file to make folders with part of folder name and then copy files? |
|
Answer» Hello! echo offI have some other attempts based on other posts i've found, if they help let me know!This is the example I tested with based on your description. Code: [Select]C:\Nature>dir /ad /s /b C:\Nature\(C323) Fox (Carnivore) C:\Nature\C123) Wolf (Carnivore)Using this code. Code: [Select]echo off FOR /D %%G IN (*) DO ( FOR /F "tokens=3 delims=()" %%H IN ("%%~G") DO ( MD "%%~H" 2>nul move "%%~G" "%%~H" ) )Running the batch file. Code: [Select]C:\Nature>FolderMove.bat 1 dir(s) moved. 1 dir(s) moved. C:\Nature>dir /ad /s /b C:\Nature\Carnivore C:\Nature\Carnivore\(C323) Fox (Carnivore) C:\Nature\Carnivore\C123) Wolf (Carnivore) C:\Nature> |
|
| 1198. |
Solve : MSDOS Freezes, Hanging? |
|
Answer» Hi all. New here so first of all, greeetings!
I havent yet checked the RAM or fully checked things like the AWE32's IRQ or Address altough I know they are different to factory but I'm wondering if there is something else I should try or whether someone has suggestions? Its a shame as its for using older equipment of mine and this LEGACY isnt my speciality Thanks for your time! Quote on a 4GB FAT partition FAT16 or FAT32? If FAT16, cluster sizes larger than 32K can cause problems in "pure" MS-DOS and for MS-DOS Applications. If FAT32, FAT32 can cause problems in "pure" MS-DOS as well, Even if you have MS-DOS 7.1 (which I should mention isn't "legitimate"- it's a hacked release ripped out of Windows 98SE) You can eliminate that as the possible CULPRIT but using a separate partition for MS-DOS altogether, a <2GB FAT16 partition for MS-DOS and a FAT32 partition for Windows 98.I'd run memtest86 if you can get it to boot off of a CD. 80MB RAM means you have mismatched capacity and maybe even brand and latency etc. You might find that the issues are in a RAM stick or pair of RAM sticks that dont play well with others, meaning you might be dropping your RAM to 64MB to get it to behave until you get more RAM that is compatible with already existing RAM or a new used good set of RAM for greater than 64MB. I ran into problems like your having years ago with a 486 and 24MB RAM. I stuffed as much RAM as I could into it and come to find out with 8MB - 8MB - 4MB - 4MB sticks in the memory slots one of the 4MB sticks had and issue, so I had to DROP it to 20MB until I got two more used off of ebay 8MB sticks that were same latency as the 8MB sticks I already had to bring it to 32MB. I had where Windows 95 would behave for the most part, but games would randomly hang and crash. Not sure if this is because Windows 95 was using mainly the 8MB sticks and the games ran into the upper memory where the 4MB sticks were in slots 2 and 3 where 8MB sticks were in slots 0 and 1, if memory placement even matters in controlling where an OS loads to vs games etc. It might be that RAM is evenly used among all 4 slots vs loading up from the beginning of slot 0 working its way up to slot 3 etc. Never researched that. However more than once a troubled stick in the tail end slots seems to be detected later vs sooner which might just be coincidence or maybe memory is loaded in order from lower to upper memory address vs whatever address is next available. Quote from: BC_Programmer on January 06, 2018, 08:36:27 AM FAT16 or FAT32? That's a good point. I follow LGR on youtube and he mentions all the time about only being able to use 2GB for DOS partitions. I'll have to check the file format, I'm thinking that it might be FAT32 now. Quote from: DaveLembke on January 06, 2018, 09:04:33 AM I'd run memtest86 if you can get it to boot off of a CD. 80MB RAM means you have mismatched capacity and maybe even brand and latency etc. You might find that the issues are in a RAM stick or pair of RAM sticks that dont play well with others, meaning you might be dropping your RAM to 64MB to get it to behave until you get more RAM that is compatible with already existing RAM or a new used good set of RAM for greater than 64MB. I'll INVESTIGATE that too. The memory did strike me as an odd size so might have to hold for some matched pair of SIMMs. Thanks for the responses, will try them out! |
|
| 1199. |
Solve : robocopy copy and save the replaced file in different folder?? |
|
Answer» Hi guys, I got another question. USING robocopy command to copy from one location to another. when I copy something from one location to another it will replace the file with older time stamp or file size. but how can I make so that file that is replaced, instead of being replaced/deleted that it would be SAVED to a different folder? |
|
| 1200. |
Solve : multiple renaming files? |
|
Answer» Can someone help me rename multiple files. If copied.txt exists already, what should happen to it? nothing. copied.txt should stay as it is, but not_copied.txt should rename to copied.txt Quote from: Blisk on December 22, 2018, 06:29:40 AM nothing. Rename will fail because you cannot have two files in a folder with the same name. Quote from: Salmon Trout on December 22, 2018, 07:09:02 AM Rename will fail because you cannot have two files in a folder with the same name.there is no two files in folder with same name, it is only one file.Your original question seeks to do this: Quote d:\myfolder\archive\john\documents\today\not_copied.txt That is, not_copied.txt renamed to copied.txt in that folder. I asked: Quote If copied.txt exists already, what should happen to it? I clearly meant "if d:\myfolder\archive\john\documents\today\copied.txt already exists in that folder, what should happen to it?" One of us is confused, which one? if that file exist than it should leave it if there exist not_copied.txt it should rename it if laso file exist.txt exist.You cannot have 2 files called copied.txt in the same folder. If copied.txt already exists in the same folder, what NEW name should not_copied.txt have? And what if that new name already exists etc? Are these really the names, or just placeholders used in your question? I have a script which looks OK, but I shall not post it here unless you address this. I will soon click "unnotify", so please answer if you want any more help. Quote from: Salmon Trout on December 22, 2018, 07:31:11 AM Your original question seeks to do this:Did they edit their question at some point because I see this. d:\myfolder\archive\nina\documents\exist.txt d:\myfolder\archive\nina\documents\today\not_copied.txt Quote from: Squashman on December 22, 2018, 10:11:06 PM Did they edit their question at some point because I see this. That was not edited; that is not the problem. The requirement appears to be this: Quote d:\myfolder\archive\nina\documents\exist.txt See? Same folder for copied.txt (the desired end result) I guess this could be an error. That is Look in folder $NAME\documents for a file called exists.txt If it is found: Look in folder $NAME\documents\today for a file called not_copied.txt If that is found: Rename it to copied_txt I appear to have set the cat among the pigeons by asking innocently "What happens if copied.txt already exists?". Looking behind the CODE for a moment, I am wondering if the desired end result is to copy or move not_copied.txt to another folder as copied.txt. That is, conceptually, the names copied and not_copied clash with the idea of 'rename'. Copy duplicates a file; rename leaves it in place. The question of what to do if the desired destination file place/name already exists still remains, though. |
|