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.
| 3501. |
Solve : Read a particular word using DOS?? |
|
Answer» Hi, |
|
| 3502. |
Solve : Batch File to read individual lines of .txt document? |
|
Answer» I've written a basic batch file to read a directory and output all the files into another .txt. file. Is their anything wrong with the way I tweaked it? Not a thing. Any TWEAK that works is a good tweak. Code: [Select]@echo off cd /d C:\Program Files\Thunderhead35 pause for /f "tokens=* delims=" %%v in ('dir /b "C:\Production Change Actions\Input"') do ( Thunderhead.Importer.exe -user domain\username-conflict overwrite -verbose -file C:\Production Change Actions\Input\\"%%v" ) pause Could you explain what some of this actually means? I guess the for and do are where I'm lost on what this is actually doing. Tokens=* delims=nothing??? why is the variable %%v??? I'd like to understand this so I don't have to ask a similar question later. Thanks.tokens=* tokens=2* defines 3 variables (tokens) tokens=1* defines 2 variables tokens=* defines 1 variable Could I have used tokens=1? Yes! Go figure! delims=nothing the default delimiters are tab and space; overriding with no delimiters avoids dropping data when file names have embedded spaces why is the variable %%v??? Why not? The variable declared can be any lower or upper case letter. Numerics can be used, but are easily confused with command line arguments. Using the tokens=, delims= and the declared variable, each for statement is constructed specific to the data. The for command is highly nuanced. These sites are MUCH more eloquent than I could be. Iterating with FOR FOR Thank you for your assistance. It is greatly appreciated. |
|
| 3503. |
Solve : call bat file inside batch file.? |
|
Answer» I USED to do following flow in batch file |
|
| 3504. |
Solve : reformat a string? |
|
Answer» Hi |
|
| 3505. |
Solve : FTP Question? |
|
Answer» Hey guys, i've GOT a question. Say you have a website, which has an FTP server; now in that FTP server i would LIKE to replace index.html for one DIRECTORY inside my FTP server. Would it be possible to if you used the del and send commands while connected? Thanks, Clipper34.yes, you can just CD to the directory, send a delete command , use put to send your new file. |
|
| 3506. |
Solve : Get current folder name? |
|
Answer» Hi all, Try this but not been tested with LFN or spaces in directory names. doesn't work on folder with spaces. Just returns the part after the last space, e.g. "folder name with spaces" shows up as "spaces". These modifications made it work plus I trimmed unnecessary code @echo off for /f "delims=" %%b in ("%cd%") do set fold=%%~nb echo %fold% Thanks alot Hey guys, the ~nx example seems to work fine until I come across a folder with an ampersand (&) in it. (Btw, the ~nb example does NOT work correctly if there are any periods in the folder name--it always cuts off EVERYTHING after the last period. The ~nx method works fine with periods THOUGH.) To test it, make a folder called This.is.{ –a ]} crazy.test,}—folder #.[@mad(symbols)!='%^- The ~nx works fine on that. Now rename the folder, adding a & symbol anywhere in the folder name, and you get "........blah blah blah....... is not recognized as an internal or external command, operable program or batch file." Any way around this?Quote from: AVP on September 15, 2008, 10:43:00 AM Hey guys, the ~nx example seems to work fine until I come across a folder with an ampersand (&) in it. Try quoting the string. E.g. Code: [Select]set fold="%%~nb" The ampersand character is called, in NT batch scripting circles, the 'poison character'. This is because it is used in the batch LANGUAGE as a command separator. In a batch, this: Code: [Select]cls&echo %date%&echo %time% is processed as if it were this: Code: [Select]cls echo %date% echo %time% So, therefore, this: Code: [Select]set fold=Mom&Dad is treated as if it were this: Code: [Select]set fold=Mom Dad and the result is a message saying this: Code: [Select]'Dad' is not recognized as an internal or external command, operable program or batch file. The above solution may not always work in every situation, and a good policy is to avoid using control characters in file names, (or learn VBscript!) Thanks Dias -- the quotes do allow the ampersand. I think this will work for what I need, but if I did need the quotes removed later, am I stuck? Btw, yes, I wish I could control what people are naming their folders, but sometimes they do PUT ampersands in them. Is there a way to rename the folder that has a ampersand into a + instead? Maybe with SET foldernew=%foldername:&=+%You can generate a VBscript and then call it to replace ampersands in a string Code: [Select]@echo off setlocal enabledelayedexpansion echo Set oArgs=WScript.Arguments>%temp%\deAmp.vbs echo MyString = oArgs(0)>>%temp%\deAmp.vbs echo Wscript.echo (Replace (MyString, "&", "+"))>>%temp%\deAmp.vbs for /f "delims==" %%A in ('dir /b') do ( set filename="%%A" for /f "delims==" %%R in ('cscript /nologo %temp%\DeAmp.vbs ""!filename!""') do set deampname="%%R" ren !filename! !deampname! ) Quote from: AVP on September 15, 2008, 11:59:37 AM if I did need the quotes removed later, am I stuck? The ~ variable modifier, used by itself, dequotes a quoted string, and leaves an unquoted string unchanged. Code: [Select]set quotedstring="a string with quotes" for %%S in (%quotedstring%) do set unquotedstring=%%~S echo %unquotedstring% Thanks for all your help Dias! I may also throw up a message that tells the user "hey, stop using ampersands in your folder names" you can get current working directory and its parent folder and current folder name in vbscript Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell") Set objFS = CreateObject("Scripting.FileSystemObject") strCurrentFolder=WshShell.CurrentDirectory WScript.Echo strCurrentFolder 'Get parent folder WScript.Echo objFS.GetParentFolderName(strCurrentFolder) 'Get current folder name WScript.Echo objFS.GetFolder(strCurrentFolder).Name |
|
| 3507. |
Solve : Improper DOS Shutdown? |
|
Answer» I am using DOS on some old legacy TEST stands, and there has been some "heated" arguments as to WHETHER there is a "proper shutdown" methodology. I say that you should exit out of the running program to the "DOS Prompt" and then shutdown the system. Others say it makes no difference in DOS and just shutdown. |
|
| 3508. |
Solve : Execute a Command line entry from a batch file? |
|
Answer» OKAY, firstly I am doing this to MAKE things go faster for my classwork with a program called OSP2 (remembering the command for it is the thing I'm trying to avoid). I am PLANNING on having this in the program's directory, and the USER can enter two arguments, a sub directory and a specific jar file to use. The jar file I would like to default to demo.jar if none is entered. Below is what I'm thinking so far from other guides on the site. The actual command when in the prompt is: Code: [Select]java -classpath .;demo.jar osp.OSPand is typed in the specific projects folder in the command prompt to get the desired result when using demo.jar. I would like argument one to be the specific project name (the subfolder under projects to go into prior to executing the command) and the second argument to be the jar file name used in the command itself), if the second argument is not GIVEN, assume it is "demo." I am using this on Windows XP Computers. Code: [Select]cd projects/%1 if(%2) GOTO CUSTOM java -classpath .;demo.jar osp.OSP goto END :CUSTOM java -classpath .;%2.jar osp.OSP :END |
|
| 3509. |
Solve : File moving batch file? |
|
Answer» My skill when it comes to DOS and batch files is pretty limited. I have a solution for my particular task, but I know it's fairly clunky. I think what you want is a batch file the will live on and on. This is exactly what I'm after. http://www.computing.net/answers/programming/mid-or-substr-batch-simulation/14516.html Doesn't seem to be 'pure' DOS but would seem to work. I've also seen some examples of substrings used as variables - which would seem capable of doing what I want. But I've no idea how to approach it. But while I suck at DOS, I'm relatively comfortable with VB and I think I can write some simple script to rewrite the batch file every time a new folder is added. This would let me keep the batch file simple (i.e. a list of MOVE's). I think I'll have a go at this first and see if I can pull it off. |
|
| 3510. |
Solve : Create a file using MS Dos? |
|
Answer» Hi, |
|
| 3511. |
Solve : Find the row location of a text? |
|
Answer» Hi, the word "Application" in the first row. I will work on this tomorrow. In the meantime, you should know that the correct word is "line", not "row". for /f "tokens=1*" %a in ('findstr /M /I Application *') do move %a %systemdrive%\yourfolder\%a ok , the command you want is findstr , using the /M switch to display only the filename of the files that contain a match , using the /I switch to signify that is not case-sensitive, Application is your search term, * signifys all files in the current folder , using the FOR Command , with the /F switch .. , you are looking for %a in the output of findstr /M /I Application * the next part.. of the output that is a match, move %a (the matching output filename) to %systemdrive% witch is normally C: , \yourfolder\%a , %a is the filename.. so if you had a file with Application in it called myfile.txt , %a would equal myfile.txt , so the above will copy all matching files with Application Written in it, its important to remember.. using %a in a batch file would need an additonal percentile symbol so instead in a batch file the command would look similar to this.. for /f "tokens=1*" %%a in ('findstr /M /I Application *') do move %%a %systemdrive%\yourfolder\%%adiablo, the OP specified that "application" should be in the first "row" (line) in order for the move to happen, and in FACT gave examples illustrating that if "application" was present in a file, but not in the first line, then that file should not be moved. hello everyone, thank you for helping me out. Yes, the word "Application" should be in first line in order to move the file. Any ideas on how I can accomplish that? Your post seems to have gotten lost in the shuffle. This may help you out: Code: [Select]@echo off setlocal enabledelayedexpansion for %%i in (C:\Misc\*.txt) do ( set /p var=<%%i if /i !var!==Application move %%i C:\Misc\Option\%%~nxi ) You didn't mention an extension for your files. The code uses .txt, but it can be changed. thanks Sidewinder, I tried using your code but it didn't work. I created a bat file with your code. Am i doing something wrong?Quote I tried using your code but it didn't work. I created a bat file with your code. Am i doing something wrong? Hard to tell from here. Did you re-type the code or copy/paste it? Any error messages? What are they? What extensions do your files have? The code was tested and checked out on a XP machine. Should run easily on Win2003. Try removing the @echo off line from the batch file. You may be able to debug yourself or post the console output and we'll take a look. PS. I tested with the FileA and FileB exactly as you posted. Is that not correct?hi sidewinder, I tried to use your code in the command prompt but the file transfer doesn't work. Here is your code modified for command prompt: C:\misc\test1>for %i in (*.txt) do (set /p var=<%i if /i !var!==Application move %i c:\va\%~nxi) Here is what I get in the command prompt window on running the above code: C:\misc\test1>(set /p var= if /i !var!==Application move testing.txt c:\misc\t esting.txt 0if /i !var!==Application move testing.txt c:\misc\testing.txt C:\misc\test1>(set /p var= if /i !var!==Application move testing2.txt c:\misc\ testing2.txt 0if /i !var!==Application move testing2.txt c:\misc\testing2.txt It looks like the code is unable to identify if the word "Application" is in the first line or not.I KEEP telling myself to be more precise. The posted code was not meant to be run at the command prompt. It was DESIGNED as a batch file. Quote I created a bat file with your code.So what happened when you ran the code as a batch file? Code: [Select]@echo off setlocal enabledelayedexpansion for %%i in (C:\Misc\*.txt) do ( set /p var=<%%i if /i !var!==Application move %%i C:\Misc\Option\%%~nxi ) You should be able to copy and paste the code into your favorite editor. Save the script with a bat extension and run from the command prompt as scriptname.bat thanks Sidewinder, this code worked. Now what if I had the same file but the first line had multiple columns separated by a tab how would we have to modify the code. e.g. Application3586NameTgi How would I change the code to use this? Your code is extremely helpful. A big thanks once again. As written, var takes on the value of the first line of the file, including the spaces. This works if application is always the first word and starts in the first position: Code: [Select]@echo off setlocal enabledelayedexpansion for %%i in (C:\temp\*.txt) do ( set /p var=<%%i set var=!var:~0,11! if /i !var!==Application move %%i C:\temp\Option\%%~nxi ) If you are scanning the line for the word application in any position, you'll need to set up a loop within the for loop to do the scan. There are other scripting languages that make this easy. Batch code, not so much. thank you thank you thank you Sidewinder. Your code did exactly what I was looking for, thank you so much for all your help. It works just fine. |
|
| 3512. |
Solve : Lock? |
|
Answer» Hi, |
|
| 3513. |
Solve : AOA - Help %Random%? |
|
Answer» As you well know %random% creates a random number between 0 and 32767. If you want the value of %random% to be the same for both formulas, save it and use the saved value in the second formula. Nope, I want them to be different. It all appears to work fine now, so thanks for your help anyway. EDIT: it still has the same problems but it will have to do. as it is roughly fair now anyway.The reason why you are not getting the correct random numbers is because you are not doing the right arithmetic. To get a random number between 1 and 100 you use the modulus operator % thus: set /a var=(%random% %% 100) + 1 Notes: (1) % = modulus (or mod) (N mod M) = the remainder on integer division of N by M (2) To use a percent sign ("%") in a batch file you need to 'escape' it with another one. (To get the effect of % you use %%). Code: [Select]set /a OppDamage=(%random% %% %0Attack%) + 1 set /a Damage=(%random% %% %Attack%) + 1 set /a CHealth=%CHealth%-%OppDamage% set /a OCHealth=%OCHealth%-%Damage% CLOSES the bat file.well im always doeing this like : Code: [Select]%random%%%%var%+1 and it worksI think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number. Quote from: Dias de verano on September 14, 2008, 04:00:16 AM I think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number. Thanks but it is a capital o not a 0.Quote from: devcom on September 14, 2008, 03:58:42 AM well im always doeing this like : That works brilliantly, thanks to both of you you will receive credits.Quote from: Jacob on September 14, 2008, 04:04:21 AM Quote from: Dias de verano on September 14, 2008, 04:00:16 AMI think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number. It is definitely a ZERO. This is the code YOU posted, shown in monospaced font where zero is different from capital 0. Quote from: Dias de verano on September 14, 2008, 04:13:06 AM Quote from: Jacob on September 14, 2008, 04:04:21 AMQuote from: Dias de verano on September 14, 2008, 04:00:16 AMI think that 0Attack may be a bad choice for a variable name. Set /a interprets values (including starting with a zero as an octal number. Thank you, well it's not meant to be, because it stands for opponents attack. Thanks for pointing that out. I have given you credits in the AOA post.Quote from: Jacob on September 14, 2008, 04:14:48 AM well it's not meant to be Those words are written on the gravestones of many many crashed PROGRAMS... Quote from: Dias de verano on September 14, 2008, 04:16:29 AM Quote from: Jacob on September 14, 2008, 04:14:48 AMwell it's not meant to be Lucky I have you. |
|
| 3514. |
Solve : Why does batch file not launch the next command?? |
|
Answer» Hi, mvn clean install && copy target\a.jar D:\srv\app /y/v |
|
| 3515. |
Solve : ftp via .bat not cmd.? |
|
Answer» FIXED myself. Code: [SELECT]@ECHO off FTP.EXE -s:script.txt needed the .exe for some REASON. |
|
| 3516. |
Solve : Create Directory with combined name? |
|
Answer» Hi, |
|
| 3517. |
Solve : Dos attacks?? |
|
Answer» Hi, My English is not very good No, and carbon check out my AOA post please. Alot of updates. I have read it so i want to know what it is And i have seen a command for that beforeWhere? Also...What are your intentions.... What are intentions? And i have read it by a topic on this site Something with: hacking NT Quote from: Larssie111 on September 13, 2008, 07:21:06 AM And i have read it by a topic on this site Eh? |
|
| 3518. |
Solve : Remove dir under XP? |
|
Answer» Hi, The case remove my_dir and re-create my_dir is already in use. But this is not so comfortable. If I'm observing content of my_dir through the "Windows Explorer", after remove my_dir "Windows Explorer" will be always closed and I have to open it again to further observation or I must always go into the parent directory in Windows Explorer, before my_dir will be removed. If you are trying to remove files/directories why are you accessing the directory in explorer? As long as you're in explorer, why not do the deletions there? It would be a lot safer as explorer can send files/directories to the recycle bin whereas batch scripts do not. Because in batch file I can INSERT several commands and with Windows Explorer I can only do one thing at the same time. |
|
| 3519. |
Solve : Time stamp? |
|
Answer» Hello, |
|
| 3520. |
Solve : varibles in batch file .? |
|
Answer» Ex. code in c for apending valuse in varible is |
|
| 3521. |
Solve : network and servers? |
|
Answer» I Am not GOOD in dos commands, but I WANT to make a BATH file that can do the following ( if it is possible). |
|
| 3522. |
Solve : How do I get the Time since the computer started ?? |
|
Answer» He does not explicitly state that he "wants to know uptime". He wrote... I believe Windows has a mSec counter timer ... Is it possible (and how) for a batch file to also access this Windows timer ? The way he talks about "accessing the timer which starts from zero at system startup" makes me think that he wants to access the system time more than once, for comparative or record-keeping purposes rather than merely to see how long the computer has been running. ALAN_BR, you can do away with all that systeminfo stuff. Using VBscript, you can access an uptime counter with a resolution of 10 mSec and you can get the reading into a variable in a batch file. This script should either go in the same folder as the batch file or be placed in a folder that you name in the batch file. In my example batch I placed it in C:\utils. If it is in the same folder as the batch you can just use the bare filename. VBTimer.vbs Code: [Select]Wscript.Echo FormatNumber(timer*1000,0,0,0,0) Access it in a batch file like this: Example.bat Code: [Select]@echo off for /f "delims=" %%U in ('cscript //nologo c:\utils\VBTimer.vbs') do set /a uptime=%%U echo Uptime is %uptime% milliseconds Output: Code: [Select]S:\Test\Vbs>Example.bat Uptime is 47485300 milliseconds S:\Test\Vbs>Dias - I'm out.Hi Please note that 1. I was not offended by any comment therefore I really do not need any apology; 2. I have quite a thick skin, and a very well developed sense of humour; 3. Even if I was offended I would not stay away. My son still tries to convert me to Vista. You are like the family and friends I NEVER had - you know and use DOS. Until I accidentally stumbled across this forum I was convinced that when I died all wisdom would die with me !!! Back to technical matters. I told Windows XP to exclude my external drives from System Restore, but sometimes when XP woke up it forgot and reactivated. I then added prohibitions in the registry, which fixed it until my daughter got an IPOD and I was told I could install iTunes on external drive H:\. The iTunes setup.exe also thought it could go there, but half way through it aborted. I then allowed it to install on C:\ and the first thing it did was to automatically remove its residue from H:\ - which I thought was unexpectedly nice of it. I subsequently realised it had deceived me - it had also taken the opportunity to get System Restore to once more get its claws into my H:\. I am sorry but my sense of humour fails in this situation. So I created a batch command file to determine at start-up whether Windows XP was going to stuff Restore Points into my external drives. Perfect solution. Then Service Pack 3 got in, and that slowed down some things. In particular there was only an 80% probability that System Restore would have posted today's status before my batch file examined its contents in C:\SYSTEM~1\_RESTO~1\DRIVET~1.TXT. That is when I came to this forum and found that I could "START" a program in /LOW priority mode, so I made my batch file invoke the status examination in low priority mode, hence it did not start to look at status until the frantic HUBBUB of start-up was finished. Perfect solution. Then I find with SP3 there is a far higher probability that "systray" icons will be lost at start-up, so I removed some items from the start-up folder to reduce the start-up processing, and added /WAIT to my START, and the main batch command file now launches what I removed from start-up. Much better, but still not always good. So I added diagnostic time stamps such as :- 29/08/2008 19:50:44.25 TO 19:51:09.16/19:51:10.72/19:51:11.43 19:51:14.69 30/08/2008 8:40:50.32 TO 8:41:05.11/ 8:41:12.76/ 8:41:18.08 8:41:35.27 30/08/2008 15:02:43.25 TO 15:02:59.29/15:03:01.17/15:03:02.24 15:03:09.67 30/08/2008 21:59:39.56 TO 21:59:56.02/21:59:57.85/21:59:58.98 22:00:01.13 31/08/2008 8:23:45.68 TO 8:24:00.97/ 8:24:02.57/ 8:24:03.22 8:24:20.43 31/08/2008 13:15:02.76 TO 13:15:34.76/13:15:36.36/13:15:40.16 13:15:43.36 31/08/2008 15:53:32.15 TO 15:53:45.44/15:53:47.29/15:53:48.63 15:53:51.19 31/08/2008 20:57:27.56 TO 20:57:45.22/20:57:47.70/20:57:48.41 20:57:50.50 I decided I would have a far better view of the diagnostics if they were all relative to start-up, rather than G.M.T. I saw a thread about calculating time differences, but decided that my very compact batch file would be overwhelmed with all the extra processing for all the "SUPPLEMENTARY" diagnostics. Hence my request for a counter that starts at zero on start-up. I came back to report that I can do the job with systeminfo | find "System Up Time" > GOTe(%1).TXT BUT it takes about 4 seconds to do it. With extra complications I can START a timestamp and immediately move on to do other things and start other timestamps. If I start 10 timestamps at 0.1 second intervals they all grab a number that is within 5 seconds of the first one, but they tend to swap timing order, and the subsequent spewing out and through the FIND filter takes another 40 seconds. Dias - I love you last solution. It works. It meets all my desires. I knew I could get whatever this register was if I coded in 'C' - but the last time I did that was on Windows 95 and I thought it would endanger XP unless I upgraded my tools. I thought any other way of coding to "get inside" Windows, such as Visual Basic, would cost money and a steep learning curve. You make it look so simple. I would appreciate it greatly if you could post me a link so I may learn more about VB scripts. Regards A very happy Alan I would appreciate a link to further information upon the use of "Wscript.Echo FormatNumber(timer*1000,0,0,0,0)", and the many other parameters that can be evaluated. I assume that there is a lot more information available than "timer" if only I could find a reference manual with an index. Goggle found 86,100,000 hits within 0.14 Seconds - but it would take me MUCH longer than that to find anything relevant. Searching for "Wscript.Echo" was more rewarding, BUT it all seemed to link to long articles and complex scripts - I am hoping to find some simple one line exercises that I can try out before I learn yet another completely new-to-me programming language I now have a good diagnostic summary of timestamps showing when various start-up process complete. My original goal of timestamps relative to start-up has now been revised - some processes randomly take much longer than normal and delay everything that follows. Now I subtract each timestamp from the previous and report the duration of each process, so when a process takes longer it no longer affects subsequent results. Regards Alan I'm sorry I didn't answer your previous query; the truth is I haven't got any single place I use for vbscript resources, I just tend to Google for whatever topic I need help with e.g. searching for "vbscript timer". I'll break down that Wscript.echo line for you: Wscript.echo ECHOES whatever follows, if you use cscript as the script engine, it uses the console. FormatNumber works like this Wscript.echo FormatNumber (number or expression, NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, GroupDigits) The 4 parameters after the number work like this. In the line you are referring to, they are all zero NumDigitsAfterDecimal - value indicating how many places to the right of the decimal are displayed. The default value is -1, indicating that regional settings should be used. (Optional) IncludeLeadingDigit - indicates whether or not a leading zero is displayed for FRACTIONAL values. (Optional) -1 = True 0 = False -2 = Use regional settings UseParensForNegativeNumbers - indicates whether or not to place negative values within parentheses. (Optional) -1 = True 0 = False -2 = Use regional settings GroupDigits - indicates whether or not numbers are grouped using the group delimiter specified in the Windows Control Panel. (Optional) (I.e. comma, space or dot for every 3 digits in numbers 1000 and over) -1 = True 0 = False -2 = Use regional settings Actually the site I link to below is a very good resource with examples. http://www.adminscripteditor.com/syntax.asp?l=v&lim=1 Thank you for the detailed explanation whcih answers all my immediate questions. Thank you also for the link, which looks very useful for future explorations. Regards Alan |
|
| 3523. |
Solve : using wzzip in batch file? |
|
Answer» Hello there, first time posting here, in HOPES someone can help resolve my frustration... causes an error in the batch if i leave this What error? Did the wzzip program issue the error? The syntax you posted is correct. I was able to duplicate your Winzip code with no problems. well when I put the line in with he -a option it will give a message"cannot fine -a" that throws me because I was following the instructions from the help file and I STARTED to suspect that it was not actually appending the zip file, because the properties did not show that the file had been changed. I added a test txt file in the directory that was supposed to be zipped, and the test file was not listed... yea its driving me crazy, I had perused the help section that came with wzzip for a couple of days before posting here... thank you for your help! err, cannot find -aDOS usually takes arguments in the for /* not -* but if the documentations says so....I've tried short path names, long path names, quotes, no quotes and I cannot get your code to fail. The -a switch is the DEFAULT, so why not eliminate it? Code: [Select]"c:\program files\winzip\wzzip" c:\backup\ffbackup\ffbackup.zip *.* If you can, turn off echo in your batch file, run from the command prompt and post any output to the console. I'm having a hard time fixing something that is not broke. well maybe I misunderstand what the behavior of wzzip is supposed to do. perhaps this is a test grasshoppa basically it still seems my batch is only copying the existing zip file (residing in \c:\backup\ffbackup\), and not creating another one and copying that... that is ultimately what I am wanting to accomplish. I'm confused. Are you having problems with wzzip syntax or are you getting unexpected results. There is a difference. Quote basically it still seems my batch is only copyinarchiveg the existing zip file (residing in \c:\backup\ffbackup\), and not creating another one and copying that... That would DEPEND on the source files. The -a switch will add new files to the archive. Use the -f switch to replace files that are already part of the Zip file and are newer on disk. Use the -u switch to add to the archive any files that are not already in the Zip file, and replaces any files that have a more recent date on disk. Code: [Select]"c:\program files\winzip\wzzip" -u c:\backup\ffbackup\ffbackup.zip *.* for /f "tokens=1-5 delims=/ " %%d in ("%date%") do ( copy /y /v c:\backup\ffbackup\ffbackup.zip %%e-%%f-%%g.zip ) The above code produces two copies of the archive. One on c: and one in the current directory. Code: [Select]for /f "tokens=1-5 delims=/ " %%d in ("%date%") do ( "c:\program files\winzip\wzzip" -u %%e-%%f-%%g.zip *.* ) The above code simplifies the process, creating one zip file in the current directory. Note to Self: In the next lifetime, come back as a dentist. Great, I have briefly tested and think I see where you have made improvements. I will have to play with it a bit more, but you're giving me a push in the right direction. I was under the impression that I had to put the start line in the batch to launch the app. I hope I havent added any grey hairs, or shortened your life span any |
|
| 3524. |
Solve : Trademarks and Scripts? |
|
Answer» I am looking to run a dos script to delete a couple icons that have the trademark symbol (®) in them. When I put the name shown it says it cant find the file. How would I do this? Or I guess is it even possible?What do you mean by the "name shown"?the icon name such as guardian® test.ico is what I am referring to. I have a script that I have it find the file and delete it but I am having ISSUES with the files with that symbol.Quote from: guardian on September 10, 2008, 11:11:12 AM guardian® test.ico is what I am referring to. 1. Is that the actual file name? 2. How did it get on your hard drive? That is not the actual name of the file the actual name is Horizon® Practice Plus 9.5 Prod. The file did get on my system through an application that I do use but I am working on an upgrade but when I upgrade the system it leaves that file behind and I am GOING to be doing this on multiple MACHINES so i am looking to make a script to remove that file so the new one will take its place and an extra shortcut is not left behind.1. I presume there is an .ico extension? 2. Have you tried using wild cards e.g. del Horizon*.ico or del *.ico ? its a .lnk (shortcut) and i cant use the wild card because there are other icons there that are Horizon first and then stuff after so i will get extra files.So the full name is "Horizon® Practice Plus 9.5 Prod.lnk" ? I notice it appears to have a space. I hesitate to suggest something so obvious and basic, but have you been putting quote MARKS around the filename? LOL yeah I am putting the quotes and yes the full name is Horizon® Practice Plus 9.5 Prod.lnkI tried to reproduce your situation. I can both create and delete a file named (by copying from your post) as you describe. Code: [Select]D:\test>md badname D:\test>cd badname D:\test\badname>echo hello > test.txt D:\test\badname>ren test.txt "Horizon® Practice Plus 9.5 Prod.lnk" D:\test\badname>dir Volume in drive D is DATA2 Volume Serial Number is 00CC-DEDF Directory of D:\test\badname 10/09/2008 19:03 <DIR> .. 10/09/2008 19:03 <DIR> . 10/09/2008 19:03 8 Horizon® Practice Plus 9.5 Prod.lnk 1 File(s) 8 bytes 2 Dir(s) 127,898,386,432 bytes free D:\test\badname>del "Horizon® Practice Plus 9.5 Prod.lnk" D:\test\badname> D:\test\badname>dir Volume in drive D is DATA2 Volume Serial Number is 00CC-DEDF Directory of D:\test\badname 10/09/2008 19:03 <DIR> .. 10/09/2008 19:03 <DIR> . 0 File(s) 0 bytes 2 Dir(s) 127,865,421,824 bytes free We can avoid using the ® symbol because the ? wildcard only matches 1 character in an exact position... Code: [Select]D:\test\badname>dir Volume in drive D is DATA2 Volume Serial Number is 00CC-DEDF Directory of D:\test\badname 10/09/2008 20:50 <DIR> .. 10/09/2008 20:50 <DIR> . 10/09/2008 20:50 8 Horizon® Practice Plus 9.5 Prod.lnk 1 File(s) 8 bytes 2 Dir(s) 126,659,215,360 bytes free D:\test\badname>del "Horizon? Practice Plus 9.5 Prod.lnk" D:\test\badname>dir Volume in drive D is DATA2 Volume Serial Number is 00CC-DEDF Directory of D:\test\badname 10/09/2008 20:50 <DIR> .. 10/09/2008 20:50 <DIR> . 0 File(s) 0 bytes 2 Dir(s) 126,656,790,528 bytes free D:\test\badname>did you try it yet? I have tried it and the question mark (?) did work. Thank you for all of your help. |
|
| 3525. |
Solve : retrieve deleted files? |
|
Answer» There used to be a WAY to restore/retrieve a file that was DELETED. It was in DOS, I THINK... Is it still possible?you are talking about undelete , YES you can as long as you are using a real VERSION of dos, the version in xp/vista is not the real dos |
|
| 3526. |
Solve : Running a CMD from RUN box in XP? |
|
Answer» Well first of all sorry my poor English ::I open the Cmd.exe This was a small example.As you can see it has cleaned the Logs inside a folder.(This folder was configurated by launcher.cmd)(Also many other things are configurated by the Launcher.cmd)Which means: i cant to jump over it calling directly the launched cmd files (without touching a lot all the files) Now i hope it´s a little bit more clear. I want to Launch the launched.cmd files from the RUN Box in XP Surfing the Web i learnt how to call my launcher: C:\Windows\System32\cmd.exe /k "C:\program\launcher.cmd" (I need "/k", otherwise cmd close as you know,but i learnt it yesterday) But now... im stuck i think i have to use a Pipe | or something like that...but...i cant find any clue to do that. Can u help me?Thanks put launcher.cmd to system32 folder and in run box type launcherWell devcom...i think i have FAILED to expose my problem(maybe a matter of my poor english?) I can launch the launcher.cmd without problems with the following sentence: C:\Windows\System32\cmd.exe /k "C:\program\launcher.cmd" But i want to launch launched2.cmd or launched1.cmd or launched3.cmd or.... I could use logically: Quote C:\Windows\System32\cmd.exe /k "C:\program\launched1.cmd" But it doesnt work since launcher.cmd sets some global variables(some means about 1200) and other features which launched ones needs. So i need... first to launch the launcher.cmd and then i.e launched1.cmd. All in one sentence... I hope now it should be undestable enough...but if anyone have any doubt about how it works dont be worry about asking me. Thanks anyway devcom so you can add this code in launcher.cmd Code: [SELECT]start launched%1.cmd and in run box type Code: [Select]launcher "number of launched.cmd to run" but you must copy launched.cmd to system32 like i said before ofc all launched(1-3) must bee in system32 too or you can cd to them ex of use Code: [Select]luncher 1 |
|
| 3527. |
Solve : Creating .bat file to open program and close multiple processes? |
|
Answer» I would like to make a batch file that would start one program and would also close several running PROCESSES of my choosing. I'm running Windows XP Home and am having CPU spikes that slow down the program I want in the batch file. Wow, that's awesome Not really. I use the same code to kill off program remnants when testing my homegrown applications. It's handy to have a closet full of snippets. By using the shift command, the batch code sequentially moves each program name on the command line into the %1 position. Once there, it's like shooting fish in a barrel. You can find a good free task manager here Good luck.The coding you replied with is far too advanced for me at this time, but I'd like to learn how each snippet works. If you want, you could go over each thing in your code or tell me where I can find a detailed list of all .bat codes, strings, and puncuations and how to apply them? I've searched the net for the past couple days and have only found simple commands - like for opening multiple files at once. Thank you very much for helping me with this.Not knowing your skill level, I generally send posters to this site for learning batch code. Considering there are only 13 or so batch instructions, batch code can be powerful stuff. My only gripe is readability and a notation straight from the cave drawings. Good luck. OK. I'll check out that link and see if I can create a resource toggle.bat eventually. Also, that task manager you showed me is PERFECT! Now I know what each process is for and the path to the .exe files. I also replaced the standard taskmon with it. Keep up the good work! Your help is very much appreciated. |
|
| 3528. |
Solve : Need help - excel to batch file?-? |
|
Answer» I need HELP please.... how can i link the data from excel to the batch file? if the data will come from excel how will i do that Excel spreadsheets use a proprietary file organization. Batch files can only process text files. You can use any COM aware script language (VBScript, JScript, Python, etc) to create an external script that can process the XLS file format. You can use VBA to create an internal script that will run WITHIN the Excel application. Good LUCK. |
|
| 3529. |
Solve : Scheduling application launch with AT? |
|
Answer» I am using AT to schedule the start of an application, but the application is not visible to the current user. Desired scenario: In a UTILITY application, the user will be able to choose a time to launch the application again on a regular basis--for example, every Tuesday at 11PM. The application will use DOS shell AT command to schedule the task. I want this to work at least on XP and Vista, and I'm having the PROBLEM on both. (The application will be distributed as freeware or shareware to a variety of users, so hopefully the users won't need to fiddle with any settings themselves.) Simple test scenario: I am using this shell command-- Code: [Select]at 11:00pm "C:\Path\test.bat"substituting an APPROPRIATE time and the path to the batch file The batch file says-- Code: [Select]@echo off start notepad Result: The job is scheduled successfully (on Vista, this requires running the application as Admin) and runs successfully. However, the Notepad is invisible and only shows up if I go into the Task Manager and show all users--it's a System task. How can I make this execute visibly to the current user? Thanks!Try adding the /interactive switch to the at command line: Code: [Select]at 5:35am /interactive c:\path\test.bat By scheduling a batch file, you also create an instance of the shell PROGRAM (%comspec%) Why not schedule notepad directly? Code: [Select]at 5:35am /interactive notepad.exe Thanks, I had overlooked the /interactive switch! I think that's it. However, when I tried it, I was informed (on Vista) that due to security, for interactive MODE I would have to use schtasks instead. I used schtasks, and it worked. |
|
| 3530. |
Solve : Need Ms-Dos 6.22 on floppies? |
|
Answer» Hi all, The setup.exe file for 6.22 is a free microsoft dowload, but the computer i'm working on only has 1.4 mb floppy drive I thought tho these floppies might have been of some use?! Like - 1.4 mb floppies! Thus avoiding the problem of the .exe you mention.Quote from: ChrisXPPro on September 04, 2008, 02:31:02 PM Quote from: MajorSci on September 04, 2008, 02:09:37 PMThe setup.exe file for 6.22 is a free microsoft dowload, but the computer i'm working on only has 1.4 mb floppy drive the free download from microsoft is likely the 6.22 "Step-up" installer, which UPDATES DOS 6 to DOS 6.22. One alternative you might want to explore is FreeDOS ChrisXPPro, please don't tell me you had those pictures filed away under "family" P.S: I probably would have.Quote ChrisXPPro, please don't tell me you had those pictures filed away under "family" Hahaha - well could well have been LOL! The "Grand PARENT's folder" In fact I took pics of some floppy sets because I was gonna put them on ebay! I don't need to keep all my floppy stuff but sure do not want to just trash em all.Looking at the FreeDos it appears to require a CD or other DEVICE to install. The poor old machine I'm working with has only 1.4 mb floppy. Thankshttp://www.neowin.net/forum/lofiversion/index.php/t328254.html |
|
| 3531. |
Solve : xcopy command line together with wmplayer command line? |
|
Answer» A BIG hi to EVERYBODY as this is my first appearance in this forum! |
|
| 3532. |
Solve : cmd path? |
|
Answer» when i open cmd following line APPEAR in command prompt use this: i know this i want that it will be c:\> when it opened fisrtAre you OPENING cmd USING Start>Run or are you using a shortcut/hotkey or how? What's your operating system? If opening CMD through Start -> Run, try: Code: [Select]cmd /k cd \If opening through a shortcut, change the starting DIRECTORY to C:\Quote from: GuruGary on September 07, 2008, 06:51:09 PM If opening CMD through Start -> Run, try: many many thanx |
|
| 3533. |
Solve : Open several links in internet explorer tabs from batch? |
|
Answer» Using IE7 as the default browser, the following code gets me interesting results: |
|
| 3534. |
Solve : Renaming a folder with user input batch file question? |
|
Answer» hi huys, this is my first post so a BIG hi! |
|
| 3535. |
Solve : How can I save output of dir in a variable?? |
|
Answer» Hi all, |
|
| 3536. |
Solve : ftp deletion of folders with contents? |
|
Answer» Hi, |
|
| 3537. |
Solve : Help me? Need a command here? |
|
Answer» I have made a bunch of batch files recently and I'm trying to make one for school, its a computers PROJECT. It's simple. |
|
| 3538. |
Solve : Creating a batch file with commands in programs? |
|
Answer» Im new to this forum, so this might have been posted already. I was wondering how to make a batch file perform tasks inside programs. Its for a project which involves creating a batch file that opens sndrec32.exe and then telling the program to start recording. If its at all possible i would like to be able to minimize it to the system tray. Thanks in advance!. you cannot do this in batch, atleast not using the standard commands if you want to create a batch file wrapper for a .vbs file then its possible, check out wsh.sendkeys google itYah ok i did that, but theres nothing very clear on it. Btw did i tell you im a noob, so i need like VERY clear instructions cuz im new at .bat and .vbs files. I know basic sort of.Ok |
|
| 3539. |
Solve : DOS 101 quiz question? |
|
Answer» Hi EVERYBODY, i'm just starting to learn DOS......I know go ahead and laugh |
|
| 3540. |
Solve : need help with partition/formating hard drive? |
|
Answer» Hi all! I'm trying to FORMAT my hard drive and have run the fdisk first to set a primary DOS partition (just one DISK). My hard drive is 80 GB, but after successfully partitioning the disk, it only shows about 10 GB as available. Where's the rest? Tried it several times, all to the same result. Please help me do it right! Thanks in advance.From Our VAST Archives : |
|
| 3541. |
Solve : LAN connection through command prompt? |
|
Answer» hey everyone Blastman has a good solution, but you can also use the copy command with the UNC path which will prevent you from having to map / unmap the drive (assuming correct permissions are in place). Using his example, the same copy could be done like: Hey, why didn't I think of that!! I suppose I'm used to working in a from admin to user world!! 2 last questions 1 is how do u do the "code" box? and 2 is when u mean by net use u mean by the command "netsh" right?Quote from: macdad- on March 07, 2008, 06:03:42 PM 1 is how do u do the "code" box?I assume you are referencing the "Code" box for messages in this forum? Code: [Select]Like this? There are several ways. The way I usually do it is reply to, or start a new message, then type the code in the message box, then select the code portion with your mouse and click on the "code" tag above the smiley FACES (code is the one that LOOKS like the page with the # sign on it). Quote from: macdad- on March 07, 2008, 06:03:42 PM 2 is when u mean by net use u mean by the command "netsh" right?No, you don't even NEED netsh. You use the net use command directly from the command prompt. Example from XP: Click Start -> All Programs -> Accessories -> Command Prompt You end up with something like: C:\Documents and Settings\macdad> Enter the command like: Code: [Select]copy C:\sometextfile.txt \\computername\sharenameor Code: [Select]net use * \\computername\sharethnx |
|
| 3542. |
Solve : CALL but executre script on another server? |
|
Answer» Hi, |
|
| 3543. |
Solve : how to execute a select statement from a batch file? |
|
Answer» i have windows XP, my database is sybase. I also want to know how can i make my stored procedure accept parameters from the command line. |
|
| 3544. |
Solve : Batch file error trapping? |
|
Answer» I have a batch file that copies 5 files from one folder to 10 other folders. Each coping process starts with a USER name as a label. If someone is using the files there is a delay due to sharing violation, until it reaches the LAST file in the GROUP, and then continues at the normal rate. I have tried trapping the error and sending it to the next subsequent label, but have not had any success. Can someone help me with this. |
|
| 3545. |
Solve : how to camoflauge a bat file? |
|
Answer» i was wondering... how could i camoflauge a bat file... i made one but it has .bat extention.. is it possible to make it look like a txt document but that it would run as a bat file... i hope you understand what i want :p thx i dont know how to make it look like a txt document but have it run like a batch file , but if you want to make your bat run invisibly use this.. Me and my friends are doing this sort of thing to bypass school security... the restrictions are the computers are rediculous but anyways... Maybe if you paid more attention to your lessons, and less to arsing about, you'd know how to spell "ridiculous", and your GRAMMAR would be less execrable. |
|
| 3546. |
Solve : can u make a bat file not editable?? |
|
Answer» i have seen some progs that convert ur BAT file to a COM file and obiviously a COM file isnt readable much less editable. |
|
| 3547. |
Solve : deleting directories? |
|
Answer» im sure im just not doing something RIGHT but I want the file to DELETE the folder, not just its contents. this is what i have: |
|
| 3548. |
Solve : DIR listing of files only? |
|
Answer» Hi, Hi, a) Files DIR /A-D b) Folders DIR /AD c) Files & Folders DIR use the /b switch to get a bare listing without header, footer, date info etc. Quote Obviously the DIR command works fine for listing folders (DIR /AD), files & folders (DIR) but I cannot work out how to list just files. I'm sure it's obvious but I cannot work it out. To negate or reverse a switch, put a minus sign in front of it so dir /ad list folders but dir /a-d lists everything except folders (ie just files) Also if you use the o switch eg dir /od list files and folders in date order earliest first, then dir /o-d reverses the order, same with /on etc type dir /? at the prompt for a summary of the options. This looks LIKE a homework question, and if it is, I am surprised your teacher did not go over all this with you already. Hi Dias de verano, Many thanks, it worked great. I never knew about the /A-D command... very useful indeed. The /O switch is also very useful. Thanks a LOT for your help, Roly. Quote This looks like a homework question, and if it is, I am surprised your teacher did not go over all this with you already. haha, I'm actually almost 40 but I have not used DOS since my school DAYS I'm 55 Quote from: Dias de verano on March 10, 2008, 08:55:52 AM I'm 55 Great, thanks for that. |
|
| 3549. |
Solve : Check for today's date? |
|
Answer» Hi, I have a simple batch file that copies a file from a server to the client. I want to check the date on the server file first and not execute if it is not today. (So the actual date will VARY and cannot be hardcoded). Can someone help me with this?The environment variable %Date% holds the current date - the modifier to environment variables to RETRIEVE the last updated time of a file is %~tI |
|
| 3550. |
Solve : Using a batch file to open a new command prompt and....? |
|
Answer» I have searched through the DOS forum to try and find an answer. I am trying to run a command line program from a batch file, including all inputs, multiple times. I have an Excel VBA sub that will create as many batch files as I need and fill them with the inputs, however what I am running into is that the program I call needs to have the command window it is in close before it is run again (outputs a few files at the close). So I have gotten my batch files to open a new command window, however the commands are still run in the original command window. I have also tried calling batch files that would open a new command window, but ran into the same problem. |
|