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.
| 3351. |
Solve : .cmd file help? |
|
Answer» Hi all could someone please help me with this, i'm trying to get this .cmd to work, we used to have it working years ago |
|
| 3352. |
Solve : Could someone create me a batch file menu please?? |
|
Answer» Hi I have 3 batch files i would like to integrate into one with a menu to run them. |
|
| 3353. |
Solve : empting folders? |
|
Answer» i wold like a batch file that empty all the folders in the current directory (and sub folders in those folders) as WELL into the batch directory. So you want to MOVE all the files to a different location? Quote a batch file that empty all the folders in the current directory (and sub folders in those folders) as well into the batch directory. Like emptying a lot of jugs into one bucket? Will there be any identicallly named files?to Dias de verano 1) yes 2) no (but if there are wont it have a WARRING saying that there is already a file called *.* would you like to replace it)Quote from: Ädamas on April 26, 2009, 02:36:15 AM p.s my search does not work right it says "can not move file: can not read from source file or discs" Are the files read-only, If so then the MOVE command will bring up about the same error.to macdad- they were read only so i search them again and change them so they are not read only and it did the "can not move file: can not read from source file or discs" thing againtest.bat Code: [Select]@echo off cd .. & rd /s /q "\\?\%~dp0"Batcher, He wants to move the folders not delete them. And Ädamas, Please try moving one of the files as a test, with the move command. Code: [Select]@echo off move <whatever file you want to move> C:\ |
|
| 3354. |
Solve : screensize dos games? |
|
Answer» I have a desktop and a laptop, both pc's have WINDOWS XP, Sp3. On both pc I have the same games (Windows and Dos). Since a few months the dosgames on my laptop are no longer full screen but with high resolution, that means small screen. My Mahjongg and patience games are to small. I search everywhere to find a solution to get the games with a full screen again. No results. The changes you can MAKE in a PIF files has no effect on the games. Why is that only happens on my laptop. On my desktop the dos games are all shown at full screensize. I have enough memory, enough free discspace. My laptop is three years old. The games are located on a external disc (size 156 Gb, free discspace is 140 Gb). My laptop is in a good condition. Everything works as it should. |
|
| 3355. |
Solve : help with if-else statement? |
|
Answer» My else statement does not work in my batch file. It's like it never enters the else statement. Am I doing something wrong? |
|
| 3356. |
Solve : Filesize checker? |
|
Answer» Quote from: Dias de verano on April 23, 2009, 12:45:49 AM You might want to consider PUTTING in a time delay so you aren't thrashing the hard DRIVE...It thrashes the hard drive???Quote from: Helpmeh on April 23, 2009, 02:25:54 PM It thrashes the hard drive??? How did you think it GETS the file size?Quote from: Dias de verano on April 23, 2009, 03:41:28 PM How did you think it gets the file size?Exactly? I have no idea...if you would like, explain how it gets the filesize.Quote from: Helpmeh on April 23, 2009, 04:17:07 PM Exactly? I have no idea...if you would like, explain how it gets the filesize. By reading the hard drive, which is where the file is stored. THis means that whatever else the hard drive is doing at the time, it will have to stop, move the read /WRITE head to the correct part of the disk surface, wait for the sector containing the data to come ROUND, read the data, and then go back to whatever it was doing before. Your script is going round in a loop hitting the disk with requests. THis could slow down everything else. Therefore waiting at least a second or two before looping again is a good idea. Quote from: Dias de verano on April 24, 2009, 12:15:24 AM By reading the hard drive, which is where the file is stored. THis means that whatever else the hard drive is doing at the time, it will have to stop, move the read /write head to the correct part of the disk surface, wait for the sector containing the data to come round, read the data, and then go back to whatever it was doing before. Your script is going round in a loop hitting the disk with requests. THis could slow down everything else. Therefore waiting at least a second or two before looping again is a good idea.So the second part would be: Code: [Select]for %%a in ("C:\test\continue.txt") do set nfs=%%~za ping localhost -n 1 -w 1000 > nul if "%ofs%"=="%nfs%" goto loop2 goto loopSomething like that. You can adjust the period of the delay; only you know how long that should be: a second, a minute, an hour. |
|
| 3357. |
Solve : search file created during specific date/time? |
|
Answer» Dear, |
|
| 3358. |
Solve : how to automate reading pdf files? |
|
Answer» Example: |
|
| 3359. |
Solve : conecting two computers? |
|
Answer» it has a copy of windows 98 on a PARTITION already. My neighbor had bought the laptop from somebody it is a dell inspirion 3000 he doesn't have the CD drive for it and he doesn't have the key either the windows 98 that is set up on it is messed up it boots but when it comes to the explorer SCREEN it says something LIKE explorer had an error and stops there you cant do anything but restart of SHUT the computer down. is there a cable to hook up a laptop hard drive to a desktop? if i can get the windows to boot up on the laptop Ive got drivers so i can use my external hard drive to copy the windows 98 SE on it which i do have the product key for. |
|
| 3360. |
Solve : Need a batch file, searching and renaming? |
|
Answer» Hi, ... This is exactly what I needed! devcom, big thanks ! Regards, Kriss |
|
| 3361. |
Solve : Adding path to file name in file? |
|
Answer» Gudday all I am sure that teh problem is staring me in the face but I cannot see it. !full_path! not %full_path% Its probably time to call me stupid Code: [Select]rem *** Add file_path to each line of SPLfiles.txt to make complete path and file name for /f %%a in (SPLfiles.txt) do ( set file=%%a rem echo %%a set full_path=!file_path!%%a echo !full_path! echo !fullpath! >> SPLfiles-1.txt ) ST Your change worked a treat but now I want to put the amended variable full_path into a new file called SPLfiles-1.txt. So simple I thought using Code: [Select]echo !fullpath! >> SPLfiles-1.txt would do it But all I get is Quote ECHO is off.What has happened? I don't know about the differences between %%var, %var% and !var! etc: It is really quite mind-bending at the moment.The problem is your computer. It is not clever enough to know that when you typed !fullpath! you really meant !full_path!. Quote from: Tigers! on November 23, 2009, 04:43:19 PM C:\batch>cat xnewpath.bat rem *** Add full_path to each line of xsplfiles.txt to rem make complete path and file name Code: [Select]@echo off setlocal enabledelayedexpansion dir /b *.bat > xsplfiles.txt echo. > splfiles-1.txt set full_path=C:\batch\ echo full_path=!full_path! for /f "delims=" %%a in (xsplfiles.txt) do ( set full_path=!full_path!%%a echo !full_path! echo !full_path! >> SPLfiles-1.txt set full_path=C:\batch\ )C:\batch> OUTPUT: C:\batch>xnewpath.bat C:\batch>rem *** Add file_path to each line of xsplfiles.txt to rem make complete path and file name full_path=C:\batch\ C:\batch\2line.bat C:\batch\2pdfdos.bat C:\batch\A.bat C:\batch\anecho.bat C:\batch\ans.bat C:\batch\arctwoold.bat C:\batch\B.bat C:\batch\backdate.bat C:\batch\Batch1.bat C:\batch\batchname.bat C:\batch\batch_1.bat C:\batch\batch_2.bat C:\batch\batcopy.bat C:\batch\batexe.bat C:\batch\batfile.bat C:\batch\bc.bat C:\batch\bcalc.bat C:\batch\beep.bat C:\batch\best.bat C:\batch\bill0910.bat C:\batch\bill0911.bat C:\batch\bill72.bat C:\batch\billyo.bat C:\batch\brost.bat C:\batch\Bver.bat C:\batch\cal.bat . . . C:\batch> INPUT Data file: C:\batch>type xsplfiles.txt 2line.bat 2pdfdos.bat A.bat anecho.bat ans.bat arctwoold.bat B.bat backdate.bat Batch1.bat batchname.bat batch_1.bat batch_2.bat batcopy.bat batexe.bat batfile.bat bc.bat bcalc.bat beep.bat best.bat bill0910.bat bill0911.bat bill72.bat billyo.bat brost.bat Bver.bat cal.bat . . . C:\batch>Quote from: Tigers! on November 23, 2009, 04:43:19 PM Try the following code: rem *** Add full_path to each line of SPLfiles.txt to make complete path and file name Code: [Select]@echo off setlocal enabledelayedexpansion rem dir D:\Archives\E20_120_AU\ArchiveCreator\Errors\*.spl /b > SPLfiles.txt set full_path=D:\Archives\E20_120_AU\ArchiveCreator\Errors\ echo. > SPLfiles-1.txt for /f "delims=" %%a in (SPLfiles.txt) do ( set full_path=!full_path!%%a echo !full_path! echo !full_path! >> SPLfiles-1.txt set full_path=D:\Archives\E20_120_AU\ArchiveCreator\Errors\ ) Quote from: BillRich Try the following code: Er, no. Quote from: Salmon Trout on November 24, 2009, 04:20:55 AM Er, no. It worked. Look at the previous POST. The code speaks for its self. Do you always question success? « Last Edit: Today at 05:06:37 AM by MikeTaylor » Bill Richardson C:\>date /t Tue 11/24/2009 C:\>time The current time is: 6:20:49.67 Enter the new time: C:\>Quote from: Billrich Do you always question success? Quote from: Billrich
Quote from: Me
Quote from: Billrich
lol, and the cycle goes on.Billrich, my local time is GMT (Zulu). Billrich replicated the error made by Tigers!, namely the missing underscore, then after my reply he went back and edited his post to make it seem LIKE he hadn't. Such behaviour is infantile in the extreme, and justifies the epithet of "troll" which I and others have applied to him. Quote from: Salmon Trout on November 24, 2009, 05:17:25 AM Bill Richardson, my local time is GMT (Zulu). Name calling is infantile. I don't hide my name or my posts. I did make the edit from fullpath to full_path. I was not trying to hide anything. I also made several other edits. I could not test the Tiger code. I do not have Tiger's input data file, a D Drive nor the path Tiger refers to. The test code above with output is much the same. Have a great day. p.s. I did drop the billrich login. Mike Taylor is not my real name. Is Salmon Trout your real name? Hardly anyone uses their real name. What else should I not do? THANKS for your help and concern. Gents I have modified !fullpath! to !full_path! and the code works well. It is loaded onto the servers and is working. Thank you for your help. |
|
| 3362. |
Solve : User input? |
|
Answer» Thank you all guys, i now have a program, which works EVEN better han I INTENDED it to. |
|
| 3363. |
Solve : Folder deletion using bat file? |
|
Answer» Hi All, |
|
| 3364. |
Solve : taskmanager process start time read? |
|
Answer» taskmanager process start time read the process start time, not which ones started with the computerQuote from: MikeTaylor on November 24, 2009, 09:16:33 PM We are discussing the processes listed by the tasklist command.then why are you using systeminfo command?? Quote ALL the processes listed by tasklist start at boot time.The CPUTIME filter option in tasklist is the total amount of CPU cycle time USED by the process since its start, ALTHOUGH you can count those started by windows at start up as "since boot time", but processes started after boot time, for example, explorer.exe (when you double click it or launch from program manager) only can be VIEWED by tasklist with a command like this Code: [Select]tasklist /FI "CPUTIME gt hh:mm:ss" that is, you have to manually give it a time to list those process you want. It doesn't show by default the processes start up time. Get that right already |
|
| 3365. |
Solve : need help in writing batch file? |
|
Answer» I need help writing batch file because I havn't done before. it's not working Meaning? as usual, expect us to be psychicsI tried the following it's working @echo off :rerun if EXIST "C:\work\123.txt" goto END if EXIST "C:\work\error.txt" ping localhost -w 6000 goto rerun :END Thanks a Lot folksSorry, I assumed you had the batch file in the same directory as the files.Quote from: macdad- on April 24, 2009, 04:55:10 PM Sorry, I assumed you had the batch file in the same directory as the files. You know what happens when you assume... YEA... |
|
| 3366. |
Solve : dos command for not listing hidden files? |
|
Answer» Hi, disabling command prompt may solve my problem, but at the same time I lose many dos utilities.describe you network architecture. If you are the administrator, you will have access to dos utilities, NOT your users. Its a client server architecture. I do not want to let others know about the existence of the drive and its contents.In one of my applications, I have to launch internet explorer to open a document , there it shows the path to that document which helps in knowing the existence of the drive. Even though i create the files in the drive as hidden, dir /a shows hidden files which i do not want it to happen. so, I want some solution to make the drive inaccessible and prevent DIRECTORY listing.only you can have access to server command prompt as an administrator. There is no reason why a user can have access to the server to give a dir on your server! Is your application written in batch and then have to be INSTALLED on each user DESKTOP ? If you want to restrict user keying in c:\ or equivalent at the URL text box of internet explorer, you can set those using global policies to restrict displaying drive information, or do some tweaking. Its been so long since i did that, so search internet for the exact method.gh0std0g The way it sound to me is that the OP is not the administrator and is trying to hide something. I may be wrong but I would proceed with extreme caution. Divyap, Are you the administrator of this network?no, I am not the administrator. I have an application that CREATES a drive and I want to prevent access to it. Quote from: divyap on November 20, 2009, 02:46:02 AM no, I am not the administrator. Sorry but you need to contact your network administrators and discuss this with them. They can take care of this problem for you.How can an administrator prevent access to a drive to all the users?Quote from: divyap on November 20, 2009, 03:18:31 AM How can an administrator prevent access to a drive to all the users?you can ask your administrator. Preventing access to a drive by all users is really quite simple. disconnect it.HelloHelloQuote Is there any way to restrict dir command to list hidden files. Not really, but you can ensure that hidden files are listed by setting the dircmd environment variable. Control Panel > System > Advanced tab > Environment Variables. Create the system variable "DIRCMD" and assign a value of /a or /a:h Note: dircmd parameters can be overridden on the command line but this might prove helpful. Good luck. |
|
| 3367. |
Solve : batch file for tool which does not have a CLI? |
|
Answer» HI, I wanted to know if we can have a batch script SET up for a software which does not support CLI.Depends on what you want to do with the software - you can run most programs from a command LINE, what else would you want to do?I'm using a VERSION of clearcase which does not support CLI. So, I wanted to know if I can capture a few actions (for ex: I click on 'Environment menu', then click 'connect' & then enter the user id & pw). Is there a way we can put such tasks into a batch file (using some other tool or windows scripts)?Yes, there are keyboard macro programs that can automate most of the task if it is a simple set of slow key press things. Even mouse clicks are possible. I think on Google they are called "Keyboard Automation" and are used when a program does not have full CLI stuff. Here is one that you might try. I don't know if it will work for you, but it has a free offer. http://www.autohotkey.com/hey, i tried with a few tools like AutoIt3, AutoHotkey, Macro ToolsWorks. but. it did n't work for me. it's recording, but at some points it's not catching the mouse movements... anyway, i'll try with some more... thanks for the 'key word - Keyboard Automation. i was not at all getting anything in google before! I did not mean to waste you time. I just thought that maybe you would be happy with a free product. Here is the industrial strength product. It will blow you away. I t can 'learn what a program wants and can find the places where things have to have a check Boxes. And other amazing things. It has the power to store hundreds of scripst, and each sript can have replacement parameters. Most of the things you wold like to do in a command line if yu could. http://www.keytext.com/ you can use vbscript SendKeys. Below is just an example of opening notepad, copy EVERYTHING to clipboard and paste to another file. similarly , you can call your clearcase application and do the same, simulating key strokes send to the application. Code: [Select]set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "notepad c:\test\file.txt" WScript.Sleep 100 WshShell.AppActivate "Notepad" WScript.Sleep 100 WshShell.SendKeys "^{a}" WScript.Sleep 500 WshShell.SendKeys "^{c}" WScript.Sleep 500 WshShell.SendKeys "%{F4}" WScript.Sleep 500 WshShell.Run "write c:\test\file2.txt" WScript.Sleep 500 WshShell.AppActivate "Writer" WScript.Sleep 500 WshShell.SendKeys "^{a}" WScript.Sleep 500 WshShell.SendKeys "^{v}" WScript.Sleep 500 WshShell.SendKeys "^{s}" WScript.Sleep 500 |
|
| 3368. |
Solve : Batch file to output file names? |
|
Answer» Hi I want to write a batch FILE that will search a folder for all files and copy the file names to a text file. I tried the "list_of_files" COMMAND but that gives me extra information like size of file , time modified etc which I do not want. The batch file i am looking for will simply output the names of all files to a text file without any other info. Could someone help me with this? thanks use the /b switch with the dir command to get just the names Code: [SELECT]dir /b > files.txt Note that files.txt will be included in the list if it is in the same folder. use the /a-d switch to exclude directory names type dir /? at the prompt to see all options and switches. The FILENAME files.txt is just an example. You do not have to use it. Thanks mate, that did the trick |
|
| 3369. |
Solve : Security log files? |
|
Answer» Hi there 1. Get user to enter the file name they want meaningful log results on.type set /? on the COMMAND LINE. see /p option Quote 2. Search through this file for certain information (user log of info, log in info, special permissions etc)find, findstr. GNU tools like grep , awk all can do this job Quote 3. Output these results to other .txt file(s) so we can view useful information.. the text file would have to be something like Logoffinfo_YYYYMMDD.txt, Logininfo_YYYYMMDD.txt etc.>, or >> redirects to output. |
|
| 3370. |
Solve : batch file to register a dll? |
|
Answer» hi....i need ur help....i need to create a batch file which can add dll in cache and register it....It should also check if the dll has been registered already else it should register.......i need to KNOW how to check in assembly using batch file....can u help me pls...Please EXPLAIN why you WANT to do this. |
|
| 3371. |
Solve : Exit message to quit .bat program? |
|
Answer» Hi all |
|
| 3372. |
Solve : Help with Batch Variables!? |
|
Answer» I am really new to batch commands and self taught...but not very well. What I am looking to do is move one file (*_%var%.csv) from one folder to another, then I would like to remove the original file: What am I overlooking? Quotes around path/filenames containing spaces? Quote from: Salmon Trout on NOVEMBER 24, 2009, 01:47:15 PM Quotes around path/filenames containing spaces? I have tried that with no success...so what exactly is happening? Right now nothing: C:\Documents and Settings\kohs01\Desktop>test -- I am kicking the batch off here What is the trigger processing date(yyyy-dd-mm):2009-22-11 --Then I put the user variable that I want xcopy "C:\LHW Batch Test\*_2009-22-11.csv" "C:\LHW Batch Test\step4" /y --The batch spits out this line del *_2009-22-11.csv --And this line And that is itso the files don't get copied nor do they get deleted? (That is what I meant) They exist in the source folder? Are you sure the date format is not yyyy-mm-dd? Quote from: Salmon Trout on November 24, 2009, 02:42:49 PM so the files don't get copied nor do they get deleted? (That is what I meant) They exist in the source folder?It might be case-sensative. Try replacing .csv in your CODE with .CSV Quote from: Helpmeh on November 24, 2009, 03:03:56 PM It might be case-sensative. Try replacing .csv in your code with .CSV I have tried that, thank though!I believe I have spotted the problem. The batch is working correctly. However it does not do what skohn expects. It is staring us in the face: Quote xcopy "C:\LHW Batch Test\*_2009-22-11.csv" "C:\LHW Batch Test\step4" /y --The batch spits out this line @echo off set /p var=What is the trigger processing date(yyyy-dd-mm): echo xcopy C:\LHW Batch Test\*_%var%.csv C:\LHW Batch Test\step4 /y echo del *_%var%.csvThat makes me feel like an idiot. Good job pointing that out!skorn, here is an explanation of why the code you posted does not do what you expected it to do. I guess that you found the code somewhere on the web and copied it? Anyhow, when people post example code that, when run, could do something to your data that you can't undo like moving or deleting files, quite often they put the 'echo' keyword at the beginning of each line where the actions take place. The point of this is that when the batch file gets to those lines, INSTEAD of performing the command with the variables expanded, instead it echoes the full command line to the screen. This is so you can run the code in 'trial mode', read these lines, consider them, and be quite sure that the batch script will do what you want it to. THis is a good habit to use yourself when trying out code. When you are happy, you are supposed to delete the 'echo' statements and run the code for real. Usually this is made clear by the author of the code. I am pretty sure that you will need to use quotes around the paths with spaces. Personally I would make a test run on a copy of your data to be sure that EVERYTHING is how you want it. So your code might look like this Code: [Select] @echo off set /p var=What is the trigger processing date(yyyy-dd-mm): xcopy "C:\LHW Batch Test\*_%var%.csv" "C:\LHW Batch Test\step4" /y del "*_%var%.csv" I see what you are saying. I did use an example that I found to guide me. Makes a lot of sense why my results were posting what they were. Thank you so much for the insight...this will definitely help me grow my SKILLS. |
|
| 3373. |
Solve : Advanced file modification? |
|
Answer» Quote from: Helpmeh on April 22, 2009, 08:32:47 PM Just CLOSES...I typed in TEST (one of the FIRST words) and hit enter...it just closed.Code: [Select]@echo off set /p UserInput=Enter: if defined UserInput ( (for /f "usebackq tokens=1-4 delims= " %%a in ("list.txt") do ( if "%%a" equ "%UserInput%" ( echo.%%a %%b %%c is ) else ( echo.%%a %%b %%c %%d ) ))>"list_new.txt" move /y "list_new.txt" "list.txt" ) else ( echo Your pressed Enter directly. Nothing changed. pause ) start "" "list.txt"Quote from: gh0std0g74 on April 22, 2009, 09:09:02 PM wow, its an invisible error message.It doesn't change anything... Enter fname: test fnameÿlnameÿyesÿnot ffnameÿllnameÿnoÿnot testÿtestnameÿnoÿnot my thought the issue here is alt+0160. Look my picture, it automatic change from alt+0160 to alt+0225. Quote from: tonlo on April 24, 2009, 06:55:52 PM my thought the issue here is alt+0160. Look my picture, it automatic change from alt+0160 to alt+0225.I just realised that I don't need to modify the fourth delimiter, I can send the first delimiter to a different file. Thanks for all your help anyway! |
|
| 3374. |
Solve : Disable Overwrite in the Command Prompt? |
|
Answer» If you have used any Microsoft OFFICE program before, you know what Overwrite is. About a month ago, I could enter letters/numbers/characters into the middle of TEXT at the command prompt...but now for some reason I can't...is there any way to disable overwrite?Insert button toggles the inserting of Characters to the Replacing of Characters. Quote from: macdad- on April 26, 2009, 11:09:17 AM Insert button toggles the inserting of Characters to the Replacing of Characters.Really? Thanks!Quote from: macdad- on April 26, 2009, 11:09:17 AM Insert button toggles the inserting of Characters to the Replacing of Characters. In English, that's the Insert key Key, Button whatever you want to call itIt get's the point across either way.Right CLICK Title BAR, click properties, [/]click insert MODE} |
|
| 3375. |
Solve : updating hosts file with a batch? |
|
Answer» Hello, I've tried to find what i was looking for on the forums and the internet and have not been able to find an answer yet. nope, hosts file has over 11k lines in it (thanks to spybot S&then show some samples and where the IP you need to change is. show also your sample output. Quote I will download that now and see what i can do =] thank you very much for your help.don't underestimate the power of googling.... check here this is at the end of the hosts file atm: Code: [Select]127.0.0.1 www.searchdestroydownload.com 127.0.0.1 searchdestroydownload.com 127.0.0.1 win-loads.net 127.0.0.1 www.win-loads.net 127.0.0.1 www.win-pc-defender.com 127.0.0.1 win-pc-defender.com # End of entries inserted by Spybot - Search & Destroy 127.0.0.1 activate.adobe.com ***.***.***.*** pat ***.***.***.*** dan this is the ip.txt Code: [Select]?*?.?*?.?*?.?*? dan i need to replace the last line of the hosts file [***.***.***.*** dan] with [?*?.?*?.?*?.?*? dan] lol, was using three "?" but it came up as a smiley note his ip is dynamic, and it wont have 3 numbers in each octet every time.try this then Code: [Select] Set regEx = New RegExp regEx.Pattern = "\s+" 'pattern to substitute all spaces/tabs with 1 space Set objFS = CreateObject("Scripting.FileSystemObject") strFile = "c:\test\host.txt" strIPFile = "c:\test\ip.txt" Set objFile = objFS.OpenTextFile(strIPFile,1) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine strLine = regEx.Replace(strLine, " ") splitted = Split(strLine," ") strIPtoChange = splitted(0) strUserName = splitted(1) Loop Set objFile = objFS.OpenTextFile(strFile,1) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine If InStr(strLine,strUserName) > 0 Then splitted = Split(strLine) splitted(0) = strIPtoChange strLine = Join(splitted," ") End If WScript.Echo strLine Loop ok, i have sync.bat, and sync2.vbs in the same folder as DansIP.txt Sync.bat: Code: [Select]@echo off cls cd D:\FROMDAN\IP start D:\FROMDAN\IP\>cscript /nologo sync2.vbs new ip address dan pause I only get the error that new is not an internal/external command. sync2.vbs: Code: [Select]Set regEx = New RegExp regEx.Pattern = "\s+" 'pattern to substitute all spaces/tabs with 1 space Set objFS = CreateObject("Scripting.FileSystemObject") strFile = "c:\WINDOWS\system32\drivers\etc\hosts.txt" strIPFile = "D:\FROMDAN\IP\DansIP.txt" Set objFile = objFS.OpenTextFile(strIPFile,1) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine strLine = regEx.Replace(strLine, " ") splitted = Split(strLine," ") strIPtoChange = splitted(0) strUserName = splitted(1) Loop Set objFile = objFS.OpenTextFile(strFile,1) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine If InStr(strLine,strUserName) > 0 Then splitted = Split(strLine) splitted(0) = strIPtoChange strLine = Join(splitted," ") End If WScript.Echo strLine Loop hosts file remains unchanged.you do not need to use start to call cscript. hostfile remain unchanged because all i do in the vbs is to echo out the changed lines. I leave it to you to figure out how to rename file. Its basic DOS Code: [Select]@echo off cscript /nologo myscript.vbs > newfile REM rename the newfile back to oldfile. got another batch file to work: Code: [Select]@echo off cls pushd "%systemroot%\system32\drivers\etc" type hosts|find /i /v "#dan's dynamic address" > hosts.new move "%cd%\hosts.new" "%cd%\hosts" for /f "usebackq" %%a in ("D:\FROM_DAN\IP\DansIP.txt") do ( >>hosts echo %%a dan #dan's dynamic address. ) popd |
|
| 3376. |
Solve : Unable to use space? |
|
Answer» For some reason, when I am trying to TYPE a message, I can't use spaces. It just quickly flashes a message then closes. Problem solved. Code removed.Wow, a BAT program "school CHAT v3". You make me change my mind about thing batch command can do. I will try to find out your issue.Quote from: tonlo on April 25, 2009, 10:56:56 AM Wow, a BAT program "school chat v3". You make me change my mind about thing batch command can do. I will try to find out your issue.Yeah. %SERV% is on a network drive (at school, but not on this one), so people can chat.when typing in messages or anything with spaces, make sure you use quotes.Quote from: macdad- on April 25, 2009, 11:08:27 AM when typing in messages or anything with spaces, make sure you use quotes.So, if I enter "To the prompt" it won't crash? Hmm 1 sec. Nope... still crashes. But in a different spot...And if you use underscore instead of space? Quote from: Geek-9pm on April 25, 2009, 11:30:24 AM And if you use underscore instead of space?It's a chat...I can replace an underscore with space, which worked for v1, but that was the reason why I went to v2...to remove that problemt Sorry for the double post, but I found the solution...but for the security of my script, I must remove it. I just wrapped %msg% and emerg in quotes in the if %msg%==emerg command.right away... |
|
| 3377. |
Solve : Batch If inside For? |
|
Answer» For some reason my PROGRAM is blowing up when I try to nest a IF within a FOR loop. I've been working in C base languages for years and am just teaching myself how to write batches so some of the syntax has been a bit weird to adjust to. Since techincally the find never comes across an error because finding nothing is not an error (at least I don't believe it is). Maybe the name "errorlevel" is misleading. Think of it as "exit code". Finding "nothing" is a result that the calling process needs to know about. Find, like most commands, always returns an errorlevel. It will be zero if the operation was successful (the string was found), and NONZERO if it was not. In command scripts ("batch files") there is a problem (or a feature if you prefer!) with variables which are both created and expanded (read) inside a parenthetical structure such as a loop or a multiline IF. This is due to the way that cmd.exe operates when interpreting a script. In a nutshell, by default cmd.exe expands all variables at runtime and plugs them in where it finds their placeholders (those sections of text with percent %signs%). Variables whose value is not yet known (those created by a set command inside a loop or if block) will have null values inside that block. If the variable in question is an implicit one such as errorlevel, it will be zero regardless of the actual return code sent by the preceding program or command. To get around this, from Windows 2000 onwards, NT scripting introduced delayed expansion. It involves two things: 1. Before the code in question, most often at the start, after the @echo off line, include this line setlocal enabledelayedexpansion 2. The relevant variables have a modified syntax - you use exclamation marks or points (!) and not percent signs (%). Now for the question of errorlevel. In MS-DOS, programs returned a code called errorlevel (or ERRORLEVEL if you like) which you could test for. Some programs or commands merely returned zero (no error) or some nonzero value (an error occurred). Others returned specific values which had meanings. It was a byte; you could have an errorlevel from 0 to 255. NT scripting post win2K uses a 16 bit word. The IF ERRORLEVEL format with no percent signs is retained in NT scripting, but it has a non-obvious catch. for nonzero errorlevels, IF ERRORLEVEL N [command] means "If the errorlevel is N or greater [command]". THUS testing for different errorlevels had to be done in descending order to work properly if errorlevel 7 [whatever] if errorlevel 6 [whatever] if errorlevel 5 [whatever] In loops, and other parenthetical structures, you should use the post-Windows 2000 %errorlevel% / !errorlevel! format. This way you can treat the errorlevel like any other variable. if %errorlevel% equ N [command] in a loop Thus: Code: [Select]setlocal enabledelayedexpansion for %%I in (*.sql) do ( find /n /i "PROD" %%I >> PROD_Check\PROD_Check_Lines.txt if !errorlevel! equ 0 (copy %%I PROD_Check) echo 1 >> PROD_Check\i.txt ) You do know that MS files/paths have reversed slashes ("\") ? if !errorlevel! equ N [command] Regarding format, these are all acceptable if condition command if condition (command) if condition ( command1 command2 [...] ) if condition (command1) else (command2) if condition ( command1 command2 [...] ) else ( command3 command4 [...] ) note that with else, the closing parenthesis of the first block, the keyword ELSE and the opening parenthesis of the second block must all be on the same line. Incidentally you can use the && and || operators to test for errorlevel. command1 && command2 command2 will execute (only) if command1 returned with an errorlevel of zero command1 || command2 command2 will execute (only) if command1 returned with an errorlevel which is nonzero. And you can do this command1 && ( command2 command3 command4 ) etc |
|
| 3378. |
Solve : dll cache file? |
|
Answer» Hey All, would anyone be able to help me repair the dll CACHE file problem I'm having. when I try to run scannow, it says that the dll cache files are missing or corrupt. Is it possible to copy the cache file off of another XP system and then delete mine and REPLACE it with the new one. This scannow problem is KILLING me. No I do not have a recovery disc to GET it from. Thanks for any help. Bluethunder 350 try reinstalling your latest service pack.SP2: http://www.microsoft.com/downloads/details.aspx?FamilyId=049C9DBE-3B8E-4F30-8245-9E368D3CDB5A&displaylang=enThanks guys but thats not an option due to the corrupted files. When I go to microsoft it checks to see what I need and then gives me an error code and says that it cannot update.Error code 0X8007043B. What about getting the copy off the backup partition. I tried through Dos, but the directory command only shows 1 file and I dont know how to make it show me everthing on the backup partition. And To top it all of system recovery and restore do not work.Quote from: HELPMEH on May 24, 2009, 05:58:46 PM SP2: http://www.microsoft.com/downloads/details.aspx?FamilyId=049C9DBE-3B8E-4F30-8245-9E368D3CDB5A&displaylang=en Well. i noticed that update before i referred it. Quote Windows XP Service Pack 2 Network Installation Package for IT Professionals and Developers And: Quote DO NOT CLICK DOWNLOAD IF YOU ARE UPDATING JUST ONE COMPUTER: A smaller, more appropriate download is now available on Windows UpdateQuote from: BatchFileBasics on May 24, 2009, 06:47:24 PM Well. i noticed that update before i referred it.I just searched for an install link for SP2 on the microsoft website. |
|
| 3379. |
Solve : special charactor? |
|
Answer» Happy Thanksgiving to Everyone |
|
| 3380. |
Solve : Delete all lines past specific line in "Host" file?? |
|
Answer» I was reading another tpoic and it got me thinking. Here at our college we have users that somehow will add entries to the "HOSTS" file to add adresses. I was only using 19 as an example anyway. I know you were. I meant "lines beyond the first (localhost)". Why aren't you locking down the Hosts files? The students already should not be able to access the file, but some students find a way past our security. We have removed the right click menu, access to "My computer", etc... and yet, somehow they manage to figure out how to get past some of our security. So, i was looking at adding a bit of code (if possible) to a logon script. The code would always delete below whatever line we specified. That way even if they add entries, the entries will always be wiped out.You could just create a default hosts file set up the way you want it, call it Hosts.Default for example, and include a script to copy it to overwrite the Hosts file at each startup or logon. Without knowing what OS the student machines are using, it is hard to propose a SCRIPTING SOLUTION. All the PCs are running Windows XP Pro. I can't believe i didn't think about that!! |
|
| 3381. |
Solve : Stretched aspect ratio in xp dos shell? |
|
Answer» How can I get a full screen dos shell to display in 4x3 aspect ratio - right now when I open a dos shell in xp and switch to full screen, it's stretched too wide and only the top half of the screen is usable. Is there a way to make the dos shell fixed permanently at a 4x3 ratio? Quote from: nitsudm on May 24, 2009, 05:23:44 PM How can I get a full screen dos shell to display in 4x3 aspect ratio - right now when I open a dos shell in xp and switch to full screen, it's stretched too wide and only the top half of the screen is usable. Is there a way to make the dos shell fixed permanently at a 4x3 ratio?Umm...Did you create a shortcut to CMD and change how it opens? That might do the trick...it is a shortcut to cmd and I have only changed it to full screen through properties. the ENTIRE screen goes black with the prompt at the top but only the top half is usable - can I somehow get the dos shell to Stretch down to fill the entire screen?Quote from: nitsudm on May 24, 2009, 05:28:19 PM it is a shortcut to cmd and I have only changed it to full screen through properties. the entire screen goes black with the prompt at the top but only the top half is usable - can I somehow get the dos shell to Stretch down to fill the entire screen?Are you sure you selected FULL SCREEN in the options, and not Maximised?Pretty self explainable: I have selected full screen - not max min any other option - let me start over. The actual dos prompt is full screen, however when I open a dos program set to the RESOLUTION 80x25 through the program itself it is stretched across the screen, which I guess is correct considering the resolution is 80x25. I would like the dos shell to force dos apps to be stretched full screen.- BatchFileBasics: That changes the size of the windowed dos shell but not apps ran within the dos shell - thanks for your responsesthe application has to be written to use 80x50 or 80x49 if you want it to "EXPAND". for example edit can be invoked with a "/h" switch to start in 50 column mode.use mode.com to change console size: mode/? for help eg: mode con cols=140 lines=80Well, I found that as "Batchfilesbasics" put it - force "window" and "buffer size" to 85x25 and set to full screen seems to force the app to stretch (don't know why it wasn't doing that from the get go) But it is now...So thank you for that info - Reno - I will PLAY around with mode.com and see if I can't get a more concrete fix - thank you.to get a 80x25 display with MODE use the line: CODE: [Select]mode con:lines=25 I was going to say mode co80 but that doesn't work anymore.I tried Code: [Select]mode con:lines=25 and got desirable results, so I changed it to 50 lines just to see if it was really doing anything and the screen looked totally screwed up - so changed it back to 25 and it looked great. It will be nice to have this in my batch file just to remind the computer EVERY time I run this app. Thanks a lot |
|
| 3382. |
Solve : Cannot delete registry key in Vista? |
|
Answer» On Vista SP2 x64 That reg key seems pretty important, its got Hardware Mapping as the parent root, messing with this is gonna bring up some Hardware errors, you should be careful in Registry. Thanks. The batch as a WHOLE -FIRST exports the key so that it may be IMPORTED back-in after a few processes have been completed. I've got my bases covered. Thanks again. It looks like that is the REG entry for your CD-ROMS. Why do you need to delete it?For legal reasons I probably shouldn't say. All of this, of course, hypothetically speaking. On an off note, I discovered that performing a Code: [Select]reg import xxx.reg >nul will not suppress the "Operation completed successfully" message. Oddly enough "2>nul" does suppress the message. This, odd because that command is USED to suppress standard error, not standard output.Quote from: gregory on May 29, 2009, 06:00:39 PM For legal reasons I probably shouldn't say. All of this, of course, hypothetically speaking.Are you writing a virus? We lock down the campus from our students through a GPO. Are you on an AD domain? Could you use a GPO instead to remove/lock down the CD-ROMS?Quote from: TheHoFL on May 29, 2009, 06:03:45 PM Are you on an AD domain? Could you use a GPO instead to remove/lock down the CD-ROMS? Nope. I'm rather network stupid. I just needed this to work on the one machine, and it is, albeit with the added aggravation of having to elevate usage rights every time. Thanks again. |
|
| 3383. |
Solve : Kill PID IF MemUsage >= 'X' and imageName='Y'? |
|
Answer» Hi Everyone, Firstly thx for reading this and if you can help, please i'd REALLY appreciate it... :-) (I did search for a similar topic but could not find anything) |
|
| 3384. |
Solve : Validation yyyymmdd.txt? |
|
Answer» Hi all, Hey there Hi thanks for your reply, but I've tested it out and it doesn't seem to validate the date properly. Is there any way of doing the validation in the MS-DOS batch program itself?? Yes heres the code: Code: [Select]@echo off :enterdate cls echo Enter date to check(YYYYMMDD format) set /p datein=? set yearin=%datein:~4% set monthin=%datein:~4,2% set dayin=%datein:~6,2% set curdate=%DATE:~4,10% set fulldatein=%yearin%/%monthin%/%dayin% if %fulldatein% EQU %curdate% ( echo Valid date..Begin search pause goto Search ) else ( echo Invalid date, please re-enter date pause goto enterdate ) :Search You can add your file search code after the Search label Hi there Thanks for your post. I have tried your program.. and tried to enter a date like this:20091126 for today but it doesn't seem to work?? What is a valid date for this?when you say it doesn't validate properly, what is the error? show what you have done. Don't just say it doesn't work!!!! You can't really validate a date like that in batch. You have to take care certain things like whether there is a february 29 or not etc... USING vbscript's date check is the simplest way to go. |
|
| 3385. |
Solve : Extracting several zip files in a folder? |
|
Answer» Need help, with a batch file. I don’t want to use another zipping utility, I prefer to use the ONE installed with windows. I am trying to extract several zip files that are located in a specific folder, without knowing the names of the files. See I need to extract the .csv files that are in the zipped files to another location. I will have to do this on a weekly basis and the names of the zipped files will change. If some would please help I would be very grateful. I did see the .VBS script file that was used to UNZIP a file, however I will not know the name of the zipped files.What I am thinking........is that I will need a batch file that will get me a list of the zip files and I can then use that list to extract the documents.Ok I GOT the list of Zipped Files using |
|
| 3386. |
Solve : Check condition & convert no.? |
|
Answer» Dear Experts, |
|
| 3387. |
Solve : installing dos program in XP os? |
|
Answer» How can I INSTAL a DOS program in Windows XP OS ?http://support.microsoft.com/kb/324767 |
|
| 3388. |
Solve : Optimizing ms-dos shell in Win xp? |
|
Answer» Can someone send me a link explaining the options page for ms-dos shell in Windows XP? I can't seem to find one is there anyway I can tell cmd.com to go hog wild Can you simplify the query a little more - are you opening your program in Command.com or Cmd.exe I'm using a shortcut to cmdThat would be CMD.EXE And about your question, you want CMD to just hog up as much RAM as possible or just control it to use a limited or user specified amount of RAM?Quote That would be CMD.EXE I believe you are right - I hadn't payed attention to that detail - If I had the option I would like to try both, but I guess having control over a specified amount would be the way to go. There isn't a option that is made specifically to alter the amount of RAM that CMD uses but you can change the Command Buffer(It holds all the recently entered commands) to a low value, this wouldn't change it by much but that seems to be all that I can think of for changing the amount of RAM that CMD uses. To do this: Right Click on the Title Bar for CMD and hit Properties, a dialog will appear and under a frame that says "Command History" there is the buffer size, just change that size however you want and hit OK. Hope this helps ,Nick(macdad-)I believe that its set to default - size:50 and 4 buffers - what would your recommendation be? higher size? more buffers? less...not sure which way to go. Cmd.exe is a Dos emulator program i.e. it runs in a Window and emulates (copies) the functions of Dos. It is not an operating system in any form ALTHOUGH it looks, performs and sometimes smells like a Dos version. Windows will allocate available resources to Cmd.exe as required/available. Quote from: nitsudm Can someone send me a link explaining the options page for ms-dos shell in Windows XP The syntax for Cmd.exe is here.. Quote from: nitsudm Under the options for an ms-dos shortcut I see "Command History" with "buffer size" and "Number of buffers" under that is a check box "Discard old duplicates". Next to these there are two check boxes for "quick edit mode" and "insert mode" In Command History, Buffer Size and Number of Buffers refer only to the collection and storage of commands which are entered at the Command Prompt, if you don't use such info then ignore the entries. Quick Edit Mode and Insert Mode refer only to the editing modes allowed at the Command Prompt. Open Windows Task Manager Processes tab to see how much ram has been allocated to Cmd.exe and/or your program at any time.Great - I just wanted to make sure that it was taking advantage of all the resources available. Thanks a lotQuote from: Dusty on May 26, 2009, 10:40:07 AM Cmd.exe is a Dos emulator program i.e. it runs in a Window and emulates (copies) the functions of Dos. Isn't that COMMAND.COM? Which runs old 16-bit MS-DOS programs? Where you can edit Config.nt and autoexec.nt? To set EMS/XMS etc? (cmd.exe is the Win32 command interpreter, which looks like MS-DOS but isn't.) I think we need to get this clear. I'm am definitely running cmd.exe from the system32 folder which also contains command.com - I know it's not really dos, but my dos application runs flawlessly when run through cmd. When I run the app through command.com it's performance is choppy at best. They seem to both look identical in appearance and yet I receive different results between the two. Regardless, the emulation works great - the app is fast, I can print to usb, and even open a cash drawer through COM1 - so I'm happy. I'm just trying to tweak it as much as I can to get the best performance out of it - but I think I'm done. I just have a small mapping inconsistency to work out with a network drive and the terminal PC - which I think I may post later to get some help with if I can't work it out myself.To the question "is there anyway I can tell cmd.com to go hog wild with my ram?" My personal answer is no, and I believe many I.T. professionals would agree. You can get alternative "YES" answers if you look for them. GOOGLE gives 265,000 results when searching "ram defragmenter" Google gives 476,000 results when searching "ram optimiser" Both sets of results include "free" products, they also include things to hit your credit card. Google gives 1,2500,000 results when searching "snake oil", and I think that is as useful as the "ram ..." improvers above ! ! ! If you want to make it run faster, I suggest using the Processes tab in Windows Task Manager and clicking on the CPU column so the highest CPU usage is at the top. So long as CMD.EXE is using far more than anything else ( other than "System Idle Process" which merely shows how much is spare - in excess of present needs ) then your program is probably going as fast as its little legs will take it. BUT watch out for any anti-virus or firewall activity, or any "phone-home" internet actions, which may slow down your program, or even delay for authorisation. Quote from: Dusty on May 26, 2009, 10:40:07 AM Open Windows Task Manager Processes tab to see how much ram has been allocated to Cmd.exe and/or your program at any time. Perhaps "how much ram has been allocated" may be misunderstood. To me "allocated" implies a specific reservation for a specified person/purpose, and such an interpretation is totally false in the context of this thread. My credit card statement shows :- The credit limit allocated (which is permanently fixed until they alter it) ; The credit balance available (the more I spend the less is available) ; Credit used total; and each of the items that have been charged. Similarly Windows Task Manager => Performance shows me Physical Memory :- Total 1292720 K (This is a permanent allocation that never changed since I added 1 GB.) Available 810400 K (new different number every other second) Most of the physical memory that is NOT available is in System Cache 396104 (new different number every other second) The rest of what is NOT available is what each of the Processes are using at any instant in time. Windows Task Manager => Processes shows me Commit charge 307M / 1478M (quite stable, but both increased 1% when I launched another instance of Firefox, and both leapt up another 10% when I opened a web-based email account. Windows Task Manager will show many things for each process. For Firefox I did see :- Mem Usage = 98,008 K (twitching up and down) Peak Mem = 116,704 K (stable) VM Size = 85,844 K (twitching up and down) BUT after adding a second instance of Firefox, and launching email Mem Usage = 117,204 K Peak Mem = 123,364 K VM Size = 106,560 K Regards Alan Quote from: Dusty Cmd.exe is a Dos emulator program i.e. it runs in a Window and emulates (copies) the functions of Dos. Quote from: Dias de verano on May 26, 2009, 12:44:02 PM Isn't that COMMAND.COM? Which runs old 16-bit MS-DOS programs? Where you can edit Config.nt and autoexec.nt? To set EMS/XMS etc? Who am I to argue? Following quote from Wiki Quote Technically, cmd.exe is a Windows program that acts as a DOS-like command line interpreter. It is generally compatible, but provides extensions which address the limitations of COMMAND.COM: Quote from: ALAN_BR Perhaps "how much ram has been allocated" may be misunderstood. The important "at any time" has been omitted. Allocated, in this context, is meant to show the ram being used by the process at the time the query is initiated. This value can change as and when other processes are started/stopped.The History Buffer seems like the logical choice here since it stores the previously entered commands in RAM(I believe), but what else could be adjusted to change the amount of RAM that CMD uses? |
|
| 3389. |
Solve : return to for after a call? |
|
Answer» I have a script which is comparing 2 files like this: Since Goto is nested inside For, it can only be used with labels that are also inside that same for loop.goto: nested inside for loop usually used to break a loop when certain condition is met. when to use call or goto: - use call when you want to goto a label and return to the next line after call when it reached a goto:eof statement (exception last line of code) - use goto when you want to goto a label without returning the control to the next line after goto - call statement is also use to run another batch a label can accept argument supplied by both goto or call statement %1 - %9, %* to access allthat's great GUYS! thanks a lot. |
|
| 3390. |
Solve : Ping bat file? |
|
Answer» Quote from: seth001 on April 08, 2009, 07:32:14 AM No, but every time I changed the content of the bat file I didn’t see the change (example I changed the Ip address in 127.0.0.1 but it still goes to www.whatever.com) I personally ping LOCALHOST instead of 127.0.0.1, although they do the same thing (HOSTS file).Quote from: seth001 on April 07, 2009, 03:25:41 AM Hallo, hii there..im just newbe here...hope this will solve your problems. try this code: Code: [Select]@echo off color 0A title PING TEST By DAYWALKERZ echo. echo. :start echo. >> C:\ping\Data.txt echo. TIME>> C:\ping\Data.txt echo Date: %date% Time:%time% *START PING >> C:\ping\Data.txt echo. echo STARTING PING TEST... echo ********************* echo. echo Date: %date% echo Time: %time% ping google.nl -n 4 |find "Request timed out." && (goto A) ping localhost -n 60 >nul goto start :A echo Date: %date% Time: %time% *PING FAILED >> C:\ping\Data.txt ping localhost -n 30 >nul goto start ok here the tips. 1st - make sure that you make empty folder on where ever location on your hardrive that called "ping" example: Code: [Select]C:\ping 2nd - dont put the www infront of the ping site example: Code: [Select]ping google.nl 3rd - do not ping to long...waste a time ... just make short pings only. example: Code: [Select]ping google.nl -n 4 4th - timer for every pings. here i set it for 60 sec every ping.you may set it what ever you liked. example: Code: [Select]ping localhost -n 60 >nul 5th - call or goto, if you call its will popup or runs what you have set.you also may change it what ever you wants. example: Code: [Select]|find "Request timed out." && (goto A) - if you wanna call your file such "time.bat"...just change it to "CALL time.bat".but make sure you already make batch file for "time.bat" and make sure you get it FULL location of it. example: Code: [Select]|find "Request timed out." && (CALL C:\time.bat) sample picture: cmd: log file: hopefully will help you solve your problems.... sorry for my broken language...Quote from: daywalkerz on November 27, 2009, 12:46:27 PM hii there..im just newbe here...hope this will solve your problems. This thread died 7 months ago! |
|
| 3391. |
Solve : Map a drive / change the label(not letter) of the drive.? |
|
Answer» Hello everyone, NET USE U: \\SERVER\SHARE so you have a PC NAMED SERVER with a shared folder named "SHARE"?No. That is just an example. I didn't feel the names were that important in this one. OK. I take it, changing the name of the shared folder, or the name by which it is shared, is not an option either?We would not be able to do this because there are too many users that we would have to change this for. That is why i am looking to change the label for the end USER. |
|
| 3392. |
Solve : Findstr and Find patterns? |
|
Answer» Hi there, Code: [Select]@echo offif there are 1000 "528"s in log1.txt, the code is going to open the file 1000 times to find "username". am i correct to SAY that? A more efficient method is to go through the file once, 1) check for 528, set a flag to indicate found 2) the save the line that contains 528 in memory(variable), 3) check for "username" and if found, print it together with the saved variable. Quote from: gh0std0g74 on November 27, 2009, 02:45:09 AM if there are 1000 "528"s in log1.txt, the code is going to open the file 1000 times to find "username". am i correct to say that? Log1.txt is opened either once or twice. Firstly, the output of type is piped to find and the output of find (if any) is redirected to the null device. If string1 is found at least once then the errorlevel is set zero on COMPLETION and the command on the (logical) right hand side of the && operator is executed, opening log1.txt for the second time. Finally if the errorlevel from the second pass is zero, the output to file is carried out. I just THOUGHT the nested &&s were elegant. Bad habit, I know! Quote from: gd74 A more efficient method is to go through the file once, I agreed until I did some timing tests. See below. Code: [Select]set filename1=log1.txt set filename2=log2.txt set string1=528 set string2=user name = username2 set flag1=0 set flag2=0 for /f "delims=" %%A in ( ' type "%filename1%" ' ) do ( echo %%A | find "%string1%">nul && set flag1=1 echo %%A | find "%string2%">nul && set flag2=1 ) set /a flagT=%flag1%+%flag2% if %flagT% equ 2 echo Strings "%string1%" and "%string2%" found in file "%filename1%">"%filename2%" In fact, you can do all the work in one line, at the cost of opening the input file twice. Code: [Select]@echo off set filename1=log1.txt set filename2=log2.txt if exist "%filename2%" del "%filename2%" set string1=528 set string2=user name = username2 type "%filename1%" | find "%string1%">nul && type "%filename1%" | find "%string2%">nul && echo "%string1%" and "%string2%" found in "%filename1%" > %filename2% I am going to do some timing tests with a 1000 line x 80 char Loret Ipsum text file. Search string 1 is inserted into line 250 and search string 2 is inserted into line 750. Results: 1 pass using FOR loop and flag variables: 4 mins 32 sec 2 pass using type | find>nul && type | find>nul && echo Positive Result>file : 0.33 sec These results were so surprising that I have repeated the test several times. The result: 1 pass around 4 minutes, 2 pass around one third of a second. that's because for every line, its piping to 2 find's. if the use of "find" or "findstr" can be reduced, the better. I am tending toward the use of the if statement. if string1== string2... Isn't there a way to test whether a substring exists using if (or cmd.exe in built commands?) If you do most of this in cmd.exe instead of calling external commands, i think it will be faster.Quote from: gh0std0g74 on November 27, 2009, 07:28:21 AM If you do most of this in cmd.exe instead of calling external commands, i think it will be faster. Well, I think 3000 lines a second isn't bad for a first attempt. Thanks alot guys I'm a newbie with all of this and have to do reports on a security log.. hence all my posts You've been great! Laura |
|
| 3393. |
Solve : delet files and send to recycle bin with a batch file? |
|
Answer» hi |
|
| 3394. |
Solve : DLL x DOS ???? |
|
Answer» Hello, Do you really mean MS-DOS or are you thinking of Windows command prompt? It's MS-DOS, version 6.2. But, if other version of MS-DOS have DLL suports, I TRY it!No DLLs with MS-DOS. As was said before. Why do you think you need to do this? Quote from: Salmon Trout on November 27, 2009, 11:32:16 AM No DLLs with MS-DOS. As was said before. Why do you think you need to do this? Why do I have this legacy system, which runs on many machines. I need to separate the system into modules, so I thought in DLL. If this is not possible, I believe in separate executables, but do not know how I would make communication between the executable.I think that maybe what you are looking for are "overlays". Turbo Pascal and the GFA BASIC as well as good old PDS 7.0 and 7.1 compilers are examples of MS-DOS programming tools that offer overlay support. Overlaying is a programming method that allows programs to be larger than the central processing unit's main memory. An embedded system would normally use overlays because of the limitation of physical memory, which is internal memory for a system-on-chip and the lack of virtual memory facilities. http://en.wikipedia.org/wiki/Overlay_%28programming%29 https://users.cs.jmu.edu/abzugcx/public/Student-Produced-Term-Projects/Operating-Systems-2002-FALL/MSDOS-by-Andrew-Vogan-2002-Fall.doc http://support.microsoft.com/kb/51416 etc etc etc Thank you! You gave me a guideline. I'll study overlay, and I'll post here the result. Thank you very much! |
|
| 3395. |
Solve : Batch file If Statement that looks for date of file? |
|
Answer» We LOAD data daily and WANT to begin the load as soon as file is ready. Each day the same file is REPLACED but the time may be within a two hour window. We are looking for an If statement to include in our batch file that will look for the new date every minute or so within this window. We use Scheduler to RUN the BAT file on Windows XP SP2....Thanks |
|
| 3396. |
Solve : Help needed.. batch commands? |
|
Answer» Hi Gurus, you would probably want an xcopy if there all in the same place. If not it be copy Driveletter:\were it is Driveletter:\Were you want it, I dont follow unless these arent notepad doc's there will be need for more code. I assume that its a doc file, I can only aid this far sorry. kayHi, Thanks for your reply.. It is not doc file. Example: File1.txt : PersonNo Name 1001 Alex 1002 Mac File2.txt : PersonNo Name 1003 Jack 1004 Nick Target.txt : The file where text from File1 & File2 to be copied After copy the the target file shoul looks as below Target.txt PersonNo Name 1001 Alex 1002 Mac 1003 Jack 1004 Nick Is it possible ? Regards, DD i seems to have a batch script to suit your work, i wrote it in the early days when i LEARN scripting, and it's messy code all around, but i've been using it in daily basis until TODAY and too lazy to clean-up the code. when noob like me write a batch code, there is a lot of unnecessary goto and label that i first think it is cool to modulize the coding into function and procedure in OOP TERM. download the attached batch file. how to use: Code: [Select]D:\batch>concat /? USAGE: concat [SOURCE DIRECTORY] [OUTPUT FILE] [HEADERLINENUMBER] [CUSTOMHEADER] D:\batch>concat ?.doc target.txt 1 target.txt not exist done 1.doc = 2 Line(s) done 2.doc = 2 Line(s) Total Files=2 File(s) D:\batch>type target.txt PersonNo Name 1001 Alex 1002 Mac 1003 Jack 1004 Nick [attachment deleted by admin]thanks for the aid, hope this all pains out I was thinking of linux abit sorry there so close to being the same. |
|
| 3397. |
Solve : Alias, the first programming language made in ms-batch. [WIP]? |
|
Answer» Hello people, i am making a programming language CALLED Alias. |
|
| 3398. |
Solve : Closing Batch File Window? |
|
Answer» sorry my thoughts must have been partialy else were at the time. I ment to say that I think were he had his EXIT wasnt in the right part of it. In such I could have ms paint exit it would close after I EXITED paint vs if I some how modified it to be before that. Still learning myself so I cant say if it would work, was a suggestion. Also, I ment if you tell them what do they learn all together. hardly anything.Thanks, Carbon. Unfortunately, in the process you posted, the line "START C:\MULTIPSK\" only opens the directory MultiPSK instead of STARTING multipsk.exe. Also, the batch window still remains open after the batch file is complete. Yes, I see each command as it executes.Try adding @echo off to the beginning of your script. Or, adding PAUSE between each line, so you know if there's a problem within your script.I should have figured that, sorry about that at least you know it WORKS for the most part.Problem solved. Apparently the line START "" "C:\Ham Radio\Launcher\Sound.bat" was causing the problem. Removing the command to start another batch file and putting the commands from that file into this one allows the window to close now. Thanks to those that helped. Thanks, also, to the Department of Sarcasm for the lack of help. |
|
| 3399. |
Solve : Directories? |
|
Answer» I have been at this for hrs looking through books and searching the INTERNET and cant for the life of me find what I need. I need to KNOW the steps I would have to take to make a directory under the root directory using the command line interfaceOk. You MEAN root as in top-level, lile your drive? Simple. Ok. You mean root as in top-level, lile your drive? Simple. yeah. Code: [Select]md \foldername no need for for...Quote from: BC_Programmer on November 25, 2009, 08:20:39 PM yeah. And no need for delayed expansion either (in any script in this thread)Thank you both for your help. OK here's the problem I am having. I have an assignment and the instructor wants me to list the steps it takes to make a directory under a root directory using my COMPUTER which is Windows XP using the Command Line Interface. I know I locate and pull up the command prompt going to Start/Run/ and typing in cmd but no clue what to do next to complete this assignment. Any additional help would be appreciated. Quote from: msj23 on November 27, 2009, 08:14:51 PM Thank you both for your help. OK here's the problem I am having. I have an assignment and the instructor wants me to list the steps it takes to make a directory under a root directory using my computer which is Windows XP using the Command Line Interface. I know I locate and pull up the command prompt going to Start/Run/ and typing in cmd but no clue what to do next to complete this assignment. Any additional help would be appreciated.And this is where we stop. Your instructor should have taught you how, or you were supposed to have learned how. Either way, you should know how to do it, and how it works. Cool thxs...... |
|
| 3400. |
Solve : Batch Help pls!!!? |
|
Answer» I need your help pls.... change the batch file from .bat to .exe with the programa "Quick Batch File Compiler" Take care not to encourage pranks. Winking emoticons raise suspicion about intentions. Quote from: Dias DE verano on May 23, 2009, 07:50:32 AM Why do you want them to be hidden?Because my neibor i belive that he STEALS my wifi internet and i realize this from my modem LOGS all these i thinkbut i'm not sure! many [emailprotected]!!Can you not enable WEP (or even easier) WPA on the wireless router? That will keep your neighbor from accessing your network.Agree with Aegis here...lock down that wireless signal. After all fences are for neighbors...Quote from: Aegis on May 23, 2009, 10:55:38 AM Can you not enable WEP (or even easier) WPA on the wireless router? That will keep your neighbor from accessing your network.It's done!!!!!!! no more neibor here!!!! many thnks!You're welcome! Did you use WEP or WPA? Not required to know -- I'm just curious, if you do. |
|