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.
| 7901. |
Solve : find replace help needed? |
|
Answer» I want to replace
with Here is what i tried for /f "tokens=* delims= " %%a in (%scriptsdir%/Mobilebranchota.html) do ( set str=%%a IF !str!==^
set str=!str:^
%BUILD_NUMBER%^^^ !echo !str! >> %scriptsdir%/branchota1.html "listview" data-divider-theme="d" data-inset="false">= Can some one help meNo need for the multiple posts... It's also not a good idea to use an e-mail ADDY for a User name... Unless you want your Inbox barraged with SPAM...Try something like this (UNTESTED): Code: [Select]@echo off setlocal enabledelayedexpansion for /f "delims=" %%a in (' TYPE "%scriptsdir%/Mobilebranchota.html" ') do ( set str=%%a IF "!str:~0,14!"=="<ul data-role=" ( >>"%scriptsdir%/branchota1.html" echo ^<ul data-role="listview" data-divider-theme="d" data-inset="false"^> >>"%scriptsdir%/branchota1.html" echo ^<li^>^<a href="https:google.html" data-transition="slide"^> >>"%scriptsdir%/branchota1.html" echo ^<img src="%imgpath%orange.png" class="ui-li-thumb" /^> >>"%scriptsdir%/branchota1.html" echo ^<h3 class="ui-li-heading"^>%BUILD_NUMBER%^</h3^> >>"%scriptsdir%/branchota1.html" echo ^<p class="ui-li-desc"^>%BUILD_NUMBER%^</p^>^</a^>^</li^> ) else ( >>"%scriptsdir%/branchota1.html" echo(%%a ) )If you continue to re-post the same request over and over they will be removed. Last warning. This is not live chat. patio. |
|
| 7902. |
Solve : i need a basic bat file...? |
|
Answer» ok i need a basic bat file i need it to be able to send an emulated press of a key (up arrow) to the active window every 10-20 secs (random) |
|
| 7903. |
Solve : find and replace? |
|
Answer» I WANT to REPLACE <--test--> in hml to and add two more lines below using batch file.You didn't REPLY in your other THREAD - either here or another site I saw it on.sorry if i missed it, sorry if i missed it, Can i have a solution here please. You are one lazy son of a batcher. Return to the other forum where you asked the same question and pick up your reply. In addition, you may want to CONSIDER changing your log in name. Later. |
|
| 7904. |
Solve : "Start" command? |
|
Answer» Hello everyone! ~How do I start a whole folder worth of a specific files(in my case, music )? Create a playlist with a DIR /B command Quote from: ~Is it possible to make the program select and play 1 random music (out of all music files in the active folder)? It's possible to select a random file from a folder. Quote from: ~Is it possible to make the program locate and play music from all the folders that are within the active folder? This is a GOOD program for that: http://www.freewarefiles.com/A-Random-Music-Player_program_56805.html |
|
| 7905. |
Solve : Find & Replace " |
|
Answer» Hi can some one HELP me find & Replace say example "<--test-->" with " " in large text file using batch file in a sample.html |
|
| 7906. |
Solve : batch predict next word? |
|
Answer» hi... |
|
| 7907. |
Solve : Need help modifying DOS script for continuous ping? |
|
Answer» Hello, I had a follow up to this question..... Since DOS does not support logging the output to a file, You are mistaken. Quote from: is there anyway to log this output and save to a file? Code: [Select]"batchfile.bat" >file.log and Code: [Select]>>file.log ping localhost Foxidrive, once again, awesome! ThxJust building off what Foxidrive said, ">" Overrides the file ">>" edits the file (adding output to the end) |
|
| 7908. |
Solve : Batch to remove blank lines from a TXT file.? |
|
Answer» It would take me the rest of the night. I need to be awake in the morning. I get report files that have too many blank lines (white space). The lines are not always NULL length, that might have tabs or spaces, but no visible chars. |
|
| 7909. |
Solve : Total beginner question! How do you create a batch file to count to 100?? |
|
Answer» When I say total beginner.. i really mean it! Have been GIVEN a task to learn dos in half a day! Struggling big time! One of the missions is to create a batch file that counts to 100. I'm failing miserably at this!! HELP Type in FOR /? that will get you startedermm.. not really. much more of a totally beginner than I imagined.. Although I have only been doing this since 9 today! You can put this in a .bat file. It pauses at the end for the sake of being able to see it has done what you want... It's really fast though so im not sure if this helps you 'complete the mission'? @ECHO OFF FOR /L %%i IN (1,1,100) DO ( ECHO %%i ) PAUSE set count=0 :loop set /a count=%count%+1 if not #%count%#==#100# goto loop goto endQuote from: sfin on September 27, 2013, 03:32:01 AM learn dos in half a day! This is not possible. Who gave you this "task"? Quote from: SALMON Trout on September 27, 2013, 10:27:50 AM This is not possible. Who gave you this "task"? Quote from: patio on September 27, 2013, 10:29:28 AM Ahh, it's *your* fault! So in detail, there are three ways to do what you want to do. The first is the most useful in scripts, which is a GOTO based loop, which would go something like this: Code: [Select]set counter=0 :loop set /a counter=counter+1 echo %counter% if not %counter% == 100 goto :loop The first line, gives us a base value to work with, and also truncates (empties) any previous value the variable may have had. The second line, :loop, is a marker, (A batch label) to return to later The third line is the key line of the program, it increases the variable 'counter' by one, it works using the arithmetic argument '/a', which tells set to deal with the phrase after the equals like a calculator would. The fourth is what proves that the script is counting, it prints the current number to the screen, no fuss about it. The fifth is what makes the program stop when we want it to, as well as making it continue until we want it to, it literally translates to "start again from the line with 'loop' written on it, unless you are already up to 100" The second way of doing a recursive loop like this, is the SIMPLEST way of achieving what you want, and will do it all in one line. for /L %%n in (1,1,100) do (echo %%n) This uses a for loop, which is broken up into three parts, FOR, IN, and DO FOR tells us what argument (letter variable) to deal with, in this case 'n', prefixed with a double % IN tells us how and where to find our argument, we have put a '/L' after the FOR part, so we are dealing with numbers (as opposed to files,) in the brackets we have 1,1,100; start, step, and end, so we start at 1, step forward 1 at a time, and end at 100. after each step it passes the number through %%n into DO is a function to deal with, it is just ECHO %%n, so it prints the number it is up to to the screen, The final method is almost identical to the first, except we use CALL instead of GOTO Code: [Select]set counter=0 :loop set /a counter=counter+1 echo %counter% if not %counter% == 100 call :loop This is different in the way that it deals with the looping process. I can explain FOR and CALL in more detail if you want, but if you don't understand want I just wrote, then read it again more thoroughly, or go for a slower step by step tutorial somewhere. I hope this helpedI noticed no one posted this, but you can use Code: [Select]set /a LoopToOneHundred.Counter+=1 to count %LoopToOneHundred.Counter% up by 1, instead of writing out Code: [Select]set /a LoopToOneHundred.Counter=LoopToOneHundred.Counter+1 (which can get long when your variable gets over 10 letters).Quote from: Lemonilla on September 29, 2013, 10:49:11 AM you can use Yeah Thanks Lemonilla, I forgot to add that in the notes, but I was THINKING about it, Also you could say Code: [Select]if /I %counter% LSS 100 goto :loop which gives the script a bit more integrityQuote from: spivee on September 29, 2013, 06:35:25 PM Yeah Thanks Lemonilla, I forgot to add that in the notes, but I was thinking about it, What does the /I switch do here? (I know what it means, I just wondered why you use it in that line) Quote What does the /I switch do here? I wasn't aware that it wasn't necessary to include the /I switch, until after I posted that. I learned almost all of what I know from the help utility, and it is modeled around using == and switching to explicits with /I if necessary, which I assume is because the /I switch once upon a time wasn't optional.Quote from: spivee on September 30, 2013, 02:31:19 PM switching to explicits with /I I am not sure what you mean by "switching to explicits". All the /I switch does is make string comparisons case-insensitive e.g. if /I "ABC"=="abc". Since numbers don't have case, it is unnecessary with if %counter% LSS 100. Quote from: Salmon Trout on September 30, 2013, 03:46:49 PM I am not sure what you mean by "switching to explicits". All the /I switch does is make string comparisons case-insensitive Oh, you are right, I misread the help util two years ago then... thanks for clearing that up then |
|
| 7910. |
Solve : save file.txt in folder with spesific name? |
|
Answer» i NEED a help... |
|
| 7911. |
Solve : Is this possible with a batch file? |
|
Answer» I just want to know if this is possible with a bath file. I recognise that code. |
|
| 7912. |
Solve : Create folder from partial filename and move files into that folder? |
|
Answer» Try this batch... |
|
| 7913. |
Solve : need advanced batch file assistance please? |
|
Answer» Quote from: strokeman on March 04, 2013, 09:04:15 PM is fine but not processing %1, whats wrong? That's the only thing I can see, but there may be more that i'm missing. Hard to test without the files. If it still doesn't work, try dropping pause's between the chunks of code to find which one is causing the error.Quote from: strokeman on March 05, 2013, 07:29:39 PM when theres not a %1 given, ie its blank z or x,y,z whatever you give it, z==z, so a TRUE condition is met. It will fail with quoted terms. That technique from MSDOS days should be replaced with this in windows: Code: [Select]if "%~1"==""Thanks for the correction foxidrive, I knew it looked funny, but couldn't figure out why. out of curiosity, why would it fail with quotes? Does it have something to do with not replacing %1? It seemed to work when I used %a% in cmd.In this instance the %1 will contain quotes when long filename elements are used in %1. if "%1z"=="z" So that line will expand to this which is a mess and the long filename elements like spaces and & will cause an error MESSAGE: if ""my file.txt"z"=="z" @cls ::@ECHO Off COLOR 1F ECHO +--------------------------------+ ECHO :XBMC NFO TO DIR Creator V2.00. : ECHO :(c)2012,2013, by the 'Strokeman': ECHO +--------------------------------+ ECHO. IF not EXIST NFO2DIR.TXT ( ECHO Ensure your've read nfo2dir.txt before you run, Press ^^C if you want to abort. . echo Because WARNING: This will irreversibly, alter disk structure!!! ping localhost -n 5 >nul ) else ( START /max notepad NFO2DIR.TXT ) goto miss if not exist *.nfo ( echo. ECHO It appears you haven't run vid. export yet! ping localhost -n 5 >nul exit /B ) :miss if "%~1"=="" ( echo. echo Stacked video files MAY be present, no echo commandlines given, continuing anyway. . ping localhost -n 5 >nul ) echo. echo Please wait. . DON'T INTERRUPT!! ping localhost -n 5 >nul for %%a in (*.NFO) do md "%%~na" & move /y "%%~na.*" "%%~na" >nul if exist (*-fanart.*) ( for %%a in (*.) do ( move /y "%%~na-fanart.*" "%%~na" >nul ) ) if exist (*-poster.*) ( for %%a in (*.) do ( move /y "%%~na-poster.*" "%%~na" > nul ) ) if exist (*-landscape.*) ( for %%a in (*.) do ( move /y "%%~na-landscape.*" "%%~na" >nul ) ) if exist (*-thumb.*) ( for %%a in (*.) do ( move /y "%%~na-thumb.*" "%%~na" >nul ) ) if EXIST extrathumbs ( rd /s /q extrathumbs ) if EXIST extrafanart ( rd /s /q extrafanart echo. echo extrafanart and extrathumbs dir. deleted ) ELSE ( echo. echo extrafanart or extrathumbs dir. not found. . . ) set a=%1 setlocal EnableDelayedExpansion set b=1 :loop.countChar.2 call set c=%%a:~!b!,1%% if "%c%"=="" goto end set /a b+=1 goto loop.countChar.2 :end echo. echo The following is a listing of files not yet processed echo it dosent show your newly created dir. structure!. . . echo. dir /a-d-h ping localhost -n 3 >nul goto :eof set end=-%b% for %%a in (*%1.*) do call :next "%%a" goto end if not "%~1"=="" ( :next set "var=%~n1" call set "var=%%var:~0,%end%%%" md "%var%" 2>nul echo moving %1 to "%var%" move "%~1" "%var%" >nul ) :skip echo. echo Operation Completed Successfully, you will now have to update Library, After echo that, please run artwork downloader, then enable extrafanart in chosen skin. ping localhost -n 5 >nul i dont get it, have looked at it a million times. if i PUT in a %1 its fine, but with no commandline it gets stuck in the red section, incrementing to affinity, till i ^c it?Looking only at the red bit: Code: [Select]goto end :next set "var=%~n1" call set "var=%%var:~0,%end%%%" md "%var%" 2>nul echo moving %1 to "%var%" move "%~1" "%var%" >nul goto :EOFbugger, hl the wrong section, sorry! set a=%1 setlocal EnableDelayedExpansion set b=1 :loop.countChar.2 call set c=%%a:~!b!,1%% if "%c%"=="" goto end set /a b+=1 goto loop.countChar.2 goto :EOF The characters % and ^ in filenames might cause problems. Code: [Select]@echo off set "a=%~1" set b=0 :loop.countChar.2 call set "c=%%a:~%b%,1%%" if "%c%"=="" goto :end set /a b+=1 goto loop.countChar.2 :end echo %b% pause i just wrapped it in if not exist "%~1" (...code....). so it skips that section if no %1 specified, but thats just avoiding the prob, so will try your way. thanks so far, you guys rock! theres some issues still, but have other 'work', so will have 2 shelve it for now . but ill be back. |
|
| 7914. |
Solve : file properties? |
|
Answer» Quote from: novice84 on October 02, 2013, 07:01:23 AM e.g. size, type, Author, Date modified, Path, etc. & Project. above listed these 6 properties will do the job. I don't mind even if all properties are exported together.Is there a specific file type - doc, xls, ppt, or what? Quote from: novice84 on October 02, 2013, 07:01:23 AM
This is off topic, but you just need to GET a solution to your problem, whether it uses VBS or JS in WINDOWS Scripting Host (that is cscript.exe [cmd line] and wscript.exe [gui based]) or batch or some helper batch files, or third party utilities, and then understand the immediate details of how to use it. In the future you will pick up more knowledge and can revisit your older scripts and figure out how they work. The people here will also help you understand specific details of some code, when you ask. But to help us develop an appropriate solution, we must have exact details of the task - and the person(s) helping you can then figure out the best or easiest code to solve the job. Knowing the details also enhances our enjoyment of writing some code to help you - otherwise we become bored scripting machines, and not human beings who give up their time to help other people. Quote from: Salmon Trout on October 02, 2013, 11:59:22 PM Is there a specific file type - doc, xls, ppt, or what? no there is no specific type. as I mentioned before as with DIR command we can list of files that exist in a folder, I was hoping to get more details of every file as we can see in file explorer. I thought it will be simple and straight forward, but seems to be complicated. if it's required to mention a file type, .doc files we can start with and I hope in code we can easily change file extension to match the need. Quote from: foxidrive on October 03, 2013, 01:17:21 AM
I appreciate every ones time & effort but trust me I have tried my best to explain. well you have asked I will try again if we use command DIR /A-D > tree.txt we will get Date Modified, Time & Size along with file name. so here we already getting 3 file properties. I thought may be it's EASY the same WAY we can get more details.Again you failed to tell us the type of files you are processing, and haven't listed the properties in the order and format you want, and which properties you want. It's kind of like taking your car to the mechanic and saying - there's something WRONG with my car, please fix it. And not telling him what is wrong. |
|
| 7915. |
Solve : Robocopy-Dealing with blank in directory name? |
|
Answer» Hi, Robocopy %InPath%\ %OutPath% /COPY:DATS /Log:EmailBkupLog.txt Try dropping that backslash '\' and using: Robocopy %InPath% %OutPath% /COPY:DATS /Log:EmailBkupLog.txt Best wishes!Thanks for the reply OcalaBob, That fixed it. I ALSO had to put both paths in quotes because of the UNC ADDRESSING for the external drive. I fought that battle once before. Regards FrankGC |
|
| 7916. |
Solve : Is it possible to sense when a program is opened using vbs?? |
|
Answer» I know you can do it (if not very well) in batch using 'tasklist' and 'fc'. But is it possible to do with vbs?' This computer |
|
| 7917. |
Solve : Move batch files ...? |
|
Answer» Hi, This seems to work.You are MISSING the LEADING 20 for the output year. This can be done with a single FOR loop. Just use tokens=1,2* delims=_ strip the first 4 characters off of %B and add in the leading 20.This should work. @Lemonilla: your find.exe syntax is fubar. Code: [Select]@ECHO off setlocal enabledelayedexpansion for %%a in (*.dat) do ( for /f "tokens=2 delims=_" %%b in ("%%a") do ( set "INFO=%%b" set "year=20!info:~0,2!" set "month=!info:~2,2!" md "!year!!month!" 2>nul echo "%%a" move "%%a" "!year!!month!" ) ) pauseThank you all. Thank you foxidrive . it works. |
|
| 7918. |
Solve : Batch File Problems? |
|
Answer» I want to have the date in a file name, problem is that the date is done like this: mm/dd/yyyy. A file name can't have a "/' in it. Any ideas on hwo to overcome that?This is OS dependent. There are two files, each with a number in them This works if and only if the first file contains a single record with the major version AND the second file contains a single record with the minor version. If not then you add complexity requiring IF statements to identify the record and to parse out the value you need. DOS batch is not designed for low level record processing. Good luck. |
|
| 7919. |
Solve : RENAME? |
|
Answer» Hi all, Is there a way to do this without variables? It's just that the simpler I can make the code, the easier it will be for the end users of this process to follow what's going on. What do you mean without variables? Which variable(s) were you thinking of?Quote from: foxidrive on October 02, 2013, 06:14:15 AM What do you mean without variables? Gotta be a classic. |
|
| 7920. |
Solve : Vid Problems with DOS? |
|
Answer» Does anyone know how to get drivers for a Voodoo 4 / 4500 for DOS, or how to get the card to run DOS games? It displays everything else fine, but when I start a game, all I get is a black screen. |
|
| 7921. |
Solve : Batch file, if else, and reboots? |
|
Answer» Good afternoon everyone, |
|
| 7922. |
Solve : Getting Filename & Date? |
|
Answer» I WANT a file created using DOS like this |
|
| 7923. |
Solve : Closing a dos wndow? |
|
Answer» [size=16]how to close a dos window running through a batch file automatically? |
|
| 7924. |
Solve : CACLS leading to deletion of files in root directory on USB Flashdrive? |
|
Answer» Hi all,
The first command should PROBABLY be: del /A:-H-S \USB\*.*? Then the pushd has %1 as a parameter but we don't know what it is. This should delete the files and folders in \USB but retain the folder. Code: [Select]pushd "\USB" || goto :EOF rd /s /q "\USB" 2>nul popd will give it a try, 1) the del /A:-H-S \USB\*.*? Whats the '?' for pls? is it to determine deletion be done if \usb is not empty ( also would that matter if a folder is empty and I run the above command) 2) could you pls explain how the latter half works? pushd "\USB" || goto :EOF ......... ( what is || for ) rd /s /q "\USB" 2>nul ............( what is 2> exactly) popd many thanks indeed! Regds Tom See the in-line comments in blue. Quote from: tomcatonnet99 on March 24, 2013, 12:37:34 AM Many thanks foxidrive, truly appreciate that explanation.. I think the problem is CACLS ... the first instance it unlocks the folder 'USB' ... runs through the entire routine without a glitch even with the earlier code for del and rd, run it a second time and it locks the folder and now I've tried everything and it wont unlock! cacls USB /e /c /grant Everyone:f cacls USB /p Everyone:f cacls USB /e /c /g %Username%:f Any suggestions? Why would it do that ( have tried it on 2 different laptops in WinXP and Win7 and both react similarly, just not the laptop on which it was initially created which is also a winXP) on the parent laptop it is able to unlock successfully regardless of the number consecutive locks/unlocks! also does CACLS work exactly the same in Win7 / Win8 as I will need to use this flash drive and the above batch file in different environments It may be because you grant permission to username, but then remove permissions to username and that may include all the default permissions. What you could do is Edit and grant 'everyone' permission, and do your tasks, and then remove the 'everyone' permission. You should find that even if it is 'locked' then by starting from an elevated admin prompt you will be able to access the folder again and change permissions.Quote from: tomcatonnet99 on March 25, 2013, 05:40:25 AM also does CACLS work exactly the same in Win7 / Win8 as I will need to use this flash drive and the above batch file in different environments The security you are using seems to be a bit haphazard as any admin will be able to take ownership, and change the permissions. In Windows 7 and 8 there is an additional tool called ICACLS I think, and while CACLS works the same way (I think, I haven't checked deeply) I have found that there are some system folders that it cannot change the permissions of (at least to edit and grant permissions to 'everyone').may be so as regds its inability to change permissions to some system folders but this is on a USB flash drive... MY set up is as follows: I have a PROGRAM 'USB Safeguard' which resides in \USB folder, its executable file is hidden with attrib +h +s. It creates its own .lnk invisible(-s-h attrib) encrypted file(needs password to unlock) .... 1)so far I've never seen it being deleted whilst using the TYPE nul>\USB\*.* on using Del A:\-s-h %cd%USB\*.* DESPITE the -s -h its still deleting that file ! what am I doing wrong pls? 2) and I don't see why cacls would work on one laptop and not another regds further rd /s /q removes the \USB directory as well which isn't what I want for to happen ... only the contents (files and folders except +h +s attrib ones ) to be deleted / removed If you use the code as provided then it won't remove the \USB folder too because it is in use, as the pushd command opens the folder and locks it from being deleted by the RD command. Quote pushd "\USB" || goto :EOFQuote from: tomcatonnet99 on March 25, 2013, 06:14:00 AM only the contents (files and folders except +h +s attrib ones ) to be deleted / removed Sorry, that's different to what I had understood you wanted to do. The RD command will remove all folders and files from within \USB Another post: This will not delete hidden files from \usb and will remove the folders and files. Code: [Select]@echo off del \usb\*.??? for /f "delims=" %%G in ('dir \usb /b /ad') do rd /s /q "\usb\%%G" pause I admit I didn't read all the posts, however I noticed the use of cacls and USB flash drives, so I think it's worth mentioning that flash drives, under normal circumstances, will use FAT32, which does not support Access Control Lists; cacls is a ACL editor, so there might be some assumptions or extra information from the ACL security info that you are trying to use that just isn't available.Quote from: foxidrive on March 25, 2013, 07:12:08 AM Another post: thanks, is this the same as using push \usb and then rd/ s /q it?? ( coz thats definitely a lot simpler, as I would need to understand what exactly the above means / how it works) especially delims .... what is /f and whats the difference between "delims=" and "delims=*" Quote from: BC_Programmer on March 25, 2013, 01:00:01 PM I admit I didn't read all the posts, however I noticed the use of cacls and USB flash drives, so I think it's worth mentioning that flash drives, under normal circumstances, will use FAT32, which does not support Access Control Lists; cacls is a ACL editor, so there might be some assumptions or extra information from the ACL security info that you are trying to use that just isn't available. Yes I'm using the NTFS format as I use the 'safeguard.exe' in the \USB folder which requires NTFS. the problem is CACLS! it works perfectly well to lock&unlock the \USB from any unintentional deletion; but in Win7 / Win8 ICACLS would be required and as such I would like to have a CACLS /ICACLS available for any system operability... (ICACLS is just way to complicated, its like MS have just nuked us! to stone age and driven users to an other planet and now we're like aliens! there ) Any ideas/ suggestions to lock / unlock \USB folder? |
|
| 7925. |
Solve : starting logon.bat maximized? |
|
Answer» Ok I need help. Although im not a DOS fan. I did create a NICE logon.bat that NEEDS some user input. But since I work with a lot of very ignorant users that dont feel the slightest need to investigate that pretty scarey button in their taskbarr, I need that logonscript to start MAXIMIZED. It should really prevent everything else from loading untill they entered their input but that might be a little too much to ask :-). I tried everything I COULD think off (and Im pretty creative) with the start /max command but I cant get it to work. Please help before I strangle a few PEOPLE!Post bat file used:Im sorry, did you mean to ask me if I would post the batchfile I use?I'm guessing Merlin did in fact suggest you post your batch file. |
|
| 7926. |
Solve : trying to start up :-/? |
|
Answer» Hi, |
|
| 7927. |
Solve : Create a batch file, need help please? |
|
Answer» Hello, need some help please. I need to creat( if possible) one batch that permit to make a search and EXECUTE the file that i searched for. Example I have several bios updates from several models, for example: I have PSTA2, PTA2E, PDVX3(inside of each folder there is the bios .exe. So the idea is to creat a batch file and we execute it ask to input the model to search. we put PSTA2 for example ask for confirmation and execute the update bios. |
|
| 7928. |
Solve : Notify page when a batch file crashes.? |
|
Answer» Hello all, $EmailFrom = “[emailprotected]” I used a different tool to e-mail myself via command line, but this should be all you need editing for PATHS and piecing this together to make it happen. Thank you very very much for your reply and for the time you spent to write the code. I will try it and i will inform you about the results. |
|
| 7929. |
Solve : Output Screen Contents? |
|
Answer» I'm having a problem outputing the screen results of a batch file (I.E. results of a timed run of an NBTSTAT or other SYSTEM query ) as a text file to be SENT to a directory such as c:\10\Status. Any suggestions appreciated..I would think you need to redirect the output: |
|
| 7930. |
Solve : HELPPP!!!!!!!? |
Answer» HI im in deep deep poo i think. I was tryin to reinstall windows xp, but kept being told the computer couldnt fine any hard drives connected to the computer. I have a SATA hdd so i was tryin to run some drivers from a floppy. I booted the pc and a message came sayin hystem.sys not found. so i took the floppy out and booted as normal. i arrived back at my desktop, insterted the floppy and looked at the CONTENTS. On the floppy were 2 dos files that werent on before so i deleted them and rebooted the pc. Now at BOOT up it says dos could not be found and the computer want go past that stage. HELP ME PLEASE!!!!!!Quotehi im in deep deep poo i think. I was tryin to reinstall windows xp, but kept being told the computer couldnt fine any hard drives connected to the computer. I have a SATA hdd so i was tryin to run some drivers from a floppy. I booted the pc and a message came sayin hystem.sys not found. so i took the floppy out and booted as normal. i arrived back at my desktop, insterted the floppy and looked at the contents. On the floppy were 2 dos files that werent on before so i deleted them and rebooted the pc. Now at boot up it says dos could not be found and the computer want go past that stage. HELP ME PLEASE!!!!!! Well ...for openers get a pair of CHEST waders ......lol Your post is a wee bit confusing .......If you had formatted the drive ........how did you manage to end up on your desktop ? and .......the 2 dos files you mentioned .........they had to come from SOMEWHERE . How about having another go at explaining exactly what you did in detail ......... dl65 |
|
| 7931. |
Solve : Batch Antivirus---is this possible?? |
|
Answer» I had done a little bit of batch programming, and I suddenly thought if it was possible to make an antivirus using batch programming. Is this possible for batch? The best you could hope for is to have a virus definition database and then compare the files to look for the definitions You'd need to open the files in binary mode, and you'd need something non-batch for that, and you might as well speed up the database operations with something designed for the job, and you need to download new definitions every so often (another compiled program), so you'd end up with a bunch of compiled programs being co-ordinated by a batch script, at which point it would become much more sensible to ditch the batch script. Oh I see. Thank you for the help. I just enrolled in a C++ online school last week. I might do the AV stuff using C++ in the future...now I'm just learning the basics of C++.Not to scare you away from making an antivirus as a C++ project since maybe you could, but I have been working with C++ for the last 15 years as one of my choice computer languages to program in and I took in college ... Intro to C++, Intermediate C++, and Advanced C++. As a beginner with C++ if you have never worked with programming in any other languages, I would suggest not just doing the course work assigned, but constantly explore and try to stay 1 chapter ahead of wherever the class is at and make small programs even if they are as simple as a conversion program, or text based game of some kind to exercise your mind and strengthen your skills. In C++ as a beginner depending on what development tool you are using, your most likely going to start simple with console programming which is basically programs that when executed they run in a command shell window unless the course is jumping directly into programming for Windows using Visual Studio Express 2010 or 2012 etc. A good suggestion for a project for C++ and not be in way over your head will be to make a video game, unless your skills with C++ are so well that you want something more challenging and want to take the risk of not having the project completed in time for the deadline at the end of the semester. My final project for Intro to C++ was a game called SIC BO which is a gambling game. http://en.wikipedia.org/wiki/Sic_bo I decided to program this game for C++ because it was one of my favorite games at Casino's that host it. And it was more advanced than Blackjack or Poker with all the logic involved to make it work, and at the time there was no video game version of it for free on the internet. For graphics it was all text based and the biggest challenge was squeezing all the information in the limited lines and width of a command shell in ASCII text into the viewable user console shell window, since the Intro C++ course pretty much covered the basics and the most advanced the course had gotten was passing values to arrays and Local and Global Variables as well as the many ways to structure the program within the different loop types since GOTO's will get you scolded as bad programming and myself coming from Basic to C++, I had to break the GOTO habit and force myself to place everything within loops. Areas that were not taught as a part of Intro to C++ but I had to implement in my game were String Compare http://www.cplusplus.com/reference/string/string/compare/ and adding sound with beep function http://stackoverflow.com/questions/4060601/make-sounds-beep-with-c as well as reading and writing the game data to text file so that the game state could be saved and loaded back up vs always having to start the game fresh with these open/close read/write functions as example here: http://www.cplusplus.com/doc/tutorial/files/ Lastly, I would like to state that the hardest part of making an antivirus program is because you need a vast database of information to go by to detect if something is good from bad, and so while even if you did write an antivirus in C++, you still need a larger piece of the puzzle to make it work and the definitions are not open source to implement into your antivirus. The fact of the matter is that probably the closest you can get to making an antivirus at the Intro to C++ level would be to make a C++ program that knows how a text file should be structured, and can detect differences between how it is and how it should be through comparison between two arrays with an incremental counter++ to compare for all text characters including spaces between what it should be and what it is, which would be more like a File Integrity Checksum Verification vs an antivirus, but only comparing ascii characters instead of going as advanced as to implement MD5 or SHA-1 hash values. Quote The File Checksum Integrity Verifier (FCIV) utility can generate MD5 or SHA-1 hash values for files to compare the values against a known good value. FCIV can compare hash values to make sure that the files have not been changed. * I would suggest sticking to easier PROJECTS for the course and work on something like this on the side if your determined to make an antivirus. Once a long time ago I tried to make my own AI using GW-Basic. I thought at 11 years old that it should be not too hard to program the computer to respond just as I would respond to questions. A couple weeks into the project and many many hours into it I soon realized that I could not account for every combination possible for every question that could have been asked and to populate my programming with every response that I would respond with. I also learned later on when getting into algorithms realized just how complicated AI is! http://en.wikipedia.org/wiki/Artificial_intelligence ... but for me I thought at 11 years old that I could make it happen with many many logic conditions IF this THEN that ELSE something else etc, and I soon realized it was beyond what I could program up myself as well as beyond what my computer could store since the amount of STORAGE needed was infinite to account for every question that could ever be asked and answred and even if I programmed it every second of my life, it still wouldnt be complete to be an exact copy of my mind in an AI form. *AND, the other problem was that the more I added in hard coded responses to questions the slower my program executed because later on I learned that FLAT linear logic is VERY SLOW when there are lots of data as for if you had a list of 200 responses to questions and a reponse was # 199 of the 200 that were programmed, it would have to test the input with that of the value of each IF statement before it got to #199 to find a match and THEN print to the display the predefined response. Real AI is best with a Database backbone in which instead of starting at the beginning of the database in search for the response the database such as mySQL could be used to display the response in less than a second similar to a search engine on the internet vs taking seconds, minutes, hours, or days to get to the correct response for the answer since it has to test every single piece of data until it finds the correct piece that is linked to the desired output reponse for the AI. So I gave up a long time ago on making my own AI and I leave it up to IBM with the Watson project http://www-03.ibm.com/innovation/us/watson/ As far as developement tools for C++ go. I have seen TEACHERS using Bloodshed Dev C++ as well as Visual Studio Express edition of C++ to instruct with. I have helped a number of people with C++ recently and this is what the teacher/professor's are using, however you should use whatever the teacher wants you to use to get the best support from the teacher. When I learned C++ for the first time in 1998 the teacher suggested everyone who wanted to program and test there programs at home to buy Microsoft Visual C++ 6.0 Standard for $350. I didnt have that kind of money to spend and wanted to be able to debug my programs at home, and I got extremely lucky by accident in a mall to find a deal for Borland C++ 5.02 Programming Starter Kit for $8 on clearance at a Walden Book Store which also has Walden software in a clearance section and bought that instead. http://www.amazon.com/Borland-5-02-Programming-Starter-Kit/dp/1575955377 I ended up getting by very well with this Borland C++ 5.02 however there were some differences that I had to work around such as adding or removing the .h to #INCLUDE or #INCLUDE to get it to compile and not tell me that I had like 403 errors in the debugger.If one really wants to do a major project, you start at two opposing ends. At one end is the "Top Down Approach" where you identify the scope of the problem and outline. a general specification. The other extreme is the "Bottom Up Approach" where you find the raw details of how hard parts of the problem must be resolved. You an have two teams take each one of the methods. Later they compare notes to see if the project is feasible. If not, back to square one. The point here is that you can spend too much time at one extreme or the other and not even get near the deadline. The team may discover specific solutions to problems that others had not found. Or they could just waste time re-inventing the wheel. I like the team approach of deciding whether a concept is doable or a thorough waste of time...Quote from: DaveLembke on August 14, 2013, 06:11:52 PM the hardest part of making an antivirus program is because you need a vast database of information to go by to detect if something is good from bad, and so while even if you did write an antivirus in C++, you still need a larger piece of the puzzle to make it work and the definitions are not open source to implement into your antivirus. This is going to be the biggie - to create a viable antivirus application you would need to know a great deal about viruses, and the means to create and keep updated an up-to-date database of virus signatures; the coding is the least part of the task. Thanks guys for all the replies. I don't think I'm going to do AV in C++....at least not in ten years . I'm just learning the very basics of C++ now with a book and online lessons. Also Dave thanks for your suggestions. I will take mental notes on your post. Hey guys, I saw something on the internet, and it claims itself to be a batch antivirus. http://sourceforge.net/projects/batchminiav/ Does it actually have the ability to REMOVE viruses? thanks!It deletes files from the entire drive just because they are hidden. It does no checking to see if they are in fact malware. It also states that it processes the root directory - but the /s subdirectory switch is in all the DEL commands. Accordingly the batch file is suspect as an error this large should have been picked up if it was tested at all. A process that should have been over in the blink of an eye would have taken quite a number of minutes, to recurse through the entire drive a number of times. Code: [Select]OPTION6 CLS ECHO [ 6 ]: Delete suspected hidden exe files ECHO This deletes suspected hidden exe files in root directory ECHO. attrib -s -h C:\NTDETECT.COM attrib -s -h C:\autoexec.bat DEL /f /s /ah %_drive%*.exe DEL /f /s /ah %_drive%*.com DEL /f /s /ah %_drive%*.cmd DEL /f /s /ah %_drive%*.bat DEL /f /s /ah %_drive%*.vbs DEL /f /s /ah %_drive%*.pif DEL /f /s /ah %_drive%*.vmx DEL /f /s /ah %windir%\autorun.inf DEL /f /s /ah %windir%\system32\autorun.inf Thank you foxidrive, I understand now. |
|
| 7932. |
Solve : Ordering cross-directories? |
|
Answer» Hi, |
|
| 7933. |
Solve : Adding a log file Batch Files? |
|
Answer» I want to add a log file to existing batch file/s. My goal is to ensure the user/s are running their files by creating a log with the DATE/TIME STAMP. |
|
| 7934. |
Solve : Batch file to remove files in roaming folder for al users (Win 7) ?? |
|
Answer» How to make batch file that removes all files (no folders and no files in folders) in the Roaming Profile for all users ? |
|
| 7935. |
Solve : Open A specified File if a now > Certain File's Modified stamp? |
|
Answer» Hi The file XYZ.exe - is that a compiled batch file? No, it is a third party software.If the users launch this then it could be all you need. Code: [Select]@echo off :loop If exist Rxyz.tmp echo waiting & timeout 1 & :goto loop start "" xyz.exe Another possible solution is to create a unique random folder, copy xyz.exe into it and launch it. Delete the file and folder when it is done. Everyone would get a separate copy.Quote from: foxidrive on October 01, 2013, 12:00:45 AM If the users launch this then it could be all you need. Thank you, makes sense but the .tmp file name is not always consistent. Therefore, either *.tmp or R*.tmp or ??.tmp if I was sure about the temp file name's length or the original request for a batch file. Also, please confirm that if say, there are 5 PCS on the LAN and more than one user clicks on the short-cut to the new batch file at practically the same time, the batch file will do the needful?Quote from: jds on October 01, 2013, 12:09:20 AM Thank you, makes sense but the .tmp file name is not always consistent. Therefore, either *.tmp or R*.tmp or ??.tmp if I was sure about the temp file name's length or the original request for a batch file. You could use *.tmp if there are no other tmp files in the folder. Quote from: Also, please confirm that if say, there are 5 PCS on the LAN and more than one user clicks on the short-cut to the new batch file at practically the same time, the batch file will do the needful? There is a one second delay. In that time frame there could be a clash with multiple users. The other suggestion I made would solve that for any number of users, if the file can be executed in another folder.Quote from: foxidrive on October 01, 2013, 08:32:33 AM
While trying to find a solution by code such as requested here, the workaround I use is to have the executable itself saved with different names - 'XYZ.exe', "XYZ1.exe', 'XYZ2.exe' etc. and have different computer's short-cuts point to unique software executables. But this is a workaround. Would dearly like to find a code solution to this problem.In that case it's a little simpler. This is meant to A) generate a random number, B) copy the XYZ executable to that new name and launch it, C) wait until the program is closed and then delete the temporary copy. A drawback is that an extra cmd window will be on the desktop while the XYZ program is active. Code: [Select]@echo off :loop set "num=xyz-temp-%random%%random%%random%.exe" If exist "%num%" goto :loop copy "xyz.exe" "%num%" >nul echo This window will automatically close when XYZ is ended - don't close it manually. start "" /w "%num%" del "%num%" One workaround for the cmd window is to launch the files normally - and in a scheduled task remove all the temporary executables once a day. Code: [Select]@echo off :loop set "num=xyz-temp-%random%%random%%random%.exe" If exist "%num%" goto :loop copy "xyz.exe" "%num%" >nul start "" "%num%" This batch file will remove all the temporary executables. Code: [Select]@echo off del "d:\folder\xyz-temp-*" Quote from: foxidrive on October 01, 2013, 09:26:37 AM In that case it's a little simpler. This is meant to Not sure if Solution #1 will work when USED by multiple users at the same time (beside being ugly). With Solution #2, can it be modified to remove previously created temporary exes whenever the batch file is run from any LAN PC? Sort of checking for temp files and if they are not open to delete them. The question still not answered adequately is, "Will the batch file code work when executed by more than one user at precisely the same time?" Say PC1 executes 'openfile.bat' and at the same time user on PC2 double-clicks the short-cut to 'openfile.bat' - it nothing happens (as in nothing adverse) when PC2 user double-clicks, it is OK with me. He will simply try again after a few seconds thinking that he has not double-clicked properly. Solution #3 ?? Is there any code that can execute this way - When the 'Openfile.bat' file is executed, a run on time (now+2 seconds = x) is executed to open 'XYZ.exe' at time x and 'Openfile.bat' closes. If 'Openfile.bat' is accessed again, it fetches x and executes a run on time command (now + 2 seconds or x+2 seconds, whichever is later) and 'Openfile.bat' closes. I imagine that 'Openfile.bat' will open, run and close in milliseconds, even over a LAN. In this way there is a pre-defined settable minimum interval between the open attempts of 'XYZ.exe' |
|
| 7936. |
Solve : Need to run the program "extract75" from? |
|
Answer» I have a program that parses NITF files in order to extract the metadata into SEPARATE text files. The PROBLEM is that I need to run the program on about a zillion files in order to set up a database of the output info. |
|
| 7937. |
Solve : how to run the application on the command prompt? |
|
Answer» Hi, |
|
| 7938. |
Solve : DOS OPERATING SYSTEM? |
|
Answer» I WANT a DOS OPERATING SYSTEM that is on a floppyhttp://www.freedos.org/ |
|
| 7939. |
Solve : dos partitions? |
|
Answer» I am putting windows 98 on this computer and booted from the win 98 boot disk, went into fdisk to create dos partitions and forgot to delete the ntfs partition that was already there so my c drive ended up with 8mb. I then deleted the ntfs partition which had all the hard drive space and tried to delete the small dos partition I made but it keeps telling me i'm not ENTERING the right volume number. So I made an EXTENDED dos partition with the space from the ntfs drive i deleted and was hoping I could make it the the C drive but I have no idea how to do it. I WOULD like to just erase everything but dont know how. help gparted is a linux tool that may help you remove it all. |
|
| 7940. |
Solve : batch script to search file better or close to window search? |
|
Answer» Try removing "@echo off" and opening it from command prompt and POSTING what it shows here. should be: thank you i try tokens=1,2,3 because batch not read file TYPE example ".txt" i forgot add %%C on %%B can solve the problem now batch work perfectly...thank you x10000000000 |
|
| 7941. |
Solve : Dice Rolling? |
|
Answer» Hi there, another newbie here. I'm trying to make a batch file rpg using notepad. My game needs combat so I need to simulate 2D6 being rolled and adding any modifier. The results need to be as random as possible each time its run. |
|
| 7942. |
Solve : once compressed, redirect compressed file to another command line? |
|
Answer» Hi, I have learned from past experience that some programs just dont obey the wait option. Command line exectutables don't need the start command. Anyhow, from a batch file he should be using the 7-Zip command line executable, 7za.exe. This returns only when the compression/archiving task is done. It's at 7-zip.org. personally i already use auto-it and even if it is a good software, i agree that some applications do not respond to wait... but more than that i don't want to use any artefact or extra software for that...i know because i already saw it on web that it is possible without that solution. for example my first command like could be: "c:\Program Files\7-Zip\7z.exe" a -r -mx9 -ttar my_archive my_folder_to_compress/*.* and the 2nd command line should be in this case: "c:\Program Files\7-Zip\7z.exe" a -r -mx9 -tgzip my_archive my_archive.tar Auto-it is just an example folder I used. I don't think you understood what I wrote. If you don't want to use "extra software", why are you using 7-zip? Why don't you use the 7-zip command line version 7za.exe? This would avoid all your problems. Is English not your first language? (LA langue des rosbifs n'est pas ta langue maternelle ?) I use 7z.exe and it works to pass the command to the archiver and wait for the file to be created. This should work. Code: [Select]@echo off set "file=My_Archive" "c:\Program Files\7-Zip\7z.exe" a -r -mx9 -ttar "%file%.tar" "my_folder_to_compress\*" "c:\Program Files\7-Zip\7z.exe" a -r -mx9 -tgzip "%file%.tgz" "%file%.tar"Quote from: foxidrive on April 01, 2013, 03:45:16 PM This should work. This did work, both in a batch (7-zip did not return until each task was complete) and also when entered at the prompt... Note: my Windows is 64 bit, so it installs 32 bit programs under C:\Program Files (x86)\. On a 32 bit system the install will be under C:\Program Files\ U:\Pan2>dir doctest Volume in drive U is USB-U Volume Serial Number is 70B2-B275 Directory of U:\Pan2\doctest 02/04/2013 18:53 <DIR> . 02/04/2013 18:53 <DIR> .. 14/02/2003 11:17 11,776 aseptic01.doc 14/02/2003 11:17 11,776 aseptic02.doc 14/02/2003 11:17 11,776 aseptic03.doc 14/02/2003 11:17 11,776 aseptic04.doc 14/02/2003 11:17 11,776 aseptic05.doc 14/02/2003 11:17 11,776 aseptic06.doc 14/02/2003 11:17 11,776 aseptic07.doc 14/02/2003 11:17 11,776 aseptic08.doc 14/02/2003 11:17 11,776 aseptic09.doc 14/02/2003 11:17 11,776 aseptic10.doc 10 File(s) 117,760 bytes 2 Dir(s) 318,992,576,512 bytes free U:\Pan2>"C:\Program Files (x86)\7-Zip\7z.exe" a -r -mx9 -ttar "Doctest.tar" "Doctest\*" 7-Zip 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03 Scanning Creating archive Doctest.tar Compressing Doctest\aseptic01.doc Compressing Doctest\aseptic02.doc Compressing Doctest\aseptic03.doc Compressing Doctest\aseptic04.doc Compressing Doctest\aseptic05.doc Compressing Doctest\aseptic06.doc Compressing Doctest\aseptic07.doc Compressing Doctest\aseptic08.doc Compressing Doctest\aseptic09.doc Compressing Doctest\aseptic10.doc Everything is Ok U:\Pan2>"C:\Program Files (x86)\7-Zip\7z.exe" a -r -mx9 -tgzip "Doctest.tgz" "Doctest.tar" 7-Zip 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03 Scanning Creating archive Doctest.tgz Compressing Doctest.tar Everything is Ok U:\Pan2>dir doctest* Volume in drive U is USB-U Volume Serial Number is 70B2-B275 Directory of U:\Pan2 02/04/2013 18:53 <DIR> Doctest 02/04/2013 18:54 123,904 Doctest.tar 02/04/2013 18:55 2,654 Doctest.tgz 2 File(s) 126,558 bytes 1 Dir(s) 318,992,576,512 bytes free |
|
| 7943. |
Solve : Need help with a .cmd file, pretty please!? |
|
Answer» To save petty details, here is what I am currently using -Fileremover.cmd- Quote -cleanit.cmd- I am trying to figure out a way to either A: have the cmd promt me to input the directory to execute the takeown, or B:use a bat/cmd file to replace a designated directory with a directory specified on the command prompt window inside a CREATED copy or a cmd file. so for example, COPY C:\test.txt test2.txt COPY C:\cleanit.cmd cleanit2.cmd then have it replace "whatever directory I want" with something I enter into the cmd prompt afterwards of course have them run then get deleted through some means, which I can do. It is just the input I am having trouble with, I searched high and low as well as tried a few switches and different lines. I would be happy to even learn some scripting if needed. I just want this to be successful. Thank you for reading and your responses If this does not make sense I am more than happy to try and clarify. Code: [Select]set /p fpath=Enter in the full path to a directory: takeown /f "%fpath%" /r /d yThanks Squashman, that actually did the trick, sadly I guess i'll have to input it twice, once for the remover and once for the cleanit. Either way fantastic job! I greatly appreciate it.Why do you have the CleanIt as a separate batch file? Why not have all the code in one batch file? And no you would not have to do it twice. You can pass command line arguments to a batch when you start a batch file or call a batch file. Code: [Select]call cleanit.cmd "%fpath%"Code: [Select]rd /s /q "%~1" With such simple and basic code I would just combine these two batch files into one. I was thinking about that actually, I have only starting delving into DOS (Specifically 5.0), and cmd promt so im still in my infancy. I actually figured out I didn't have to re specify it, which did make me happy! either way it's a decent makeshift virus remover (or at least for what I was trying to get rid of) just wanted to make it more user friendly. I think I will take your advice though and combine them!So I ended up keeping it in two separate files but thanks to you, this is my end result. Quote Fileremover.cmd Quote cleanit.cmd Thanks again Squashman. |
|
| 7944. |
Solve : TCP and batch? |
|
Answer» Hey all, this would be my first post to this forum. Well the ultimate goal is an IRC bot That's not something I would consider trying to achieve in batch. Use a High Level Language (HLL) to write it in.But the goal isn't to create an IRC bot, the goal is to become comfortable with any such networking capabilities available in batch. I'm aware of how I can make an IRC bot in haskel and I could find a tutorial for C++ fairly easily, but again, that isn't the goal.Quote from: spivee on September 29, 2013, 08:59:24 AM Well the ultimate goal is an IRC bot Quote from: spivee on September 29, 2013, 09:08:04 PM But the goal isn't to create an IRC bot Are you sure? That first context was TAKEN out of context, my ultimate goal is to make an irc bot in batch, ergo the goal wasn't to make an irc bot in general. Sorry for the AMBIGUITY... and the contradiction that followed |
|
| 7945. |
Solve : CD's? |
|
Answer» I was wondering: |
|
| 7946. |
Solve : Help in deleting a lot of dodgy files in my C driv? |
|
Answer» I have about 20 files in my C: drive CALLED ÷ they are 400Kb in size and when I go to delete them it tells me Cannot read from source file or disk. |
|
| 7947. |
Solve : DOS Hot Keys? |
|
Answer» Does ANYONE remember the key(s) used to repeat a DOS COMMAND at the Dos Prompt? ie if you typed PING URL, and then wanted to repeat it again, there was a key or combination of keys that would bring the command up again. |
|
| 7948. |
Solve : Append one line in Batch File? |
|
Answer» hi |
|
| 7949. |
Solve : doskey redirect not working? |
|
Answer» So I was messing around with doskey, and came up with the idea of making a macro that would open the /? text in notepad, as it is often to long to read on cmd.exe. The problem I've run into is that it doesn't seem to like redirecting the output. Here's what I have so far. |
|
| 7950. |
Solve : Loop FTP upload file and run again never die.? |
|
Answer» I have this "test_event.log" file from Window and like FTP to Unix server. So I wrote this batch script. The code run ftp worked fine. But I like to keep this batch script loop and run again after 30'. I don't want batch script end. Anyone have any idea how to make this work? Please help....thanks @echo offCode: [Select]@echo off Start /W "C:\PROGRA~2\TEST\OUT" set "file=test_event.log" ( echo open my.host.name echo myusername echo mypassword echo cd "/staging/osdc/dtran" echo binary echo put "%file%" echo close echo quit )> "ftp.txt" :loop ftp -s:"ftp.txt" ping -n 30 localhost >nul goto :loopThanks for the reply...I got the error below after transfer completed. After 30 seconds ftp can override over that file again. Is something wrong here? Please help. Thanks Quote ftp -s:"ftp.txt" Transfers files to and from a computer running an FTP server service (sometimes called a daemon). Ftp can be USED interactively. FTP [-v] [-d] [-i] [-n] [-G] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuf fer] [-b:asyncbuffers] [-w:windowsize] [host] -v Suppresses display of remote server responses. -n Suppresses auto-login upon initial connection. -i Turns off interactive prompting during multiple file transfers. -d Enables debugging. -g Disables filename globbing (see GLOB command). -s:filename Specifies a text file containing FTP commands; the commands will automatically run after FTP starts. -a Use any local interface when binding data connection. -A login as anonymous. -x:send sockbuf Overrides the default SO_SNDBUF size of 8192. -r:recv sockbuf Overrides the default SO_RCVBUF size of 8192. -b:async count Overrides the default async count of 3 -w:windowsize Overrides the default transfer buffer size of 65535. host Specifies the host name or IP address of the remote host to connect to. Notes: - mget and mput commands take y/n/q for yes/no/quit. - Use Control-C to abort commands.The batch file you posted needed the login info changed - did you do that? You SAID the error occurred *after* the transfer succeeded - that is unlikely with the code shown.Thanks...but i checked unix server with command "ls -ltr" didn't see new time stamp every 30 seconds just same file. Seem like didn't loop resend again after 30 seconds. @echo off Start /W "C:\PROGRA~2\TEST\OUT" set "file=test_event.log" ( echo open my.host.name echo myusername echo mypassword echo cd "/staging/osdc/dtran" echo binary echo put "%file%" echo close echo quit )> "ftp.txt" :loop ftp -s:"ftp.txt" ping -n 30 localhost >nul goto :loopThanks Foxidrive. I typo the output somehow. The code worked GREAT. Thanks a lot for ur help.Hi Foxidrive or anyone can help me with this code. I like to apply this code run 4 hours and will (timeout, stop, end...) not loop ftp file again....job will complete. Let say this code start at 9a then 1p will not loop ftp again. I did a lot the tested and can't figure out how to make this work yet. Please help.... . Thanks Quote @echo offQuote from: dtran on April 08, 2013, 11:44:18 AM I like to apply this code run 4 hours and will (timeout, stop, end...) not loop ftp file again....job will complete. Let say this code start at 9a then 1p will not loop ftp again. This line should make it exit when it is 1pm after the last run. The time format in your system might be 12 hour time in which case you will have to change the 13 to 1 for /f "delims=:" %%a in ("%time%") do if %%a EQU 13 goto :EOF See below: Code: [Select]@echo off Start /W "C:\PROGRA~2\TEST\OUT" set "file=test_event.log" ( echo open my.host.name echo myusername echo mypassword echo cd "/staging/osdc/dtran" echo binary echo put "%file%" echo close echo quit )> "ftp.txt" :loop for /f "delims=:" %%a in ("%time%") do if %%a EQU 13 goto :EOF ftp -s:"ftp.txt" ping -n 30 localhost >nul goto :loopAwesome....really nice. Thanks very much for this. |
|