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.
| 5701. |
Solve : Need help with a batch file? |
|
Answer» I am installing AIM via a batch file process. Due to the way AIM installs itself I can't seem to get it to install silently as there are no switches that I have found that can do this. ANYWAY everything seems to be fine until the install finishes , at that point it pops a box up and asks to click close. I would like to somehow SCRIPT for a way to either click the close button for the user or somehow put into the script a timeout with a taskkill or something where after say 40 seconds the batch would kill setup.exe and continue to execute ? |
|
| 5702. |
Solve : echo %%i throu FOR loop? |
|
Answer» Dear friends, in batch i write for /f "delims=" %%i in ('find "ABC" ^<MyFile.TXT') do echo.%%i>> NewFile.TXT Or this: Quote find "ABC" <MyFile.TXT >>NewFile.TXTThank you very very much, i use the 1st suggetion because i need more manipulations. Please tell me what is this use/behaviour of ^ before the input < after your solution i tried instead of the use of ^ this: '"find "ABC" OK i realized that it's an escape char that causes to interpret codes as simple chars. I see that robvanderwoude has a lot about it. again thank you very muchQuote from: yossi_moses on JULY 25, 2012, 08:38:35 AM after your solution i tried instead of the use of ^ this: '"find "ABC" <MyFile.TXT"' and it also worked. If you try that again in a for in do loop command you will find that it generates an error and will fail. I'm glad you found the solution useful. Am I missing something? Code: [Select]C:\>type myfile.txt abc&def abc<def abc|def abc>def 123>asd\678 123<asd\678 123&asd\678 123|asd\678 C:\>type test1.bat @echo off for /f "delims=" %%i in (myfile.txt) do echo.%%i>>newfile.txt C:\>test1.bat C:\>type newfile.txt abc&def abc<def abc|def abc>def 123>asd\678 123<asd\678 123&asd\678 123|asd\678 C:\> A later post revealed that this was more like the real request: for /f "delims=" %%i in (MyFile.TXT) do echo.%%i|find "ABC" >> NewFile.TXTDear Salmon Trout, 1st, thanks a lot. But it seems that indeed some thing is missed. very strange, but ECHO%%Var>FileName is well escaped (no need for escape chars), and ECHO%%Var|FIND is not escaped. Please HELP me to UNDERSTAND how to thank in a way that my thank to any body will be counted in the forum. Thanks |
|
| 5703. |
Solve : Read from file named after the next day in the week? |
|
Answer» I'm stuck trying to do something in a batch file based on the day of the week. Here's some of the code: Code: [Select] set /a Tomorrow=%M%+1M is equal to 1.Monday. So you end up with your code failing. Code: [Select]C:\Users\Squash>set M=1.Monday C:\Users\Squash>set /a tomorrow=%M% + 1 Missing operator. But you could substring the variable Code: [Select]C:\Users\Squash>set /a tomorrow=%M:~0,1% + 1 2What happens at :SPECIAL? Also, you can replace these 2 lines IF %M%==Q GOTO :QUIT_ADMIN IF %M%==q GOTO :QUIT_ADMIN with this one line IF /I %M%==Q GOTO :QUIT_ADMIN Salmon Trout - Special is used when the standard daily list changes. Rather than append the changes to Tuesday.txt (for example) a separate list is made. Thanks for the tip about Quit. I'll apply that for sure. I have several other scripts where I account for both upper and lower case entries from the user so this is nice to know. Squashman - Thank you for your help. I didn't realize that what I asked for %M%+1 could work. Maybe it didn't. I added SET /A Tomorrow=%M% + 1 and "2" was returned SET /A Tomorrow=M + 1 and "2" was returned SET /A Tomorrow=%M:~0,1% + 1, "2" was returned Since my lists are named after the day of the week is it possible for %M% + 1 to equal "Tuesday" instead of "2"? Thanks again, MJ Not really understanding what you are trying to do. Code: [Select]SET /P M= IF %M%==1 ( SET TOMORROW=TUESDAY GOTO :MONDAY ) IF %M%==2 ( SET TOMORROW=WEDNESDAY GOTO :TUESDAY ) IF %M%==3 ( SET TOMORROW=THURSDAY GOTO :WEDNESDAY ) IF %M%==4 ( SET TOMORROW=FRIDAY GOTO :THURSDAY ) IF %M%==5 ( SET TOMORROW=SATURDAY GOTO :FRIDAY ) IF %M%==6 ( SET M=Special GOTO :SPECIAL ) IF %M%==Q GOTO :QUIT_ADMIN IF %M%==q GOTO :QUIT_ADMINIt could probably be streamlined if we knew the purpose and code. I'm guessing that the code for the actual function is repeated 7 times with just a name changed for the file each daySquashman - thanks again. It appears that I was mentally over-complicating things and I'm not much of a script writer. SET TOMORROW= was what I was looking for. It allowed me to tidy up one script and cut 3/4 of another one out. Every night I have to drain servers in two different farms. The script determines the day of the week and then references preconfigured lists named after the days of the week to run wlbs commands against. For example: on Monday the script determines that it's Monday and loads the servers from the Tuesday.txt list, emails the proper parties the list of servers that scheduled to be drained, drains them, creates a log, emails me the log and cleans up the temporary txt files it creates in the process. Perhaps you can help me clean up another segment of the script: Code: [Select]FINDSTR /V "WLBS" logs\templog.txt >>logs\format.txt FOR /F "Tokens=* Delims= " %%A in (logs\format.txt) do ( SET /a N+=1 echo ^%%A^ >>logs\RebootLog.txt This part of the script searches templog.txt and outputs every line that doesn't start with WLBS to format.txt. Blat is being used for emailing the logs. When Blat reads RebootLog.txt and copies the contents into the body of an email it isn't easily read. So I use the next lines of code to read the contents of format.txt and add a space between each line so the body of the email that Blat sends is easily read. Is there a simpler way to add a CR at the end of every line of text in templog.txt so I can just echo it to RebootLog.txt and bypass the need for format.txt? Thanks, MJNot understanding you again. I am one of those people who needs to see examples. What the Input Looks like and what the desired output needs to look like. Then I code based on that information.The text that is output to the log report (templog.txt) looks like this: Did not receive response from the cluster. Did not receive response from the cluster. Did not receive response from the cluster. Did not receive response from the cluster. But, when Blat uses the templog.txt file to create the email body the text in the email body looks like this: Did not receive response from the cluster.Did not receive response from the cluster.Did not receive response from the cluster.Did not receive response from the cluster. I am ECHOING the contents of templog.txt to format.txt to correct the formatting so the email body looks like this: Did not receive response from the cluster. Did not receive response from the cluster. Did not receive response from the cluster. Did not receive response from the cluster. I'd prefer not to have to use format.txt to finesses the data but there's something about how Blat views templog.txt (which is a plain text file btw) that is forcing the need. I just wonder if there is a less involved way to do what I've done than Code: [Select]findstr /V "WLBS" logs\templog.txt >>logs\format.txt FOR /F "Tokens=* Delims= " %%A in (logs\format.txt) do ( SET /a N+=1 echo ^%%A^ >>logs\RebootLog.txt Thanks, MJCan we see the entire batch file.I'm guessing that the line endings are not MSDOSsified. Try this to see what it spits out. Code: [Select]for /f "delims=" %%a in ('findstr /V "WLBS" logs\templog.txt') do cmd /c echo.%%a>>logs\RebootLog.txt |
|
| 5704. |
Solve : Can I run a com file in separate memory space?? |
|
Answer» rem.>file.txt creates a zero byte file. |
|
| 5705. |
Solve : need some help checking a batch file for errors? |
|
Answer» I made this batch file about a year ago to fix windows network scanning errors for a program CALLED Spiceworks. Somehow since then I forgot why some of the lines of code are the way that they are, and I think that I have most of the problems fixed now.. but I was hoping that someone could look at the file and see if there are any errors that need fixed. never expect volunteers to verify a long, long batch file This most of all. You see this type of question from time to time, and often nobody at all replies. Quote you need to make it cleaner for yourself. You can not remember a year later what you did. Maybe your code is much too long for yourself to visualize easily. . You need to break it up into short things the can e tested and verified. These are called subroutines and can be other batch files. You invoke such with the CALL keyword and pass arguments. Much easier to understand. This is definitely good advice. Start small and work your way up. Write and test the script in stages. Make sure each part works before adding another. Quote You need to make more comments about what things do Failing to COMMENT is one of the biggest mistakes that a batch scripter can make, in my opinion. Not only does good commenting help when you come back later on, it can help you right now, as you are actually writing the code, because it forces you to state in writing what a line or section of code is supposed to do. In order to do this, you have to actually think about that. If you just slap lines of code in because you hope they might do what you want, you'll end up with a mess, and you won't know what works and what doesn't (and why). Sometimes you need to turn echoing on to see where code is not doing what you want. For example here the code I show in red does absolutely nothing and if you put @echo on before it and @echo off after it, you will see why. SET INPUT= SET /p INPUT= IF "%INPUT%"=="1" GOTO RESTART IF "%INPUT%"=="2" GOTO END FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT% CLS GOTO Restart_Prompt It looks like it was left over from an earlier incarnation of the script where you made the code GOTO a variable label e.g. :1 :2 etc and then you found out that typing 3 made the script crash? well you could always run the program and see where it crashes, here's a script that will make a copy that creates a log of the commands that it does before it crashes, that way if it does have an error, you will know exactly which line it is on. Code: [Select] @echo off echo Enter Name Of File To Edit set /p name= echo @echo off >>%name%Bug.bat echo ^:^: This is a bug testing program for batch. >>%name%Bug.bat echo ^:^: Results may varry with scrips containing for loops. >>%name%Bug.bat echo ^:^: ******* By Lemonilla >>%name%Bug.bat for /f "delims=" %%G in (%name%.bat) do ( echo echo %%G ^>^>%name%Log.txt >>%name%Bug.bat echo %%G ^>^>%name%Log.txt >>%name%Bug.bat echo %%G >>%name%Bug.bat ) start %name%Bug.bat PS: Don't know if this works with multi-line for loops. |
|
| 5706. |
Solve : [help]about bootable flashdrive? |
|
Answer» can anyone HELP me how to make bootable FLASHDRIVE that can make a DOS command that have a boot disk start up dia,l recovery disk ,and SYSTEM disk?look up bootdisk.com for a bootable ISO image. |
|
| 5707. |
Solve : How to add new user environment variable uisng the DOS command??? |
|
Answer» Dear All, |
|
| 5708. |
Solve : ISO: DOS BATCH method to FIND+REPLACE text in TaskSched .XML file? |
|
Answer» Hi, I am looking for a way to SEARCH+REPLACE a string between two XML tags (see below), with a different string, using DOS BATCH. You would be better off not using batch, because this is impossible in vanilla batch. Your Posts will now be moderated from here out before they show up here... patio.Luigi Master is a 16 year old gal, it seems. It's nice to see gals doing batch stuff but you need to read a bit more widely Luigi Master, to learn a bit more about this and that. You didn't make a typo about your gender there, did you? PENchaotic, is COMPUTERNAME\USERNAME actual literal text, or someone's details? Quote from: PENchaotic on June 28, 2016, 09:32:33 AM Scenario: I have a .XML file (exported from TaskSched) that has the following lines: The line can be recreated completely in either case, and I'm only commenting that it may be variable text.Age nor gender have any bearing...seeing innaccurate advice over time is the deciding factor...I trawled through his, erm I mean her, posts before commenting, patio: I know exactly what you mean. My waffle wasn't meant to question any decisions - I'll avoid commenting in response to forum matters, as I should have done here. I wasn't sure how to phrase my point that Luigi didn't seem to be a gal. MEA culpa. Luigi is a boy's name, and 'master' is a male title. |
|
| 5709. |
Solve : Batch file to copy, rename and organize files from a CD to a HD? |
|
Answer» HELLO everybody, My name is Antoine, I'm new on this forum. I'm trying to DEVELOP the following batch file : My point : As a private pilot, I get every month a CD-ROM with updated information in PDF format (approach plates, rules, airport information, etc.), spread in various files and directories. The way these data are organized and named on that CD doesn't totally fit my needs, thus I would like to automatically transfer chosen data from the CD-ROM to my HD (E:\) in dedicated directories and with a completed name. For instance, airport visual approach plate files are identified on the CD-ROM with a long name containing amongst others the 4 letters of airport's ICAO name (eg LSZH). I would like the file's name to be automatically completed with the city name (eg ZURICH LSZH). Airports LIST is finished and I would fill up a conversion table for the name completion, either inside the batch file, or ideally in a separate text file. Depending on the PDF's file name, one can also find out what kind of information it contains and therefore in which directory to transfer it. For instance, visual approach charts PDFs name contain also the word "VAC", and I would transfer such files into a VAC folder on my HD. Currently I'm doing this job manually, but it's typically something that could (and should) be automated. I have very little experience with batch files, and didn't find out so far how to do it, especially check and modify long file names and how to create/work with a conversion table. How would you proceed to create such a batch file ? Is there a way doing it, or should I TURN towards another language ? Would anybody be nice enough to help me ? Thanks a lot in advance. Best regards Antoine My system : windows 7 64 How many places did you ask this question? I've seen two... and I don't want to waste my time if some people are doing work on your behalf in another forum.2 places only, yet...This point has been solved by foxidrive in another forum. For those who are interested in the solution, it's over there. A real big thank you to foxidrive for his very efficient support, and all my appologizes for any inconvenience - the goal was not to draw competition between fora... Best regards Antoine |
|
| 5710. |
Solve : Batch file to check multiple folders, if the folders it's checking has certain..? |
|
Answer» I want a batch file to check a lot of folder and check their sub folders for certain names. I am creating a Garry's Mod FastDL generator where the batch file has to check every addon (multiple folders) and check their subfolders, if they have the subfolders of the name "materials, models, sounds, SCRIPTS or particles", then it should copy it to a specific output folder, if it has any other folder, it shall NOT copy it over. This might sound confusing but if you read it carefully, you'll understand.And what have you started with so far ? ?I created a batch for Unreal Tournament 99, years ago that went in and added textures, sounds, maps, and all that. Not your specific game, but similar functionality. if they have the subfolders of the name "materials, models, sounds, scripts or particles", then it should copy it to a specific output folder This is not tested: Code: [Select]@echo off for %%a in ( materials models sounds scripts particles ) do for /d /R "d:\base\folder" %%b in (*) do if /i "%%~nxb"=="%%a" robocopy "%%b" "c:\output folder\%%a" /mir pause or you know Code: [Select]xcopy materials/* outputfolder/ xcopy models/* outputfolder/ xcopy sounds/* outputfolder/ xcopy scripts/* outputfolder/ xcopy particles/* outputfolder/ Quote from: Luigi master on June 27, 2016, 07:59:02 PM or you know How does your script determine where those folders are in the tree of folders? The OP is probably handing in his assignment as we SPEAK anyway. Oh, okay. |
|
| 5711. |
Solve : Drive A error. System Halt? |
|
Answer» Hi. My father very recently bult himself a new computer and asked me to help him get it running, but when i turn it on i get the following lines |
|
| 5712. |
Solve : Need a Batchscript that will check the version of a file-and Uninstall if exist? |
|
Answer» Basically i need a batch script that will first check if a particular file version exists., And if it does, it will uninstall it. If it does'nt exist, than it will do nothing and exit. are you guys not reading the subject of this thread?We apologise for the poor service. You can claim a full refund of your joining fee, and also of the fee you paid for asking your question. Please have your payment reference number ready when making the claim. nvm You can use powershell to get the version. Code: [Select]D:\>for /f "delims=" %%p in ('powershell -Command "(Get-Item C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe).VersionInfo.ProductVersion"') do set version=%%p the Product Version of the executable will be saved in %version% and you can compare it. Or WMIC Code: [Select]for /f "tokens=2 delims=," %%G in ('wmic datafile where "Name='C:\\Windows\\System32\\cmd.exe'" get Version /format:csv') do set cmdver=%%GThis assumes the executable was compiled with version information. Quote from: Salmon Trout on September 29, 2015, 11:58:56 AM This assumes the executable was compiled with version information.Well the information provided has been so clear on how we should solve this problem. We are all just grasping at straws. Not sure where else we would get the version information of the install. I guess it could be in the registry but I do not have this program installed to check if that is the case or not.Quote from: Squashman on September 29, 2015, 12:04:27 PM I guess it could be in the registry but I do not have this program installed to check if that is the case or not.This is one of the (considerable) stumbling blocks in our path. Quote from: Squashman on September 29, 2015, 12:04:27 PM I do not have this program installed to check if that is the case or not.I would be surprised if you did. Barracuda Message Archivers are a range of hardware appliances that sit on a corporate network and cost $2,000 for the Model 150 (max 150 users) via the Model 450 $10,000 dollars (max 1,000 users) to the model 1050 "request a quote" (max 18,000 users). All models require a mandatory yearly update subscription costing between hundreds and tens of thousands of dollars. So not home stuff. The Outlook add-in needs to have the same major version number as the appliance firmware. I am not an expert, but it seems from a cursory look at the maker's help pages that users with a valid ongoing subscription should be able to get help to keep their deployed software up to DATE. A big element of the publicity for these products is comprehensive security and suitability for use in situations where compliance with statutory or regulatory requirements is important. Audit trails. Pro stuff. So why is a "Barracuda Message Archiver Adminstrator" asking this on here? He was LIKELY promoted to a position he's ill suited for...Only thing worse than doing somebody's homework is doing their job... |
|
| 5713. |
Solve : Windows 98 is totally busted HELP? |
|
Answer» Ok so I'm just going to start out by saying I have a vast computer knowledge and even I can't figure this one out. Lets start from the beginning: uh sort of, it actually booted to dos (not ms-dos, just a generic dos prompt) and when it was done loading it said windows millenium in the command line...That was MS-DOS 8, the version of MS-DOS embedded into Windows ME, and Windows XP and later for some weird reason create a Windows ME Startup disk. You can make the CD drive accessible from DOS by using the appropriate driver. CH has an article on that here. (Personally, I just use OAKCDROM.SYS). If the OP has the original product key, he can use a copy of Windows 98 to bring his computer back up. Find a Windows 98 boot floppy disk image of the same version as on the hard drive, create a floppy and use it on the laptop to boot to the command prompt. Then type this command - if it breaks anything then you get to keep all the pieces and I will refund you what you have paid me for this random suggestion: Code: [Select]sys a: c: Quote from: BC_Programmer on March 20, 2015, 01:36:29 PM Here is the maintenance/troubleshooting manual for that system: well when I boot to the hard disk, now it loads ms-dos 6.22 and windows 3.11 since I installed them I have the manual and it's 0 help at all because it has nothing relevant in it. safe mode isn't a thing, f8 for msdos 6.22 lets me pick which autoexec and config lines to execute scan disk can not complete because some parts of my hard disk surface are so fragmented/broken that it freezes on one of the spots after 30 minutes of trying to fix it. I don't have the atapi ide cd driver (and there is a chance the cd drive is busted)Quote from: Geek-9pm on March 20, 2015, 04:55:22 PM If the OP has the original product key, he can use a copy of Windows 98 to bring his computer back up. i have the product key, it's my laptop. And it can't do that because like I said the cd drive can't boot properly and besides the disk that came with my copy of win 98 was a restore disk and since I removed the win 98 files a long time ago that doesn't help much.Quote from: Magicrafter13 on April 10, 2015, 07:29:33 PM well when I boot to the hard disk, now it loads ms-dos 6.22 and windows 3.11 since I installed them These pieces of the puzzle weren't mentioned, nor the fact that the hard drive is about to die a violent death. Quote scan disk can not complete because some parts of my hard disk surface are so fragmented/broken that it freezes on one of the spots after 30 minutes of trying to fix it. I must have written my last reply in invisible ink - sorry about that. I confuse the bottles every now and then and wonder why nobody responds to my comments. Silly old bugga I am. Ok, guys sorry I haven't replied or anything like that, but I did some of my own stuff blaw blaw win 3.1 win 95 (added CD support so that part is solved ) win 98 win 98 sec (_________________ anyway, I'm running but I would like the nostalgic feeling again of my actual experience w/the laptop, if anyone could point me in the direction of system.sav image for a Compaq Presario >>1625<< (obviously the win98 version) that would be amazing and thank you so much because I still have my QUICK restore disc and my serial key... just not the system.sav (Compaq did I dumb thing with having the reinstall as an image of the hard drive and since HP bought them... HP does it now too... Jesus Christ...)Quote from: foxidrive on April 10, 2015, 07:53:09 PM These pieces of the puzzle weren't mentioned, nor the fact that the hard drive is about to die a violent death. sorry it didn't crash, I actually did that again recently and it turns out they are just some bad clusters (still surface damage though) and it took 4-5 hours (lol omg) but It finally finished and well... that's good I guess |
|
| 5714. |
Solve : Find file names that have a capital letter in them....? |
|
Answer» I see how you can IGNORE the case of the letter in the file NAME, but I actually want a list of all file names in a folder, that have a capital letter in them. I will have to look up those echo parameters so I understand more about the output. if %%A is a file name %%~dA is the drive, %%~pA is the path, %%~nA is the bare name and %%~xA is the extension. You can combine them so %%~dpnxA is the whole drive letter, path and name. |
|
| 5715. |
Solve : More for loop troubles? |
|
Answer» So I was writing a game for fun, and I ran into a for loop problem where it isn't saving %%G into a veriable that I can call. Nor is it reading the full file. Any Idea's? Expantion That's not how you spell 'expansion' ... There is ALSO an issue where %%G is the outer loop VARIABLE and you are reusing %%G in the inner loops. It's wiser to use %%H %%J %%K etc in the inner loops.There is yet another issue: you can't have labels inside loops. As far as the command interpreter is concerned, the INTERIOR of a loop is one long line, and you cannot have a label in a line of code. This is one good reason why the undocumented, unsupported practice of using a double colon to start comment lines is frowned upon. It will break a loop. And 'vendor' has only one 'e'. |
|
| 5716. |
Solve : problem cmd Run as Administrator? |
|
Answer» I run cmd as ADMINISTRATOR and then i run my tool , working just fine for 3 weeks but like 3 days ago it doesn't WORK anymore MAYBE one of remote administrators changed soemthing i don't know but when i run my tool i receive: Access is denied. but when i run my tool i receive: Access is denied. The error message indicates that you don't have permission to access the resource you are trying to use. i have administrators and all rights , how can i change that ? any solution for this? must exist a solutionNobody knows what you are really doing and the situation it is being used in.i can give you my messenger or better team VIEWER to take a lookWe do not do TeamViewer here for obvious reasons... You need to contact the System Administrators on your end to get this resolved...nothing we can do for you here.I AM SYSTEM ADMINISTRATOR BOSSSScmd run as administrator , path tool.exe blah blah.... *censored* ENTER --- > ACCES denied Topic Closed. patio. |
|
| 5717. |
Solve : If Statement Strange Results? |
|
Answer» Thank you all in advance for any help you can offer. |
|
| 5718. |
Solve : Unable to Rename Copied Files via Windows Command Line? |
|
Answer» I am trying to create a .BAT script that will read a list of file locations from a CSV (in column 1) and then find that file in a directory and COPY it to a new folder giving it the name specified in column 2 of the CSV file. |
|
| 5719. |
Solve : Shortcut with folder name? |
|
Answer» Perhaps you don't realise that every time you do a cd.. command, the current directory changes? Naming the shortcut is not the problem. It is where it puts the shortcut. I have TRIED using you formula but I just cant seem to get a shortcut in the current directory. Below is my directory structure So why don't you specify where you want the shortcut to be created? e.g. D:\Users\tertom01\Desktop\BatchFiles\mkshortcut /target:"%cd%" /shortcut:"D:\Users\tertom01\Desktop\BatchFiles\6568\dwg cont\working\Ref" This will create a link in the folder "D:\Users\tertom01\Desktop\BatchFiles\6568\dwg cont\working". The link will be called "Ref.lnk" The link will point to whatever folder %cd% is at the time the BATCH script is run. Finally figured it out. See below. Believe it or not I thought about this for hours. But I find my self starting to understand how variables and such thing WORK. thanks again for you time SALMON Trout. @echo off cls set a=%cd% cd ..\ cd ..\ mkdir "Drawings-Uncontrolled\Ref" CD "Drawings-Uncontrolled\Ref" for %%A in (".") do set b=%%~nA D:\Users\tertom01\Desktop\BatchFiles\mkshortcut /target:"%cd%" /shortcut:"%a%\%b%" |
|
| 5720. |
Solve : If Exists, If Not Exists? |
|
Answer» I Have a NEED to write a batch file (executed via SQL job STEP) to VERIFY if a file in a folder is present. If so it would move the file to a archive folder. I'd need to also include If Not Exists, so that if there isn't a file to exit. |
|
| 5721. |
Solve : Bat script to detect if a file .jpg finish downloading? |
|
Answer» I have a software under windows 7 that automatically check EVERY 3 seconds if |
|
| 5722. |
Solve : What is the Sort Order in DOS?? |
|
Answer» I know I can sort a list with the SORT command. By I do not understand the sort order. Some characters that are late in the ASCII table show up early in the sort list Where is the order explained? I am using the SORT command at the command prompt. But in which? MSDOS or Win9x or XP etc?OK. I was using the SORT in Windows XP. What happens is the last things in the ASCII table, the symbols after 'z', end up early in the character set sort. I am in the USA. Here are last items in the 127 ASCII set: Quote xThe four symbols are move up in the sort. Just ahead of the + sign. Quote {Far future reference, Is there some place where on can find the sort used by a system in a specific locale? By default sort.exe sorts according the system locale. You can over ride this by using the /L [locale] switch. Currently the only locale available is the C locale which results in sorting being in binary order. 1. The test file C:\>type test1.txt x y z { | } ~ 2. Sort using default order C:\>type test1.txt | sort { | } ~ x y z 3. Sort using C locale C:\>type test1.txt | sort /L C x y z { | } ~ Operating system locale charts IBM i5/OS Fedora core 6 FreeBSD 5.4 HP-UX 11 SCO OpenServer 6.0.0 SGI IRIX 6.5 SUN OpenSolaris 2008.05 SUN Solaris 10 Sparc SUN Solaris 10 x86 Windows 2000 Windows XP Windows Vista http://collation-charts.org/ Thanks for that link. I will ADD it to my collection. That link explains that some changes were as recent as 2007, 2009 and 2010. The changes affect both Unicode and SQL. Interesting to learn that there have been recently altered rules. |
|
| 5723. |
Solve : rename 2 variables on one line with 2 spinners? |
|
Answer» im trying to make a batch video game for a school project, I was wonder |
|
| 5724. |
Solve : Running a batch file from with a batch file not working right? |
|
Answer» I am trying to create a directory based on three variables. Then I use the "civmd.bat" file to create subdirectories under that in a standardized format. @ECHO OFF Everything works as planned except that the civmd.bat file that is being "called" runs in whatever directory I have this input.bat file. Not in the "D:\%uname%\%uname2% %caseno%" directory.Is the input.bat STORED in a folder on the D drive? The reason I ask is that a CD command will not work if the new directory is on a different drive form the current folder unless you use the /D switch to change the drive, e.g. Code: [Select]cd /d "D:\%uname%\%uname2% %caseno%" Or you can change the drive first: Code: [Select]D: cd /d "D:\%uname%\%uname2% %caseno%"No, it wasn't. It was on my c:\temp. I took it from your question that would matter, so I moved it and it worked. |
|
| 5725. |
Solve : running cmdow problems? |
|
Answer» Im running Cmdow is a Win32 commandline utility for NT4/2000/XP/2003/2008/7 that allows windows to be listed, moved, resized, renamed, hidden/unhidden, disabled/enabled, minimized, maximized, restored, activated/inactivated, closed, killed and more. |
|
| 5726. |
Solve : Is there a DOS command to Disable/Enable a given Network Connection?? |
|
Answer» Is there a DOS command to Disable/Enable a given Network Connection? NETSH Hmmmm forgot about NETSH.... so they could NETSH set to change configuration to make configuration outside of the normal network scope and break the connection to the network that way. I DONT know of NETSH having an enable/disable for the actual NIC... Quote Microsoft Windows [Version 6.1.7601] Quote C:\Users\user1>netsh lan Additionally there are some tricks you could do in DHCP to disallow a connection to the network based on MAC address, and blacklist a system to disallow it to get an IP lease, however if anyone has the ability to create a static IP and gateway with a corporate system that is joined to the domain they could cheat the system getting on static and USING pass thru authentication with any data shares etc.Quote from: John_L. on October 10, 2015, 07:53:53 AM Is there a DOS command to Disable/Enable a given Network Connection? IPCONFIG can release a given connection name.Thanks to all that replied. I was able to find: netsh interface delete interface "Wireless Network Connection" (for example)I think a simple disable would have sufficed. netsh interface set interface "Local Area Connection" DISABLED |
|
| 5727. |
Solve : I need to load my CPU 100% through batch file? |
|
Answer» I need to load my CPU 100% ( or a variable %age) through a batch file. How do I do so? One instance gets the CPU up to around 15%, and takes around 30 seconds, and the CPU maxes out at 8 concurrent copies running. Interesting.... i would have thought that core affinity would have had to be set to force the additional single threads to specific cores so that you dont end up with 2 SHARING a core of 8 and one of them not weighted down heavily with concurrent copies. Learned something new. Thanks for sharing that salmonQuote Learned something new Me too. I really did not expect this. I also thought I would need to force core sharing. I am running Windows 10 64-bit and I don't have any other OS to compare it with. I suppose the OS is somehow making efficient use of the CPU cores? When i TRIED it with 16 instances it looked the same as with 8, and the CPU core temp (average) went up to 75 C. Copies running: 1 Copies running: 2 Copes running: 4 Copies running: 8 |
|
| 5728. |
Solve : Help needed in copying files using batch script? |
|
Answer» Hi Guys.... for /f "[emailprotected]" %%a in (textfile) do move /y %%a d:\What is that supposed to do, exactly? reads the text file using @ as a delimiter in the event there are spaces in the file name and moves the files to the D: Drive if you are running it from the command line and not in a batch file it should be for /f "[emailprotected]" %a in (textfile) do move /y %a d:\OK. But why not use "delims=" which is the standard way of grabbing the whole line? Possible relevance: what delim to use to to read text file line by line Quote Not really, as "tokens=*" and "delims=" produce NEARLY the same result. As with "tokens=*" the delims are still active, they remove leading spaces and TABs from each line – jeb Jul 22 '11 at 11:29Quote from: erobby on November 15, 2015, 10:22:46 AM reads the text file using @ as a delimiter in the event there are spaces in the file name and moves the files to the D: Drive As noted in posts above "delims=" is USEFUL - and if there are spaces, then won't your code break if the loop variable is unquoted?Using ROBOCOPY is probably the best solution, as it's able to create the direcory structure at the DESTINATION if it doesn't already exist. COPY and MOVE (on my system, Win8.1/64) simply error out with "The system cannot find the path specified." if the destination folders do not already exist. Also, the issue of using FOR and "[emailprotected]" has several problems as well, including things like handling spaces (easily fixed, though), and what happens if one of the source files has an @ character in the name? Of course, there's work-arounds/solutions to these problems.. But they should be AWARE in the first place, not just blindly use a FOR construct that seems to work "most of the time.." |
|
| 5729. |
Solve : find file and copy? |
|
Answer» yes but it will do next time.Quote from: Blisk on November 18, 2015, 12:16:38 PM yes but it will do next time.If you used my example it would work for new users as well. Quote from: Squashman on November 18, 2015, 07:27:19 PM If you used my example it would work for new users as well. Thank you I will CHECK your script again. When script must start when PC start or when user log in?Quote from: Blisk on November 19, 2015, 12:32:25 AM Thank you I will check your script again. As I said my previous post. Local computer policy. Which you could also implement at the domain level for the computer object but just as easy to do it once as a local policy on the computer. Or, you put the script in the startup folder. That is how we do it where I work. Quote from: Squashman on November 05, 2015, 08:55:12 AM Well if know how to do it for a domain then I would assume you know what Group Policy editor is.Another alternative: Since this is a configuration file, I'll assume that it's needed by some program INSTALLED on the computer. Rather than launching the program directly, create a batch file which will first check if the configuration file is in the proper place ("%UserProfile%\AppData\Local\Microsoft"), copy it if not, then launch the real program. Or do all three: check all users when the computer is first turned on, check each user when they log on to the computer, and check again when they try to launch the program needing the info. The last two are the easiest to code because you can get the current user with the %UserProfile% environment variable, and only check their configuration file, not everyone elses. Plus, you can use the policy editor to ensure the script is always run on those conditions (I think? I'm not as familiar with the policy editor these days..) |
|
| 5730. |
Solve : Cmd.exe history? |
|
Answer» Came across this while looking for something SIMILAR, and felt horror rise as I read down the replies.. |
|
| 5731. |
Solve : Simple two program start and kill batch file? |
|
Answer» Hi all:) |
|
| 5732. |
Solve : Batch file needed... Totally bamboozled :)? |
|
Answer» Hi i am a new user here and im hoping that someone here can accomplish what ive been trying to do for the last hour!! |
|
| 5733. |
Solve : copy file via batch file? |
|
Answer» how to CREATE a batch file which will copy a particular file in Program file folder during logon via gpo once the USERS is login to particular SERIRES of servers.How are they connecting to servers, just a server share to a mapped folder from a workstation where the data is in a file server or is there a virtual environment they log into such as Citrix to work from where the startup could POINT to the batch to EXECUTE? |
|
| 5734. |
Solve : Move script file to users adobe folder? |
|
Answer» Hi, all. |
|
| 5735. |
Solve : If Copy Batch File Help? |
|
Answer» Hello, I need some assistance in making a batch file. I need the file to check if a file exists in a location, if it does I need it to be renamed, and then copy a target file to that same directory. It has to look at a few directories, but I should be able to write that in after the fact. Hello, I need some assistance in making a batch file. Is it assistance you need, or do you want the script written? Quote I need the file to check if a file exists in a location, if it does I need it to be renamed, and then copy a target file to that same directory. It has to look at a few directories, but I should be able to write that in after the fact. If you want a working script then details about the task are needed. I would suggest you look up the semantics of the CMD.EXE CALL :label [args] command extension. Using this, you could create a "function" which would expect a source and destination path, and if the file already exists at the destination, rename it then copy. Then you can call this function for each source/destination combo you need. I just gave a similar script in this topic: Move script file to users adobe folderIt will always be the same file name in this case. I'm just trying to copy over a report file that serves as a template, but the problem is that the program has been installed at different directories and as far as I know there isn't an environment variable for me to use. I'm a bit lackluster in scripting so I was hoping for some code I can try to make sense of. Casteele's example in the other post is a bit confusing for me. Please let me know if there are any more details I can provide, I'm not intentionally trying to be vague.Quote from: fdskl on December 01, 2015, 06:50:27 AM It will always be the same file name in this case. That makes it easier. Quote I'm just trying to copy over a report file that serves as a template, but the problem is that the program has been installed at different directories And where are these folders, and what are they called? Quote I was hoping for some code I can try to make sense of. It'll be a piece of cake when we have some details that we can make sense of. Quote from: foxidrive on December 03, 2015, 03:03:15 AM
Post #3 has that information.Quote from: fdskl on December 03, 2015, 12:54:21 PM Post #3 has that information. Post #3 has bogus information though. You MAY like to consider the thought that you're asking for exact code to solve a problem, and giving details that are inexact. If you gain experience in solving problems for other people then you will understand how often you have to change the code you have already provided (free of charge), because the details you were given were wrong, or information was withheld. C:\Program Files (x86)\nise\inv.rpt C:\Program Files\nise\inv.rpt C:\nise\inv.rpt copy "%~dp0\inv.rpt" There's the exact paths, hope that adds some clarity. Thank you for your patience. |
|
| 5736. |
Solve : FOR /F to search computer name in a text file and report to another text file.? |
|
Answer» I need to check the computer names in the text file for a string then report back to another text file with the results. I have an error with the FOR /F syntax in the first line, if I REM out the first line the script works?? You invoke the FOR metavariable %%a in the FOR /F line, but then you never use it in the loop. %%a will successively hold each of the lines in C:\Folder\Computerlist.txt but, as I say, you don't use it. Did you expect %computername% to hold something different each time around the loop? (that variable is a special one used by Windows to hold the host name of the local computer). Thank you, I forgot to get it to loop through the text file I guess, I will try to fix that.Geek-9pm I deployed software via GPO and now I need to see how many installs where successful so it will search the text file with the computer names and report back for each computer. I used a DSQuery for computers in certain OU's to DEPLOY the software via GPO.Your information is to little, and whats your purpose of you using the string...? maybe this is what your looking for. it's not tested but it should be error free @echo off color 17 title Made by Zask SET /p "Command1= Creating directory, what would you like to name it? : " set /p "Command2= Name of file 1. : " set /p "Command3= Name of file 2. : " if not exist "C:\%Command1%\" ( mkdir "C:\%Command1%\" if "!errorlevel!" EQU "0" ( echo Folder created successfully ) else ( echo Error while creating folder ) ) else ( echo Folder already exists ) copy /Y "%~f0" "C:\%Command1%" set nl=^& echo. echo %nl% %nl% %nl% echo @echo off >> C:\%Command1%\%Command2%.txt echo echo @echo off ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%date%% ; this is the variable for date ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%time%% ; this is the variable for time ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%computername%% ; this is the variable for the computer name ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo echo %%username%% ; this is the variable for user name ^>^> %Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt echo null >> C:\%Command1%\Dont_remove!.tmp echo Files Created! pause :2 set /p "Command4= Start your folder (y/n). : " if %Command4%==y goto 3 if %Command4%==n goto 4 :3 start C:\%Command1% :4 echo About to create second file! pause cd C:\%Command1%\ ren *.txt *.bat echo %nl% %nl% %nl% call %Command2%.bat echo %nl% %nl% %nl% del /s *%command2%.bat echo Second file created! pause :end Thank you for the help, I am looking through computer names in a text file to check each computer for a certain string that will tell me if the software I sent out via GPO was installed successfully and put the outcome in a file called Report. I found something that worked for me: @ECHO OFF FOR F "usebackq tokens=*" a IN ("c:\Folder\ComputerNames.txt") DO ( "\\Server\Share\filever.exe" "\\a\C$\Program Files\File.dll" | findstr "1.2.3.4" && echo a %date% %time% Software Installed >> "C:\Folder\Report.txt"Quote from: Newbie0000 on December 12, 2015, 04:13:46 AM Thank you for the help, I am looking through computer names in a text file to check each computer for a certain string that will tell me if the software I sent out via GPO was installed successfully and put the outcome in a file called Report. I found something that worked for me: So you no longer need my help? |
|
| 5737. |
Solve : Help with my Batch PLEASE!!? |
|
Answer» Hello, It would seem from this site: http://www.robvanderwoude.com/errorlevel.php, you don't put a % around error level. Try and see what happens if you remove the %. i have tried that. and also tried !errorlevel!... no luck. someone told me that i cannot use the "goto" function in a FOR command.. is this true? You should be able too. I did some Googling and it doesn't seem that it's illegal to do inside a for loop. According to this, if GOTO doesn't work, try this, call: Example here: http://stackoverflow.com/questions/11177419/batch-file-goto-in-for-loop It seems to be the appropriate answer inside a for loop.Quote from: Arotin on December 15, 2015, 11:20:38 AM i have tried that. and also tried !errorlevel!... no luck. someone told me that i cannot use the "goto" function in a FOR command.. is this true? Did you try it in call caps without the percent?Quote from: Arotin on December 15, 2015, 11:20:38 AM someone told me that i cannot use the "goto" function in a FOR command.. is this true?Nearly right... what you can't have in a loop is a label. You need another way to use conditional logic in the loop Here are 2 ways 1. Using errorlevel variable Code: [Select]REM if you use the errorlevel variable REM in a loop you need this and also REM you use !errorlevel! not %errorlevel% setlocal enabledelayedexpansion for /f %%F in (C:\IPLIST.txt) do ( pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2 ) 2. Another way to test for a non-zero errorlevel is with a double pipe || (test for zero error level with &&) Code: [Select]for /f %%F in (C:\IPLIST.txt) do ( pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2 ) In fact you can put the second one all on one line Code: [Select]for /f %%F in (C:\IPLIST.txt) do pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2 Quote from: Salmon Trout on December 15, 2015, 12:04:07 PM Nearly right... what you can't have in a loop is a label. You need another way to use conditional logic in the loop Wonderful! Just out of curiousty, how did you become good with batch files?Quote from: Nexusfactor on December 15, 2015, 12:18:31 PM Just out of curiousty, how did you become good with batch files?Study the documentation, look for batch code sites and forums (ss64 and Stack Overflow are good, so are alt.msdos.batch & alt.msdos.batch.nt - you can get to these via Google Groups), practice writing scripts, don't be afraid to experiment. Quote from: Salmon Trout on December 15, 2015, 12:04:07 PM Nearly right... what you can't have in a loop is a label. You need another way to use conditional logic in the loop I am going to test these out now, thank you for the examples that really helps! i will post the result, thanksthat worked!! if i wanted to add a third authentication it would just be?: for /f %%F in (C:\IPLIST.txt) do ( pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2 if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password4 net user administrator password3 ) and to log the ones that fail i can just do : for /f %%F in (C:\IPLIST.txt) do ( pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2 if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password4 net user administrator password3 if !errorlevel! NEQ 0 echo >>Failed.log ) ? thank youThe reason your original batch file worked the way it did is because REGARDLESS of whether the errorlevel was 0 or not, :two was the next line encountered in the batch. In order for it to work, goto two would have needed to skip over batch lines that you didn't want executed. |
|
| 5738. |
Solve : Batch file for deleting files based on absence files with same name? |
|
Answer» Hi there, example: I can't see how romA.zip and romB.zip are related to each other. Or how 5 directories are involved. Okay let me explain this. example: Map System contains - Map R (contains Roms) - Map A (contains artwork) - Map B (contains artwork) - Map C (contains artwork) - Map D (contains artwork) For every rom file there is artwork with EXACT the same name (diffrent ext) which are placed in the diffrent artwork maps (A, B, C &D). First this, the directory structure is PART of a program called Hyperspin which is a Arcade Frontend for old games so it's not a choice for me. I have to DEAL with it ;-) lets say: PACMAN So normally there is 1 pacman file in all 5 directories with the same name, pacman.rom (MapR), pacman.png (MapA), pacman.png (MapB), pacman.png (MapC) and pacman.mp4 (MapD). The MapR for roms is leading. When pacman.rom is deleted from MapG there are still 4 pacman files left on this disk. I want to scan these other maps for "Orphan" files. When the script is done MapA, MapB, MapC & MapD no longer have pacman files inside them. You can do this by hand off course but we are talking here about almost 20.000 rom files ;-) (5 maps x 20000 rom, so 100000 files in total) So by hand deleting the files will take ages. My solution is to delete ALL rom files from MapG and copy back the rom files i need frommy backup instead of deleting them one by one.Thats why i need such a solution/script.Quote from: rikos on December 07, 2015, 07:28:43 AM Okay let me explain this.You gave the examples above and then referred to Map G which didn't exist. Quote The MapR for roms is leading. When pacman.rom is deleted from MapG there are still 4 pacman files left on this disk. I want to scan these other maps for "Orphan" files. When the script is done MapA, MapB, MapC & MapD no longer have pacman files inside them. It seems as though you want to delete one file, and then remove all other files with the same name.any_extension from every folder - except from Map R. Are you manually deleting this file? On re-reading your initial post - you are dealing with ZIP files. It also seems that the "rom map" you are referring to is a text file with a list of names in it. Hi, sorry for the late responce.. Found a solution with a tool which COMPARES multiple locations and deletes the unneeded files. Thnx for responding! |
|
| 5739. |
Solve : FTP Dated File? |
|
Answer» You are right foxdrive. I can only say I am sorry about that but I did not know all of the requirements at my first post. I found out more and added it to my post later. I also figured out that like Salmon Trout said windows has no built in mechanism for establishing an SFTP connection so a third party application will be needed. WinSCP.com and is located in the WinSCP program folder. The file has an exe structure and is renamed as a .com file, and I suspect it's a stub that calls winscp.exe in the same folder. The sneaky so and so's. Your code should help those that need sftp. It's not something I've had a need for yet... |
|
| 5740. |
Solve : for in working kinda funky (file not found)? |
|
Answer» then again i have little xp in working with command line am i targeting the 'allfiles' incorrectly? Glad to hear your figured it out and also welcome to COMPUTER hope. |
|
| 5741. |
Solve : Netsat Output with timestamp? |
|
Answer» I have a simple batch file netstat -n -p tcp >> C:\temp\Capture_%date:~-4,4%%date:~-10,2%%date:~-7,2%.txt I need to have the time in the text file each time it is appended.Quote from: sd621 on December 13, 2015, 08:46:58 PM What can I add to the above batch file to get the date to show each time the file is appended? I THINK there's a fly in the ointment here. Thanks for the help, works fine. |
|
| 5742. |
Solve : Avoiding Spaghetti Code? |
|
Answer» I've been READING how to avoid spaghetti code in batch files(http://www.robvanderwoude.com/goto.php). Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework.-Google What is Windows PowerShell? -stackoverflow.. Quote The language is sane, especially when compared to CMD. Does that help? Your code can be changed, and made a little more robust - is it less spaghetti-like ? Dunno. Code: [Select]@ECHO OFF CLS :MENU echo Welcome %USERNAME% echo 1 - Start KeePass echo 2 - Backup echo 3 - FireFox echo 4 - Exit echo( SET "keePass=%USERPROFILE%\KeePass\KeePass-2.30\KeePass.exe" SET "kdb=%USERPROFILE%\KeePass\PasswordDatabase\PasswordDatabase.kdbx" SET "backup=%USERPROFILE%\backup.bat" set "m=" SET /P "M=Please Enter Selection, then Press Enter: " IF "%M%"=="1" (echo I'll start KeePass for You & START "" "%keePass%" "%kdb%") IF "%M%"=="2" (call "%backup%") IF "%M%"=="3" (start "" /d "C:\Program Files (x86)\Mozilla Firefox\" firefox.exe) IF "%M%"=="4" (GOTO :EOF) GOTO MENU When it comes to batches. They are usually a down and dirty method of achieving something without writing it up from scratch. Its really intended for scripted routines of file interaction and scheduled tasks etc and system admin etc but never distributed and/or compiled as actual software etc. I have always lived with the fact that batches require goto's to jump around and as long as it does as is intended, so be it. If you were programming in a somewhat modern or evolved to modern language other than batch such as C++, Python, Perl, VB, Java, and on and on. You would be creating loops and calling to objects for functions etc for reuse vs having to rewrite the code for each part of the FLOWCHART that requires the specific object to function at. Lots of these languages do have legacy support for goto operation. I have sometimes with C++ instead of having to make changes adding a loop add a goto statement that restarts the program from the beginning if I get lazy. Once you compile it, and it does as intended, then your good to go. However if you were programming for a client and gave them the source code in the end, you might not get future work with that company if you use goto statements as well as not enough comment lines. |
|
| 5743. |
Solve : Zip using batch file help? |
|
Answer» Hi, should i modify anything in code. I just installed and still its the same issue.Well you just installed a different program. So yes. You need to use the correct executable and the correct options. If you look in your Start > Programs > Winzip, you will see a help file for the Winzip Command line add-on. |
|
| 5744. |
Solve : Disabling Selecting? |
|
Answer» I want to disable selecting in cmd, because every time I want to use batbox for CLICKING, it selects instead. |
|
| 5745. |
Solve : how to automatic. rename many txt files?? |
|
Answer» how to automatic. rename many txt files? the difference between the two lists isNope. It makes these: asdf - 1 asdf - 2 asdf - 3 asdf - 3 (1) asdf - 3 (2) asdf - 3 (3)Batch script: @echo off setlocal enabledelayedexpansion echo Before: echo. dir /b John*.txt echo. echo Renaming... echo. for /f "delims=" %%A in ('dir /b John*.txt') do ( set oldname=%%A set newname=!oldname:John - =John! if not exist "!newname!" ren "!oldname!" "!newname!" ) echo. echo Done echo. echo After: echo. dir /b John*.txt echo. Pause Console output: Before: John - 1.txt John - 10.txt John - 11.txt John - 12.txt John - 13.txt John - 14.txt John - 15.txt John - 16.txt John - 17.txt John - 18.txt John - 19.txt John - 2.txt John - 20.txt John - 3.txt John - 4.txt John - 5.txt John - 6.txt John - 7.txt John - 8.txt John - 9.txt Renaming... Done After: John1.txt John10.txt John11.txt John12.txt John13.txt John14.txt John15.txt John16.txt John17.txt John18.txt John19.txt John2.txt John20.txt John3.txt John4.txt John5.txt John6.txt John7.txt John8.txt John9.txt Press any key to continue . . . Quote from: Luigi master on June 11, 2016, 05:51:16 PM Uh... working perfectly for me too but i just WONDERING u can do this too?look for example this is the list: john - 1 john - 2 john - 3 john - 4 john - 5 john - 6 i want to start and rename with nr. 5 for example look john5 john6 john7 john8 john9 john10 thank youQuote from: Salmon Trout on June 12, 2016, 12:36:09 AM Batch script:can u do this please? john - 1 john - 2 john - 3 john - 4 john - 5 john - 6 i want to start and rename with nr. 5 for example look john5 john6 john7 john8 john9 john10 thank youIn Luigi's code change this set var1=1 to this set var1=6 Quote from: Salmon Trout on June 12, 2016, 12:55:18 AM In Luigi's code I saw ur nr. 1 hehe can u help me pls with a script?all i want is to set a waiting times between start sessions,can u do this please?Quote all i want is to set a waiting times between start sessions,can u do this please? waiting times....... sleep command or scheduled tasks?No further assistance for this User... Topic Closed. Any questions...PM me. patio. |
|
| 5746. |
Solve : Please help me with a batch file? |
|
Answer» Ok so it does what it is supposed to but i am not going to give the full code of everything )>C:\IP_Changer\Profiles\%prof_name_1%.bat You need to explain what you intend to do. That way you get more help quicker. Quote from: Geek-9pm on December 22, 2015, 08:25:25 PM What is this? Sorry i am trying to make it so that you can change your static IP a friend ask me to make this for him but so that he can geate profile (It makes the bat file with all the stuff in it but doesnt change the bat files name) and then just choose the IP he wants here is the full code of everything: (Note: The rem is just for making it easy to write) EDIT: Code: [Select])>C:\IP_Changer\Profiles\%prof_name_1%.bat is just for the location where it saves the bat file and it works but i cant get the bat files name to change Code: [Select]:menu cls @echo off title IP Changer echo -------------------------------------------------------------------------------- echo IP Changer by Inforcer25 echo -------------------------------------------------------------------------------- echo. echo. echo. echo. echo. echo Select a Option echo ================ echo. echo [1] Set Static IP [4] Make Profile echo [2] Reset DHCP [5] Delete Profile echo [3] Use Profile [6] Exit echo. set /p op=Enter Option: if %op%==1 goto set_static_ip if %op%==2 goto set_dhcp if %op%==3 goto use_profile if %op%==4 goto make_profile_1 if %op%==5 goto del_profile if %op%==6 goto exit goto error rem ======================================================================================================================================= :set_static_ip cls @echo off echo "Please enter Static IP Address Information" echo "Static IP Address:" set /p IP_Addr= echo "Default Gateway:" set /p D_Gate= echo "Subnet Mask:" set /p Sub_Mask= echo "Setting Static IP Information" netsh interface ip set address "LAN" static %IP_Addr% %Sub_Mask% %D_Gate% 1 netsh int ip show config pause goto menu rem ======================================================================================================================================= :set_dhcp cls @ECHO OFF ECHO Resetting IP Address and Subnet Mask For DHCP netsh int ip set address name = "LAN" source = dhcp ipconfig /renew ECHO Here are the new settings for %computername%: netsh int ip show config pause goto menu rem ======================================================================================================================================= :use_profile @echo off cd C:\IP_Changer\Profiles cls echo. echo. echo. echo. echo Please enter the profile name. echo. set /p profile=Profile name: call %profile%.bat goto profile_used goto no_profile :no_profile cls echo. echo. echo. echo ERROR! echo That Profile does not exist! echo. echo. ECHO Press any key to go back pause >nul goto use_profile :profile_used cls echo. echo. echo. echo The profile you selected has now been used! ping localhost -n 3 >nul goto menu rem ======================================================================================================================================= :make_profile_1 cls @echo off if not exist "C:\IP_Changer" mkdir C:\IP_Changer\Profiles echo. echo "Profile name: (no space)" set /p %prof_name_1%=Profile name: echo. echo "Please enter Static IP Address Information" echo. echo "Static IP Address:" set /p make_IP_Addr=Static IP Address: echo. echo "Default Gateway:" set /p make_D_Gate=Default Gateway: echo. echo "Subnet Mask:" set /p make_Sub_Mask=Subnet Mask: echo. ( echo echo "Setting Static IP Information" echo netsh interface ip set address "LAN" static %make_IP_Addr% %make_Sub_Mask% %make_D_Gate% 1 echo netsh int ip show config echo pause )>C:\IP_Changer\Profiles\%prof_name_1%.bat goto prof_made :prof_made cls echo. echo. echo. echo. echo The profile has now been made! echo. echo Press any key to exit! pause >nul exit rem ======================================================================================================================================= :del_profile @echo off cd C:\IP_Changer\Profiles cls echo. echo. echo. echo. echo Please enter the profile name. echo. set /p del_profile=Profile name: call %del_profile%.bat goto profile_del goto no_profile_del :no_profile_del cls echo. echo. echo. echo ERROR! echo That Profile does not exist! echo. echo. ECHO Press any key to go back pause >nul goto use_profile :profile_del cls echo. echo. echo. echo The profile has now been deleted! ping localhost -n 3 >nul goto menu rem ======================================================================================================================================= :error cls echo. echo. echo. echo. echo. echo. echo OOPS! Wrong Number echo. echo. pause goto menu rem ======================================================================================================================================= :exit exit rem ======================================================================================================================================= Somme one could tell you, but you ought to learn now to DEBUG. You write little bits of code nips and test them one at a time. Code: [Select]C:\IP_Changer\Profiles\%prof_name_1%.batThat was not written correctly. What part of the code does that? Make it in to a little bit you can invoke. Like just two or three lines. And turn on echo. You need to see what the CMD sees. Then it becomes obvious. Your use of % is not right. There may be other problems in your code, but this line is wrong (you don't use percent signs around the variable name on the left side of a SET statement) so your variable %prof_name_1% will be undefined (blank) which is the PROBLEM you asked about. Code: [Select]set /p %prof_name_1%=Profile name: Examples: set temperature=30 (right) set %temperature%=30 (wrong) Like Geek says, learn to debug. You could have found this yourself. Quote from: Geek-9pm on December 22, 2015, 10:37:52 PM Somme one could tell you, but you ought to learn now to debug. couldn't you just make it automatically add the address so that you don't have to type it? for example for /f "delims=: tokens=2" %%a in ('ipconfig ^| findstr /R /C:"IPv4 Address"') do (set tempip=%%a) set tempip=%tempip: =% set ip_addr = %tempip% |
|
| 5747. |
Solve : how to create a list with horizontly lines? |
|
Answer» this is the txt FILE:-------------------------------- |
|
| 5748. |
Solve : Does . Mean A Wildcard?? |
|
Answer» I was looking for away to use a batch file to properly remove sub folders/FILES but leave the parent directory. I found this code on SO: |
|
| 5749. |
Solve : Batch wifi password recover? |
|
Answer» Quote from: zask on December 12, 2015, 04:28:03 PM Never mind i FIGURED it out. Did it function by only adding the tab to the delims section?Yeah thanks! Cool. Yeah i know right! Quote from: foxidrive on December 13, 2015, 09:05:45 AM Cool. Wanna be my programming budy, im 17 but im really goodEveryone thinks that at 17.... Quote from: zask on December 14, 2015, 07:12:23 PM Wanna be my programming buddy I added a 'd' there coz there was a syntax error. Does a programming buddy get first dibs on copyright, and PATENTS? That might work for me. I'm not sure what you need help with in coding, but the forum is here for help Quote from: foxidrive on December 15, 2015, 06:52:25 AM I added a 'd' there coz there was a syntax error. well i dont care bout copyright as long as i get credit but i like to program virus generators, ikr lol im not gonna get banned or anything for posting my code so if you wanna see what ive been really working on then you could email me. I eventually want to learn enough about viruses to start creating antivirus I've learned a lot so far... Quote from: zask on December 30, 2015, 12:05:09 AM but i like to program virus generators Back a fair way in the past, AV programs were command line tools only - and I wrote a script to scan cdroms for malware (shareware cdroms were popular back to get shareware, before the Internet was in common use). My script unzipped all the programs on the shareware cdrom, in many archive formats, and scanned it all for malware. A report was generated with the results, and was all automated. It was good fun. Back then the only AV tool I know about was McAfee Scan - and BBS (Bulletin Board Systems) with a dialup modem was the way to get any AV updates. Quote from: zask on December 30, 2015, 12:05:09 AM I eventually want to learn enough about viruses to start creating antivirus I learned a lot about them back then - and it began when my machine at work was infected with a boot sector virus called Pong, which was shared around on 5 1/4 inch Floppy disks. Pong was a benign virus, but viruses grew more malicious as time passed. I hope you succeed in your plans to learn and develop AV software - it's a much more complex field these days. Quote from: zask on December 14, 2015, 07:12:23 PM Wanna be my programming budy, im 17 but im really goodRather than having a "programming buddy" and sharing code over email I'd suggest setting up a Github account and putting any code you want to be open source on there, people than then contribute as they see fit and it makes life a lot easier than managing code changes through a forum which really isn't a great way to share code. Sure it takes time to learn how it all works but it s a very important skill to have and gives your code decent exposure. This can be particularly good for applying for programming related jobs as your Github account acts as a portfolio of all the work you've done. For example, my Github account is at https://github.com/camerongray1515 - Most of my larger stuff is private for now as I need to clean things up in order to make them public but you get the idea. Quote from: zask on December 30, 2015, 12:05:09 AM well i dont care bout copyright as long as i get creditI'd look into proper open source licences, they really aren't as scary as they first look - You essentially include a licence file in your project and fill out the copyright years and names.etc - This means that your work is formally licenced and restricted to what people can do with it. You'd probably want to look at the MIT licence which is essentially "do what you want as long as you leave my name in the licence file" and GPL which is similar but states that if you change the source code, you must also share the changes that you made. Quote from: zask on December 30, 2015, 12:05:09 AM i like to program virus generators [SNIP] I eventually want to learn enough about viruses to start creating antivirusNot trying to discourage you but just be very careful with this - It's all too easy to make something to see how it works and accidentally get into a massive legal mess by accidentally running the virus somewhere it shouldn't have been run. I mentor at a programming club for under 19s and quite often there are people making harmless prank type things (randomly playing noises in the background or opening the CD tray type stuff), this is all well and good until they come up with the next idea "how do we make it so it replicates to other devices on the network?" - Now you have a pretty dangerous virus! You don't necessarily need to write a tonne of viruses to be able to make antivirus as viruses are so varied it would be impractical to make enough to cover all the different ways they work, instead you would need to ANALYSE common viruses to see what they do and how you can recognise them. It could be quite fun to see what sort of detection rate you can get but obviously don't expect to be able to rival the large antivirus providers with their teams of security researchers, there's a reason that many SMALLER antivirus programs use virus scanning engines from other companies! There are also lots of other interesting areas to get into other than antivirus. Web applications are a huge, growing area (everything is moving onto the web/cloud nowadays) and they are quite easy to get started on and easy to put launch to the public - This could be an area to apply your skills to.Quote from: camerongray on December 30, 2015, 04:52:34 AM Rather than having a "programming buddy" and sharing code over email I'd suggest setting up a Github account and putting any code you want to be open source on there, people than then contribute as they see fit and it makes life a lot easier than managing code changes through a forum which really isn't a great way to share code. Sure it takes time to learn how it all works but it s a very important skill to have and gives your code decent exposure. This can be particularly good for applying for programming related jobs as your Github account acts as a portfolio of all the work you've done. For example, my Github account is at https://github.com/camerongray1515 - Most of my larger stuff is private for now as I need to clean things up in order to make them public but you get the idea. Thank you for the information about github.com, and don't worry about the whole accidentally getting in a legal mess. I have a professional programming teacher at my school that teaches me about regular programming, and after school he teaches me how to program viruses and disable, for example, if i wanted someone's computer to pop out it's cd try i could make a simple vbscript to do that, but then all i would have to do is end it's TASK in taskmgr. but if i wanted to add it to for example "%ALLUSERSPROFILE%\Start Menu\Programs\Startup" then i would simply remove it from that folder, or if it infects drives, system files, or data i could just run it on a virtual machine lol. my teacher is a old school virus writer, he told me the only way to truly understand how viruses work, (by the means of where they deploy, how they remain anonymous while they transfer throughout flash drives or worse networks) you have to know how they are designed, and now of coarse it is possible to learn how to create antivirus without actually having to create a virus. But if you truly want to create good antivirus software you have to understand multiple types of viruses, stay updated on vulnerabilities, zero days, and such. which can be a pain to some but i actually enjoy the art of creating viruses (As long as it done legally in a safe and secured environment). I treat it as if it is my hobbie, i believe all forms of code are beautiful in there own unique way. and my craving for knowledge in all subjects of programming holds a strong importance in my life. Oh boy... Next he will tell us how his teacher also did time in jail for fraud Quote from: Geek-9pm on December 31, 2015, 04:18:17 PM Next he will tell us how his teacher also did time in jail for fraud good one |
|
| 5750. |
Solve : Help me regarding creating a batch file? |
|
Answer» 1. create a batch file that accepts a # input 2. identify if input is odd or even 3. if input is odd, write the directory structure of the c: drive on desktop C: > Users\ITE1-31\Desktop\CITCS\dir.txt Code: [Select]@echo off SET /p num="Enter Number: " set /a numberinput = num %% 2 if %numberinput% EQU 1 I did the first part but number is 3 confusing I don't what should I type for the Directory and number 4 for Re-directory. @echo off set /p num="Enter Number: " set /a numberinput = num %% 2 if %numberinput% equ 1 ( HERE IS COMMAND TO LIST ALL FILES ON C TO FILE AS SPECIFIED ) else ( HERE IS COMMAND TO REMOVE FINAL FOLDER ) @echo off set /p num="Enter Number: " set /a numberinput = num %% 2 if %numberinput% equ 1 dir C:\ /a /b /-p /o:gen >C:\Users\ITE1-31\Desktop\CITCS\dir.txt C:\Users\ITE1-31\Desktop\bsit\dir.txt @RD /S /Q "Z:\Final" pause I tried this but it's not workingYou did not read my reply properly. Quote from: SALMON Trout on May 30, 2016, 05:01:03 AM You did not read my reply properly. He may have lost his specs - and so can't find his way back here to thank you properly either. Quote from: Salmon Trout on May 30, 2016, 05:01:03 AM You did not read my reply properly. Thanks for the answer, I already got it. |
|