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.
| 6651. |
Solve : Crystal Report? |
|
Answer» How can I display the last record in the perticular field into the crystal report. I have only FORMULA which is write the formula EDITOR in crystal report. |
|
| 6652. |
Solve : Batch game help? |
|
Answer» I'm working on a batch came thats manly text like say: if co= new goto: new variables have percent signs around them when you want to use their values you use quotes in if tests and double equals signs you don't use the colon when using the label in a goto if "%co%"=="new" goto new It still dosent work I dont know why. It's all those....vertical lines. (I've forgotten what they're called). You cannot simply have '|'. It needs to be '^|' Try it for yourself. Go to Command Prompt and type 'echo |' and press Enter Then type 'echo ^|' and press Enter.Pipes.Oh, pipes? Really? Ok.Yes pipes. What's the problem with that? here is the output of of type being piped (twice) to find: type animal.txt | find "lion" | find /v "sealion" Quote from: Dias de VERANO on December 12, 2008, 12:17:20 AM Yes pipes. What's the problem with that? What's wrong with the pipes? They're not leaking, are they?Yes, the '|'s are the problem, and yes they are pipes, and no they are not leaky. or as some disallusioned players of mario BROTHERS will try to contend, as they do on the game, that they are not "pipes" but rather "tubes"... a somewhat odd theory that will still officially correct is only so because of the basic tenement that a pipe is, by definition, a metal tube. However, calling the mario brothers pipes "tubes" is like calling a pop can a "pop cylinder". That was weird; it went from the pipe character to a rant about the misuse of the word tube in mario brothers vernacular. Oh well. |
|
| 6653. |
Solve : shortcuts? |
|
Answer» How do i change the directory (not sure if thats what its called) of a shortcut? So what i mean by the directory is what happens when you click on the shortcut. thanksQuote from: davisw on April 24, 2007, 02:15:21 PM How do i change the directory (not sure if thats what its called) of a shortcut? So what i mean by the directory is what happens when you click on the shortcut. thanks And I'm not sure of what you meaning to ask. But perhaps you'll be on the right track to your solution, if you look around in the Properties of the shortcut. You forgot to say what operating system this is in reference to.... is it WinXP? ... or....? With older versions of Windows, you can right click on a shortcut, and get a pop up menu. Then click on Properties. Have a look around in there. On my system, there are entries for the Target directory, and for the 'Start in' directory. Maybe one of these is what you are looking for. I HOPE this HELPS. |
|
| 6654. |
Solve : Batch File Question - "Set" Command? |
|
Answer» Can you use the "set" command inside of another "set" command? In my batch file, I've got a list of file names at the top which are intended to trickle down into the processes below, so that it eliminates the need to type them all twice (as they may change often). However, it keeps pulling only the first one out of nine in the final result. |
|
| 6655. |
Solve : Batch File Help Please (resolved)? |
|
Answer» I'm trying to create a batch file to start Punkbuster(an anti cheating software) for a game and exit it when it finished but the game never starts so it just goes to the shutting down PB I'm trying to create a batch file to start Punkbuster(an anti cheating software) for a game and exit it when it finished but the game never starts so it just goes to the shutting down PB Logically, there doesn't seem to be a problem with your code. Why doesn't the game start? Any error messages? Are you sure /restart 1 is correct? restart 1 is a command line so it DOESNT show the movies in the begining. It says its not RIGHT. should it be /+restart 1 since it was + for the command? Also i says it couldnt start pb for some reasonQuote but the game never starts so it just goes to the shutting down PB Quote Also i says it couldnt start pb for some reason So the bottom line is nothing in the batch file works. Change the @echo off to @echo on in your batch file. That may give you some clues what's wrong or post the console list so we can see what's going on. Did you need to modify your firewall to let Punkbuster through? |
|
| 6656. |
Solve : Echo at location...? |
|
Answer» Win XP H. You don't get ansi SUPPORT in NT family command PROMPT under cmd.exe. But it is available under command.com. This may or may not be good NEWS! Definitely not good news. Will have a look at XE. Thanks again. |
|
| 6657. |
Solve : Acces denied in XP, changable in DOS?? |
|
Answer» Hello all, An extra problem is that the name of that folder contains a space Place quotes around the file/folder name. Quote I installed XP on a new PC, that worked for a while until a power failure. I suspect one installation will have to take ownership of the files owned by the other installation. This may help. Good luck. Yes! Thank you for the fast reply, after turning of 'simple file sharing' i got acces to the security tab mentioned in the ARTICLE you linked to. After that the rest was like scratching my nose. You just saved me 5 GB of disk space and some important files! Thank you! |
|
| 6658. |
Solve : select a filepath in dos? |
|
Answer» Does anyone know how to BRING up the contents of a valid file path in DOS. In place of c:, I'm guessing they want the full file path of my files. to cd to a folder which has spaces in the path name ENCLOSE it in quotes thus CD "C:\Path to files\folder" Quote N.B. I've unzipped the files, so all the files (35 of them) are on the c drive. You should not have done that. You need 2 files: (1) an .iso file. This is a CD image. You burn it to a CD. (2) a .txt file. This contains the md5 checksum for the iso file. |
|
| 6659. |
Solve : need help making a simple program? |
|
Answer» I am trying to make a small program (.exe would be great) to close a program. My goal is to create a way to close a program called vkt.exe by running this program. The reason I need this is because the only way to close the program is to right click it in the SYSTEM tray, however for my application I have access to the entire windows desktop closed off. |
|
| 6660. |
Solve : Batch file to fill disk?? |
|
Answer» Is it possible to create a batch file that will fill up all of the unused disk space on a hard drive? If the files could occupy one folder too that would be optimal. Code: [Select]@echo off The first for varies %%x from 1 to 10 incrementing by 1. This is strictly used as a counter and limits the number of iterations. Thanks, Yes, as would using dban or eraser. I just thought having a batch file do something similar would be interesting. Though the missing randomness might somewhat negate the effect. How can I change the path in ('dir c:\temp\ /s /b') to C:\Documents and Settings\username\Desktop\temp\ Everything I try seems to screw up the syntax. Also, I did /? for tokens and delims but I'm still having trouble understanding what they're all about... can you point me to a good place that can break tokens and delims down into simpleton terms? You need quotes when using values with embedded spaces: "C:\Documents and Settings\username\Desktop\temp\" This Site seems as good as any for explaining how a for works. Good luck. Code: [Select]@echo off for /l %%x in (1,1,10) do ( for /f "tokens=* delims=" %%a in ('dir "C:\Documents and Settings\username\Desktop\temp\" /s /b') do ( copy %%a %%a_%%x ) ) I get "the system cannot find the path specified" when I run that. I have a folder named temp on my desktop and it has a file in it. I suspect username is not really your user name: Code: [Select]@echo off for /l %%x in (1,1,10) do ( for /f "tokens=* delims=" %%a in ('dir "C:\Documents and Settings\%username%\Desktop\temp\" /s /b') do ( copy %%a %%a_%%x ) ) I have no idea if the path is CORRECT but at least the syntax is. Right, mine is actually "comp". I have the path absolutely correct, it just doesn't like that path for some reason. Oh well, it RUNS fine from C:\path\ |
|
| 6661. |
Solve : "Cannot move multiple files to a single file."? |
|
Answer» When I execute the command: moving the contents of testy1 (a subdirectory within test1) to test1. Move didn't make a new directory. It moved the contents of one directory to another. I guess I worded that kinda funny, when I said Quote It does: I'm moving the contents of testy1 (a subdirectory within test1) to test1., I meant the directory does exist, not that the command does make directories, because it doesn't. Does that clear that up? Does does even look or sound like a word anymore, because it doesn't to me...You can rename a directory with move: move testy1 testy2 Yeah, it says that when you type help move. The message is the part that has me confused. Anybody have any ideas? (If I'm completely missing the POINT, please make me feel like an idiot )I think you're confoozlicating yourself with all these oh-so-similar folder names. Quote I'm moving the contents of testy1 (a subdirectory within test1) to test1. So when you're going from testy1 to test1, you're going from one directory to its parent directory, you're going up one level. (Look at what you wrote.) This is what you have described as the relationship between the folders testy1 and test1 The command you said you used was this Quote move *.* ..\test\test1\ If executed from testy1, as you have written, the two dots take you up one level, to test1, then into a subdirectory of test1 called "test" (Huh?) then to a subdirectory of that called test1. That's DIFFERENT from what you said about testy1 being a subdirectory within test1! I just tried it and this is what i got Code: [Select] I:\test1\testy1>move *.* ..\test\test1\ Cannot move multiple files to a single file. I:\test1\testy1> To move everything from a folder to the one directly above, which is what you said you want to do, you do this move *.* .. Like this Code: [Select]I:\test1\testy1>move *.* .. I:\test1\testy1\image001.jpg I:\test1\testy1\image002.jpg I:\test1\testy1\image003.jpg I:\test1\testy1\image004.jpg I:\test1\testy1\image005.jpg I just peeked and they are there, in test1. Thanks, I'll give that a try. The reason for the CONFUSING names (you confused me with your recount ) is that I was completing an exercise for a class I'm currently enrolled in. The publishers of the exercise weren't very creative... Thanks for the help, it WORKED. I think you were right when you said I was "confoozlicating" myself with the names, I felt like smashing my head off my keyboard while READING your post . |
|
| 6662. |
Solve : How do I convert from DOS of .img to .iso?? |
|
Answer» How do I convert .img to .iso? These are MS-DOS 6.22. I tried following a guide for MagicISO. It didn't work. How do I use WinImage? I have the free one. Will someone please explain how I do it?Try IMGBurn; not sure of it's conversion capabilities, though.Where did you GET these .img's? Try IMGBurn; not sure of it's conversion capabilities, though. How do I use IMGBurn? Hmm, if it won't work for CD's then why did my other CD's work for me? I would like for the last poster to explain.Firstly, where did you get these .img FILES?Why won't you HELP me with IMGBurn? Fine, then do you have a forum to help? If you don't help then I will post on the official IMGBurn forums.Then I guess you obtained MS DOS 6.22 illegally then.....in which case, we cannot help you.There are different KINDS of img file. Not all are CD images. |
|
| 6663. |
Solve : Multiple Check? |
|
Answer» Okay, say I have a variable, it is a number. Okay, say I have a variable, it is a number. Another way is to use the modulus operator which is two percent signs in a batch or one at the prompt N modulus M means "the remainder left over after N is divided by M" and is zero if N can be divided exactly by M. It is usually abbreviated to N mod M. Thus: 17 mod 4 = 1 and 16 mod 4 = 0 (Any number) mod (4) will equal 0, 1, 2, or 3 at most, obviously. Code: [Select]@echo off :loop set /a number=%random% echo random number=%number% set /a remainder=%number% %% 4 if %remainder% NEQ 0 goto loop echo %number% is divisible by 4 Quote For instance %random%*4 may not be fully divisible by 4 and may be 4.1232424, which is not correct. In batch arithmetic, there are only integers (whole numbers) so that will never happen. The number returned by %random% is an integer between 0 and 32767. So you may need to guard against %random% being zero, (which the code above will do.) Quote How would I produce a series of 5 numbers that are multiples of 4 and then check to see if they divisible by 4. If they are multiples of 4 then they are by definition divisible by 4Thank you, very useful, I will be sure to use this. It is of course, also a lot faster than my method.You can use the modulus operator with %random% to restrict the range of random numbers generated. Since %random% ...returns a number between 0 and 32767, %random% %%N ...returns a number in the range 0 to N-1 so that: set /a number=(%random% %% 20) + 1 ...will provide a random number in the range 1 to 20 Quote from: Dias de verano on December 14, 2008, 01:58:32 PM You can use the modulus operator with %random% to restrict the range of random numbers generated.Yes, I have used this method in my ACE combat engine to randomize damage between the players attack level , thanks for your help once again. |
|
| 6664. |
Solve : Batch + VBScript?? |
|
Answer» Is there way to run VBScript via batch?TRY: |
|
| 6665. |
Solve : Query regarding my backup script ...? |
|
Answer» Hello all, for /f %%i in (%TempFile%) do call %0 CheckNumOfBackups %%i Quote :CheckNumOfBackups This appears to be the code where the message is issued. Does not a call to %0 create a recursion problem? TRY turning echo on to trace what value %%i has. I couldn't find any code specific to Tuesday, only Sunday and Monday. The message is not logical (Only completed 4 of the 3 backups attempted.) so I would try debugging files left over from previous run that shouldn't exist for this run. Quote set Date=%%l-%%k-%%j Suggest not using reserved words or command NAMES for your variables. Results can be unpredictable. Hi SIDEWINDER, Many thanks for the reply & taking the time to peruse the script. I'll take all onboard your comments and have a further look after the New Year starts. In the mean time - have Merry Christmas and a happy New Year. Cheers, Cameron |
|
| 6666. |
Solve : Batch script pipe question? |
|
Answer» HI I am wondering if something like this can be done: say ECHO %USERNAME% returns hitesh And I have a variable hitesh with the value set hitesh=savla I am wondering If I can do this: if(%%USERNAME%% eq "savla") { ....................... } I KNOW this can be done in shell and perl scripts. Can I do this in Batch script. I am thinking maybe using pipe or I have to store this in a file and then read it? If someone can help that would be great. set result=no&call echo %%username%% | find "savla">nul &&set result=yesThis is quite easy .... sort of, using Call : Call Set %USERNAME%=savla The call forces the %USERNAME% to be evaluated and return its content, so the line then is processed as set hitesh=savla To do your test, move the value of the wanted variable to a general one and test that : Call Set %USERNAME%=savla Call set generic=%USERNAME% if(%generic% eq "savla") { ....................... } Graham call echo %%username%% | find "savla">nul && ( ................................ )Thanks for the replies guys. Unfortunately none of the solutions works for me. Neither the assignment to a generic variable or using find. Let me attach a config file and a piece of my code here which will make a bit more sense. Code: [Select]for /f "tokens=1,2 delims==" %%S in (users.cfg) do ( set %%S=%%T ) What I am trying to achieve here is: If you look at the attached file, based on the access level of the user executing the script which could be wither DEV or GSD, I will forward the control to another label. for eg: if (%%USERNAME%% eq "GSD") goto label1 else goto label2 Let me know if you want to paste the entire code here. Keep up the GOOD work!! [attachment deleted by admin]Quote from: hiteshsavla on December 24, 2008, 08:02:58 AM
That code is nonsense. You cannot assign a value to the loop variable %%S with SET like that. Wouldn't want to argue with you sir. But the code works. And I got the solution from this forum only. So let me grab the topic and get back to you.Quote from: hiteshsavla on December 24, 2008, 08:11:17 AM Wouldn't want to argue with you sir. But the code works. I think I see how it works now. This is very interesting. If I am wrong, and the code works as described, then I would be very INTERESTED to see it. Please post on here for my education and maybe I can work further on this problem for you. Unfortunaltely I am unable to find the topic where I got this solution. Maybe sidewinder posted it(No offence to sidewinder, he has been most helpful). But the code works for sure. Here is a working script. you might want to add your username in the users.cfg file attached earlier and try the %%USERNAME%% solution. [attachment deleted by admin]Why not just read the access code from the file? Code: [Select]@ECHO OFF set /p username=input username? for /f "tokens=1,2 delims==" %%S in (users.cfg) do ( if "%%S"=="%username%" set access=%%T ) echo user %username% has access level: %access% if "%access%"=="GSD" goto GSDACCESS if "%access%"=="DEV" goto DEVACCESS echo Error goto end :DEVACCESS echo here is DEV access goto end :GSDACCESS echo here is GSD access :end pause Even better. This works amazing and it has reduced the complications in the code too. Thanks a million sir!! Happy holidays. |
|
| 6667. |
Solve : how to add an entry in autoexec.bat? |
|
Answer» Hi Dears |
|
| 6668. |
Solve : Needing a batch file to delete all files in a folder older than 5 days old? |
|
Answer» Hey I need a batch file to delete all .avi files in a folder older than 5 days old. I looked at the set, for, if commands, and for examples , but so far can't find any examples that help me figure out how to use the commands,I have read the if,for,set/? , but i guess i am to inexperienced to understand without some examples of their uses.... I bought a security camera and see that it will keep me very busy sorting the files out. I don't know if it's possible or not but would appreciate any help... I have no knowledge using the for, set, and if commands... did look through the forums, but didn't find anything that will help me yet, but will keep searching.... any help would be greatly appreciated...Thanks WEW. Homework?Quote I'm running a dell dimension E510 with Processor Intel(R) Pentium(R) D CPU 3.00GHzhomework? don't understandQuote from: DJFLuFFY on August 06, 2008, 06:17:57 AM homework?He thinks this persons query is a school assignment.LOL i need it to delete my logfiles and .torrent files that i don't use Quote from: DJFLuFFY on August 06, 2008, 06:17:57 AM homework? It's code for the paranoia factor. Batch code does not handle date/time arithmetic very well. Dates can be formatted many different ways. The actual format can be extracted from the registry adding overhead to your batch file. Aging files is simple arithmetic provided the current day of month is greater than age factor. When it's not, you may be dealing with multiple past months and their cumulative days. Most scripting languages for Windows have functions to SPECIFICALLY handle dates. Any reason your solution must be batch code? You can simply do a search of the computer for .log .txt and .torrent and then sort them by date. Quote It's code for the paranoia factor.Heh, you will know it's bad when I just ask 'Why' if you have another script that does what i want it is welcome i am a PHP coder so i know the basics for programming but making a Batch is really different Quote from: Carbon Dudeoxide on August 06, 2008, 08:43:17 AM You can simply do a search of the computer for .log .txt and .torrent and then sort them by date. this is how i work now, But it takes a lot of time to do. This little snippet is written in VBScript: Code: [Select]Set FSO = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("c:\scripts") 'point to your directory Set fc = f.Files For Each objFile In fc If fso.GetExtensionName(objFile) = "avi" then If objFile.DateCreated < date - 5 Then WScript.Echo objFile & " " & objFile.DateCreated 'fso.DeleteFile(objFile) 'commented out End If End If Next Save with a vbs extension and run from the command line as: cscript scriptname.vbs The delete function is currently commented out. Script will currently list files to be deleted. When you're ready, uncomment the delete function and comment the wscript.echo line. Good luck Thanks this works really GREAT only i have 2 new problems because i forgot to tell you that it has to do the same with all the folders & subfolders and now i can only select 1 extension by default it's avi. *.* works fine for me Quote from: DJFLuFFY on August 07, 2008, 12:58:09 AM Thanks this works really great But i still can't figure out how to include the subfoldersThe original code from the snippet closet had recursion built in. It took me days, hours, oh alright, a few minutes to rip it out. Should have gone with my gut feeling. Again the delete function is commented. You can activate it when you're satisfied this works in your environment. Be careful, files deleted with this script do not MAKE a pit stop in the recycle bin. Code: [Select]Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("c:\scripts") 'point to your directory Set colSubFolders = f.SubFolders For Each objFolder in colSubFolders ShowFiles objFolder Next Sub ShowFiles(Fld) Set k = fso.GetFolder(Fld) Set s = k.SubFolders Set kf = k.Files For Each objFile In kf If fso.GetExtensionName(objFile) = "avi" then If objFile.DateCreated < date - 5 Then WScript.Echo objFile & " " & objFile.DateCreated 'fso.Deletefile(objFile) 'commented out End If End if Next For Each SubFolder In s ShowFiles SubFolder Next End Sub Thanks again but i get an error when i try to delete files. the echo part works great ps. the recycle bin is for Pussies [recovering disk space -- attachment deleted by admin] |
|
| 6669. |
Solve : using DOS command to change default OEM install?? |
|
Answer» I am in need to install a second WIN XP Pro in the E: PARTITION of the HDD that already has one of it installed in the partition C: but the OEM toshiba installation disk from a WIN XP PRo get me only the OPTION to RESTORE the original default system installed in all default settings ( the default partition is the C:). Please, help me. What to do to install more one OS in partition E: with THIS SAME INSTALLATION DISK without overwrite the OS that is already installed in the default C: partition? |
|
| 6670. |
Solve : Batch Variable require for copying....? |
|
Answer» I NEED a Variable for DOS. I want to copy Links.txt to all drives in a time. What value did you plan on %alldrives% having? It might be easier to do each drive separately in a loop. I saved all in a batch. also changed my paths like this.... Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "G:") do ( copy links.txt %%i:\ ) But not working...Sidewinder, a batch file like that is excessively strong magic for a novice, I think! Quote from: afzaldir on December 20, 2008, 11:15:59 PM
You "fixed" the wrong path.Not Understand Yet. also not working.... Please explain with code. [+path] I want copy links.txt G: and D: Code: [Select]for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "partition"') do ( copy links.txt %%i:\ ) that will copy the file links.txt to each visible logical drive. If you only wanted to copy to G: and D: Code: [Select]for %%p in (D G) do copy links.txt %%p: Or why not just do copy links.txt d:\ copy links.txt g:\ ? Oh come on now, that's too easy This work good: Code: [Select]for %%p in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do copy Links.txt %%p: But first Code is not working yet..... Thanks u all and special BC_Programmer |
|
| 6671. |
Solve : time log for every boot? |
|
Answer» I got a batch that log the windows startup time and date. @echo off The if and the else need to be on the same logical line. Quote i guess the log will have only one line no matter how many times i turning on and off my machine There is no difference traveling the if path or the else path. This may help: Code: [Select]@echo off if Exist C:\startup.txt ( echo %date% %time% >> C:\temp\startup.txt ) Else ( echo %date% %time% > C:\temp\startup.txt ) Good luck. |
|
| 6672. |
Solve : fun with linux? |
|
Answer» does any one know of a Linux emulator that I can call from a 95 boot disk? ok thanks! QED I think. yes we do. I am one of the techs. I was just trying to see if any one knew of a way to boot linux off of a win boot usb. The reason I came to this site is because I have received help with my dos and batch efforts. Up to this point I have not had a bad experience. I do not under stand the comment about software audit policies. And as far as the "OK thanks!" that was in response to your suggestion. SORRY. Crossed wires. It seems to me that if you are looking for a kind of sys admin's USB Swiss Army KNIFE, you should forget Win95 and a long look at MiniPE. Specifically a variant called BARTPE, or you could roll your own. |
|
| 6673. |
Solve : Batch file for text transformation? |
|
Answer» hello |
|
| 6674. |
Solve : .bat or vbs to change modify user template in word 2007? |
|
Answer» Word 2007 |
|
| 6675. |
Solve : execute a query on sybase Database and store back the result in a variable? |
|
Answer» Apologies If this question is not meant for this forum. |
|
| 6676. |
Solve : Solved - "Batch file to give commands to different DOS programs"? |
|
Answer» How to create a batch file that will GIVE commands to different DOS programs.. But the above shown code opens the DISKPART but does nothing more than that. That's because Diskpart is WAITING for commands from the STDIN device which is the keyboard. You should try creating a script file and USING the /S SWITCH with Diskpart. See here.. Thanks. |
|
| 6677. |
Solve : pass a value from a batch file once completed? |
|
Answer» I NEED to pass a parameter (pass/fail or 1/0) from a batch file if a condition is met within it. I think I can do it by creating a registry key and setting it to a 1 or 0. Is there a better or more efficient way to do this? Within my batch file, I look at the errorlevel to determine within the batch file whether it is a 1 or 0. What condition produces a 1 or 0 errorlevel? What action does the batch file take? If you were to put this value in the registry does Labview have a mechanism to read it? Can Labview read arguments on the command LINE? If so, this might work provided Labview knew what the command line data represents. Perhaps Labview can test the condition that produced the 1 or 0 errorlevel and determine for itself what action to take. Post the batch file. It should help us see what direction you're going with this. It works by having Labview read the registry entry. My batch file writes either a 1 or 0 depending on the if statment. It works fine, I just do not like messing around with the registry. I believe what I will do is have the batch file create a .txt file if the else condition occurs and have Labview check to see if the file exists. From checking on this forum and others, this appears the least troublesome way to do it. Thanks again for your help. |
|
| 6678. |
Solve : Check whether a file is empty or not? |
|
Answer» Hi. How can I check whether a file is empty or not? |
|
| 6679. |
Solve : Unusual error when trying to redirect output to a log file.? |
|
Answer» I am trying to copy files from one location to another USING XCOPY (across DIFFERENT servers using UNC Paths) |
|
| 6680. |
Solve : Check several locations in a .vbs script to delete files by date.? |
|
Answer» I found a script on the forums by Sidewinder to delete files by date for a specific location, the code is below and I would like to be able to specify different locations and have it loop through for each location. Either by looking at an external file or by adding something in the current script and listing out each location. Can anyone assist me with this? C:\delbydate.vbs(11, 4) Microsoft VBScript runtime error: Path not found I am assuming it is stating 11 line and 4th character in there is an issue? At that location is the following code. Code: [Select] Set k = fso.GetFolder(Fld)The error is reproducible by entering an invalid directory name in the external file. I added some code for the snippet to crash and burn if a directory from the external file is not found. Code: [Select]Const ForReading = 1 Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("c:\temp\input.txt", ForReading) 'point to correct file Do While f.AtEndOfStream <> True fs = f.ReadLine ShowFiles(fs) Loop f.Close Sub ShowFiles(Fld) If fso.FolderExists(fld) Then Set k = fso.GetFolder(Fld) Else WScript.Echo "Invalid Directory:",fld WScript.Quit End if Set s = k.SubFolders Set kf = k.Files For Each objFile In kf If fso.GetExtensionName(objFile) = "txt" then If objFile.DateCreated < date - 3 Then ' age factor is days WScript.Echo objFile & " " & objFile.DateCreated 'fso.DeleteFile objfile End If End if Next For Each SubFolder In s ShowFiles SubFolder Next End Sub But those directories work fine if I use them in the first script, why would that happen? The paths are UNC name btw not sure if that effects it differently in this version of the script.Your not giving us enough information. Did the last posted version of the script ISSUED an Invalid Directory message? Can you GIVE us an example of what is in the external file? This script has been tested with directories containing embedded spaces and UNC paths, with no problems. Are you STILL getting a VBScript error, or just no results at all? Keep in mind the script is filtering only txt extensions.That was it I was missing a letter in one of the paths, sorry about not giving as much detail. Looks like the script doesn't do anything once it runs into a bad path. Thanks so much for you assistance Sidewinder! |
|
| 6681. |
Solve : Timing a command.? |
|
Answer» Sorry, I know for a fact this has been posted before but I cannot seem to find it. Okay I think this will do it for seconds.Quote from: Dias de verano on December 22, 2008, 03:21:04 PM Quote from: Jacob on December 22, 2008, 01:35:50 PMOkay I think this will do it for seconds. It seems to work, as far as I am concerned. But it may not be correct for other uses.It "works" because the parameters %1 and %2 do not exist. Better is this code. Code: [Select]set time1=%start% set time2=%finish% Also, I do not think you realise that you have destroyed the accuracy of my code? Because you are dividing the millisecond figure by 1000, and because batch arithmetic is integer only, that means that 3999 msec would become 3 seconds for example. I have adjusted the code so that it does not calculate milliseconds, but just seconds. The division is to get rid of the 3, 0's after the time for instance it outputs: 7000. But yes, it is still inaccurate, but that is fine for the purpose that I am using it for. Thanks for all your help.Quote from: Jacob on December 23, 2008, 02:47:54 AM I have adjusted the code so that it does not calculate milliseconds, but just seconds. The division is to get rid of the 3, 0's after the time for instance it outputs: Well, why don't you do it properly, by reducing these multipliers by 1000: like this... Code: [Select]set /a sec1=3600*%hh1%+60*%mm1%+%ss1% set /a sec2=3600*%hh2%+60*%mm2%+%ss2% Then you don't need to divide by 1000. Also, you do know the code will break if the start time is before midnight and the finish time is after? (And therefore measured time interval must be less than 24 hrs) Works perfectly, thanks ever so much, and about the midnight glitch, its fine. |
|
| 6682. |
Solve : Multiple commands once per directory? |
|
Answer» HEY all, I have multiple commands I want to execute. I want to execute these commands once for every directory, starting at the location of the batch file, and walking down the directory tree. It's important that all commands complete for a sole directory before moving on to the next. This, essentially creating a loop at each new directory. Hope that makes sense. For simplicity's sake, lets just call the commands; command a and command b Thanks for the help. @echo off for /f "tokens=1*" %%a in ('dir /a:d ..\ /b /s') do ( cd "%%a %%b" attrib +s +h ) use for /f , the above when put in a batch file will use for /f and dir to search out all directorys starting at the drive root ..\ , the loop uses cd to change to the current directory, then uses attrib to add attributes to everything in that folder, the folder path is stored as a variable , %%a and %%b , %%a %%b combined is the full folder path, if you use %%a or %%b individually you will not get the folder path, for example %%a=C:\documents %%a %%b=C:\document and settings\program files , so for this reason its important to add quotations around %%a %%b so that the full path will be used in certain commands ,its also important to notice that "%%a %%b" doesnt include the final slash needed, so if you WANTED to copy a file .. copy "%%a %%b\file.txt"Thanks diablo416. That solved my problem and I learned a couple of tricks in the process. Thanks again.Crap, ran into a problem USING the code. Here's a snippet. Code: [Select]@echo off setlocal enabledelayedexpansion for /f "tokens=1*" %%a in ('dir /a:d /s /b') do ( cd "%%a %%b" set group.counter=1 : group.loop for /f "tokens=!group.counter! delims=," %%c in ("%group.string%") do set group.name=%%c ) pause It produces this: Code: [Select]!group.counter! delims=," was unexpected at this timeMultiple times depending on how many sub-directories there are, which is expected. What's wrong?Well I solved the problem by putting quotes around the [tokens=] in the second [for /f] command. I don't understand why they would have to be there, if the [group.counter] variable is always a value containing no spaces....continuing the conversation with myself The quotes around [tokens=] did not work after all, tokens simply got set to [""], der It seems that no matter what I do, a variable that is set within the first [for /f], cannot be called within the second. Code: [Select]for /f "tokens=1*" %%a in ('dir /a:d /s /b') do ( set var=1 for /f "tokens=!var! delims=," %%c in (%some.var%) do set group.name=%%c ) If I use [!var!] then I get:Code: [Select]!var! delims=," was unexpected at this time It doesn't seem the [!!] are processed. If I use [%var%] then I get:Code: [Select] delims=," was unexpected at this time Note the leading space. The variable value was not transferred, leaving an empty [tokens=], hence that error. Can someone please try this, or tell me why this does not work? Thanksk i fixed the errors , but i cant figure out what this batch is suppost to do? there must be more to it then this? @echo off setlocal enabledelayedexpansion for /f "tokens=1* delims=," %%a in ('dir /a:d /s /b') do ( cd "%%a %%b" call set group.counter=1 for /f "tokens=%!group.counter!%*" %%c in ("%group.string%") do set group.name=%%c echo %group.string% ) pauseThanks again diablo416 There is more to the batch, much more, but there is no need to add confusion. The problem exists in this small snippet of code, which I simplified slightly in my last post. Try running the code below, both the WAY it is, and what you had DONE when you made [!var!] --> [%!var!%]. They both return errors. The task here to accomplish seems simple; set a variable within the first [for /f], then call it within the second [for /f]. If you leave echo on, you can see the variable is never transferred into the second [for /f]. I don't know what I'm doing wrong or if it just does not ever work. Code: [Select]for /f "tokens=1*" %%a in ('dir /a:d /s /b') do ( set var=1 for /f "tokens=!var! delims=," %%c in (%some.var%) do set group.name=%%c )This, on the other hand, works fine. Take the variable outside of the [for /f] and it works. It's not where I need it however. I've decided this cannot work, unless someone can tell me otherwise. Code: [Select]setlocal enabledelayedexpansion set var=1 for /f "tokens=1*" %%a in ('dir /a:d /s /b') do ( for /f "tokens=%var% delims=," %%c in (%some.var%) do set group.name=%%c ) pause |
|
| 6683. |
Solve : batch to run certain apps on start up? |
|
Answer» hi, im on a windows NT here, its a slow pc, everytime when i start it, takes sometime to load up |
|
| 6684. |
Solve : notepad? |
|
Answer» Hi friends.. |
|
| 6685. |
Solve : How can i copy one file to StartUp? (in batch file)? |
|
Answer» for EXAMPLE i want copy 1.txt to startup and i dont KNOW user profile ... |
|
| 6686. |
Solve : increment a variable? |
|
Answer» Is there a way to INCREMENT a variable in a BATCH file such as the way its done in C? (tick++ or ++tick) |
|
| 6687. |
Solve : DOS limitations? |
|
Answer» I've been trying to copy a folder and group of subfolders from C:\program_files to another hard drive. The first folder and several layers of subfolders copy fine, but the deepest subfolders aren't copied. When I tried to view that subfolder using DOSSHELL or DOS Navigator, neither can open it. I can open it fine in Windows or Linux. Is there a depth limit on subfolders DOS can access or a limit to the number of characters in a path? Is there some place these and similar limits would be documented? I've tried searching Google but apparently I'm not using the correct search terms.http://www.google.co.uk/search?num=100&hl=en&safe=off&q=dos+path+max+length+characters&btnG=Search&meta=&aq=f&oq= I'm using Windows 98SE. The program files directory uses the standard windows given name. I am booting to real DOS with a bootdisk. The actual path as copied from the Windows address bar is: Try using double quote marks around the path that you describe. copy C:\Program Files\Connectix\Virtual PC 5.1 Online Installer\Installer\program files\Connectix\Connectix Virtual PC c:\some_dir will not work. copy "C:\Program Files\Connectix\Virtual PC 5.1 Online Installer\Installer\program files\Connectix\Connectix Virtual PC" c:\some_dir should. Experiment with it a bit. You'll get the idea quick enough. I hope this helps.Quote from: still_learning on December 16, 2008, 07:51:40 AM I'm using Windows 98SE. I am booting to real DOS with a bootdisk. The explanation is that you are using MS-DOS version 7. All versions of MS-DOS limit a file name including path to 80 characters. The path+filename you quoted is 113 characters LONG. Quote All versions of MS-DOS limit a file name including path to 80 characters.That explains it. Even using truncated names, some of the subfolders still push the length to over 100 characters. I'm familiar with 3RD party drivers that overcome the long file name limitation. Does anyone make a driver, modified file, etc that will raise this limitation? Do any of the other versions of DOS (FreeDOS, 4DOS, etc) have higher limits?I think this is a limitation of all versions of MS-DOS and the other non-MS "DOS" variations. Anyway, that doesn't mean you can't get to the folder you are interested in and perform operations on the files therein. You don't have to use the FULL path, you can just CD from folder to folder down the path until you get there. Or go part way until the path remaining is less than 80 chars |
|
| 6688. |
Solve : How to get rid of the "Novell Login" dialog box?? |
|
Answer» Dear all, I doubt you can. Batch code cannot mimic key presses or mouse clicks. What about echo. echo Y etc? Hy Guys, I wanna thank you all for your time, but I must congratulate "erobby" for his tip. It works just perfectly. Once more, thank you all for your help. Gustavo |
|
| 6689. |
Solve : running Visual studio Command prompt or XSD.exe from a batch file.? |
|
Answer» Can someone help me with a way (or script) to run a visual studio command PROMPT or XSD.exe tool to convert an XML file to XSD and later to a .Net class (using C# lang). I want to write a .bat file that runs this tool (VS command prompt or XSD.exe) with suitable parameters and convert an xml (from a location of a file) into a xsd and then into a class. Any help would be APPRECIATED |
|
| 6690. |
Solve : create vbs to add text to start of each page of word? |
|
Answer» Can some HELP me change the FOLLOW vbs script to add the text "start" and "end" to each PAGE of an existing multiple page doc. |
|
| 6691. |
Solve : I need help with this batch? |
|
Answer» I'm working on securing the batch files from being edited |
|
| 6692. |
Solve : Need to process all the files in the folder using DOS?? |
|
Answer» Hi Friend, |
|
| 6694. |
Solve : findstr and echo count of rows? |
|
Answer» Hello, |
|
| 6695. |
Solve : FINFO - A easy to use program for batch? |
|
Answer» And heres the NEW version of FINFO, with error checking, not hidden 'setvars.bat', and redited Read-Me My computer might be stupid... No utilities I've tried so far work... As my PvP did not work for you either. yeah that too. But some things like timestreamer and EDS work. doesn't make sense if you ask me.gamer, you had to put the path in quotes like so Code: [Select]finfo "C:\Temp\test.txt" /R and the variables are returned to a batch file in the current DIRECTORY of the batch file or Command PROMPT, so get those variables with Code: [Select]call "setvars.bat" of course this isnt needed if no switches are used. and after you call setvars.bat, you can echo the variables, the variables are as follows: %size% is the variable when the /S SWITCH is used %createdate% is the variable when the /D switch is used %readonly% is the variable when the /R switch is used and only one switch may be used at a time hope this helps ,Nicki got it. if i dont use a switch it works fine. otherwise nothing. |
|
| 6696. |
Solve : set path to javac. javac not working? |
|
Answer» I've installed Java SDK 1.4.2. It has installed properly and working all well. But the problem is that everytime I've a compile a ".java" file, I've to first set the path to the bin folder and after that the "javac" command works and of course all other BUILT in commands of DOS i.e. "edit", "RENAME", stop working and only "javac" works. When I close and reopen MS DOS, the same is the case. i.e. i again have to set the path to the bin library of java. I am using windows 98 (not sure about the dos version). I also typed the following code in autoexec.bat and saved it: You need to reboot Win98 for any changes to either config.sys or autoexec.bat to take effect. Quote I've to first set the path to the bin folder and after that the "javac" command works and of course all other built in commands of DOS i.e. "edit", "rename", stop working and only "javac" works. When I close and reopen MS DOS, the same is the case. i.e. i again have to set the path to the bin library of java. The Java install should have added the bin directory to your path automatically. By setting it yourself, you may have wiped out the EXISTING path. You should have set it as: Code: [Select]set path=%path%;c:\j2sdk1.4.2_19\bin Not finding edit would explain that the standard SYSTEM path got wiped, but not finding rename is puzzling as it's an internal command. Your profile says WinXP in which case this post is rendered obsolete. |
|
| 6697. |
Solve : Guidance to making an Adventure game using batch?? |
|
Answer» Hello, |
|
| 6698. |
Solve : .Bat to create nest of folders? |
|
Answer» I need to .bat file to create a nest of folders Main folder to be created in a location using tomorrows date Contained within a folder called: Mail191208 (Mailddmmyy) with tomorrows date year to shortyear Contained within that folder 3 other folders This folder containing 3 other folders with specific names mail1 mail2 mailrun This what I got so far not working as I entended @echo off cls :: Create/run vbs file (extracts date components) & set variables.. :: set vb=%temp%\newdate.vbs echo Newdate = (Date() ) > %vb% echo Yyyy = DatePart("YYYY", Newdate) >> %vb% echo Mm = DatePart("M" , Newdate) >> %vb% echo Dd = DatePart("D" , Newdate) >> %vb% echo Wd = DatePart("WW" , Newdate) >> %vb% echo Wn = DatePart("Y" , Newdate) >> %vb% echo Ww = datepart("W" , Newdate) >> %vb% echo Wscript.Echo Yy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn >> %vb% FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do ( set Year=%%A set Month=%%B set Day=%%C set Week#=%%D set Weekday#=%%E set Day#=%%F set ShortYear=%%Z ) del %vb% If %Month% lss 10 set Month=0%Month% if %Day% lss 10 set Day=0%Day% set Today=%Day%%Month%%Year% for /f "Tokens=%Month%" %%A in ( "January February March April May June July August September October November December") do ( set Alfamonth=%%A ) set Filename="\%Year%\%Alfamonth%\%Today%" echo Source path\ echo filename = %Filename% echo. echo Today = %Today% echo Year = %Year% echo Alpha month = %Alfamonth% md c:\test\%Year%\%Alfamonth%\%Today% md c:\test\%Year%\%Alfamonth%\%Today%\mail\%%E\%%B\%%Z Its creating the folders as follows: C:\test\12\511812\mail%%E require C:test\December\mail191208right got it part working still trying to create the folder mailddmmyy (spefically with date yy) C:\test\2008\December\18122008\mail\%E\%B\%ZHi Got it to work but have to enter the year manually. How can I convert %Year% instead of YYYY to YY for example if %Year%=2008 set Year=08 if %Year%=2009 set Year=09 Current working code.. @echo off cls : This file should be saved as .bat, and when run will create a copy of the outgoing mail to the given DESTINATION as PER code :: Create/run vbs file (extracts date components) & set variables.. :: set vb=%temp%\newdate.vbs echo Newdate = (Date() ) > %vb% echo Yyyy = DatePart("YYYY", Newdate) >> %vb% echo Mm = DatePart("M" , Newdate) >> %vb% echo Dd = DatePart("D" , Newdate) >> %vb% echo Wd = DatePart("WW" , Newdate) >> %vb% echo Wn = DatePart("Y" , Newdate) >> %vb% echo Ww = datepart("W" , Newdate) >> %vb% echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn >> %vb% FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do ( set Year=%%A set Month=%%B set Day=%%C set Week#=%%D set Weekday#=%%E set Day#=%%F ) del %vb% If %Month% lss 10 set Month=0%Month% if %Day% lss 10 set Day=0%Day% set Today=%Day%%Month%%Year% for /f "Tokens=%Month%" %%A in ( "January February March April May June July August September October November December") do ( set Alfamonth=%%A ) set Filename="\%Year%\%Alfamonth%\%Today%" echo Source path\ echo filename = %Filename% echo. echo Today = %Today% echo Year = %Year% echo Alpha month = %Alfamonth% echo Day=%Day% echo Month=%Month% md c:\test\%Year%\%Alfamonth%\%Today% md c:\test\%Year%\%Alfamonth%\%Today%\mail%Day%%Month%"08" |
|
| 6699. |
Solve : Notepad Switches? |
|
Answer» What are the available msdos command line switches for notepad? |
|
| 6700. |
Solve : locked out of DOS? |
|
Answer» Please Help!!! |
|