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.
| 1651. |
Solve : IBM Aptiva E series? |
|
Answer» Yes, I am an idiot. I can't get my old computer out of DOS. All it does is give me a key symbol and when I type it gives me a white rectangle. I have an IBM Aptiva e-series 245.And your operating system is :-? |
|
| 1652. |
Solve : creating a dir? |
|
Answer» ok here is my problem, i was messin around with my UI shell and i relocated the folder without redefining the path, well now all i can do is get into the msdos through the 98 start up disk that ive GOT...now i figured out how to copy files from one location to another, and all i need to do to fix this issue is to have the blackbox.exe file in the right place, however, i dont have the right folder(i.e. directory) in this place and i cant figure out how to create one Microsoft Windows 2000 [Version 5.00.2195] |
|
| 1653. |
Solve : Use "More" command with the least control keys? |
|
Answer» When I type the more>dailylog.txt command, I can begin to type some words. Keep it simple Dudes! Wooooo , so simple, but so DIFFICULT. I cannot understand this two statements. :-? so many questions for me? What does ECHO.%Line% mean? What does && mean? Why when I give a initial assignment "set Line=", this code does not work properly? Why when I move GOTO:GetLine to the next line, this code does not work? Can you give me some explanation on how it works? Thank you very much! Sure, let's go into detail: ECHO OFF SET Line=%date% %time% ... the Line variable is now initialized with a string containing the current date and time. :GetLine ECHO.%Line%>>dailylog.txt ... the first time coming here will append the date and time to the log file, looping back to here will append the new text entered by the user. SET /p Line=&&GOTO:GetLine ... this will query the new Line to be added to the log file. The GOTO will only be executed when some text was entered. If no text was entered then the GOTO will not be executed, and the loop terminates. Note that there is difference between single & and a double &&. Single & will concatenate commands whereas double && causes conditional execution so that the command following the double && will only execute when the command preceeding the double && succeeded. The set /a command only "succeeds" when text has been entered by the user. See also http://www.dostips.com/DtCodeSnippets.php#_Toc141112827 Hope this also eliminates jpl's concern. Quote The GOTO will only be executed when some text was enteredYou LIVE and learn; I never thought to try conditional execution .. thank you GrahamThank you sooo much for details, DosItHelp. I much appreciate your effort and time. Thanks again. |
|
| 1654. |
Solve : Problem running DOS based pgm? |
|
Answer» The hard drive on my other comp completely crashed!!! I was running a DOS BASED DBM software package with no problem. Lucky I thought, everything was BACKED up. I put everything over to this computer which runs XP and I'm having a problem. I can run DBX and see the DBF files but when I go to run the DB prgram the initial screen comes up OK but when it comes to the actual working system where different Data Bases link etc. I get an open error on one of the files, DOS error 4 with option of Quit, RETRY or DEFAULT. I went to default a few TIMES and it takes me all over the place and eventually gives me no other option than to QUIT. I have edited Autoexec and Config files based on what I used with WIN98 and I have added PATH to system variables with no luck. |
|
| 1655. |
Solve : GX1.EXE? |
|
Answer» Hey Everyone, Seems to be a crack for Galactica... Patio, I reworded the question and maybe it makes more sense now. It does read better. Thanks for trying. Gary *****************************888 |
|
| 1656. |
Solve : Time out? |
|
Answer» I am WRITING a batch scrip that will give the user the option of backing up files and syncing files or both, and i am wanting to set it that it the user hasn't inputted a selection in a determained set of time (30 SECONDS) it will automatically backup the data. |
|
| 1657. |
Solve : Batch file, help, stoopid people!? |
|
Answer» It's just so frickin(sorry for thwe bad language) annoying when someone names a post "batch file" or "batch help" or "help" or "batch" ETC! Because then you have no IDEA WHAAT they need help with and most people just ignore it!!!!Most people will probably ignore this poll as well... |
|
| 1658. |
Solve : help id dos commands? |
|
Answer» ok listen |
|
| 1659. |
Solve : no data in config.sys file? |
|
Answer» Hi All! I have installed FoxPro (for a work from home PROGRAM) when I INSERT the disk that has my assignments on it, I get a message that I need to change the FILE number in config.sys from 30 to 60. |
|
| 1660. |
Solve : Disabling service in Batch file? |
|
Answer» Hey guys & girls |
|
| 1661. |
Solve : disable xp services? |
|
Answer» I need the sintax for a batch to set the disable status to somme services in winxp. I don't want to stop those services because it takes somme time to execut those commands.By setting the disable status, when my system REBOOTS those services would be stoped. I think that i FOUND de command that can do this "SC" but i need somme help to syntax . Can you help me with an EX. for stopping the messenger service You can just disable them or set them to manual in services. |
|
| 1662. |
Solve : Redirect outputs in the same line in a text files? |
|
Answer» When I use >> to redirect the outputs to a text file, it just append the outputs in the next line, but how can I append them in the line where there already exist some words, or just append them following the existing words in the same line? [*]The whole thing is one command line. [/list] If want to add text to a particular line then use this: [edit]set ap=[highlight]str1[/highlight]&set c=[highlight]2[/highlight]&set f=[highlight]t.txt[/highlight]&cmd /v:on /c "(for /f "tokens=1,* delims=:" %a in ('findstr /v /n "$$"^"%temp%.\t0815.txt"&move /y "%temp%.\t0815.txt" "!f!"[/edit] Replace [highlight]str1[/highlight] with the text you want to append. Replace [highlight]2[/highlight] with the line NUMBER you want to append to. Replace [highlight]t.txt[/highlight] with the file name you want to append to. Is cryptic but works ;) My GOD! This is out of my reach! I copy and POST this command in my code, it says syntax error. I think the structure is too complex and not easy to IDENTIFY where the error is. Can you use multiple of lines to revise this command? Thank you very much!DOSNVC, Sorry, both code blocks had an addition double quote at the end, which is corrected now. The code is meant to be executed directly from the command line. In a batch script same can be extracted to: [edit]set ap= set f= set c= (for /f "tokens=1,* delims=:" %%a in ('findstr /v /n "$$"^<"%f%"') do ( if "%%a"=="%c%" ( ECHO.%%b%ap% ) ELSE ( echo.%%b ) ))>"%temp%.\t0815.txt" move /y "%temp%.\t0815.txt" "%f%"[/edit] This works but looks pretty ugly in you main script block. Optionally you can call an append function like this: call:append StringToAppend FileName LineNr Place the append function itself at the end of your batch script. Copy the append function from here: http://www.dostips.com/DtCodeCmdLib.php#append. Good luck |
|
| 1663. |
Solve : del user profile remotely? |
|
Answer» I have a batch file that I use to delete user profiles from remote PCs. It WORKS great But now I want to modify it so that it can use a text file called PcsLisl.txt that would contain a list of computers. Sample of file below |
|
| 1664. |
Solve : Protecting long file names in batch files? |
|
Answer» Hello, |
|
| 1665. |
Solve : Push a button key without push?? |
|
Answer» Hi Guys.. No you can not, dos or batch will not emulate keystrokes. There is a scripthing langage caled autio it that can emulate keystrokes and it is free and easy to learn, of you needx any help with that i will help you. Is it working in M$-Dos? I only know a windows version. It is worth a try to send a CARRIAGE return with echo scancodes: http://www.torsten-horn.de/techdocs/ascii.htm At the win commandline it works with echo(hold alt)13(at the num block). Should also work at M$-Dos cause scan codes are same same. In a (win) batchscript it is "&echo." in a var to make a cr. Is no assembly crack here for a debug solution? hope it helps uli |
|
| 1666. |
Solve : input a name in the same line in CMD Prompt? |
|
Answer» I have composed a batch file. When you double click on it, a COMMAND window prompts up displaying "Your name:" |
|
| 1667. |
Solve : Batch: Server Copy? |
|
Answer» Hi I was wondering if someone could help me with the code if I am trying to copy a folder and all of it's contents from one server to another folder in another server. OS Windows XP. my code... xcopy "Y:\Dom_SSDBS\LSSPD\787 ENOVIA Tailoring Process" "C:\Documents and Settings\rw131c\Desktop\testing.bat" /-y maybe /y instead of /-y hope it helps uli Yes the quotation MARKS helped the code WORK, but I can't get it to copy folders, and all of it's contents. I added \*.* because nothing was being copied, but only the files are being copied. What is the code for the folders? +dir? xcopy "Y:\Dom_SSDBS\LSSPD\787 ENOVIA Tailoring Process\*.*" "C:\Documents and Settings\rw131c\Desktop\testing bat" /y The code above COPIES all the files with out asking for overwrite permission. I need the folders to be copied as WELL. Please help.XCOPY comes with an alphabet soup of switches. Try adding the /s and /e switches. Better yet, xcopy /? from the command prompt will explain all the switches in detail. Good luck. 8-) |
|
| 1668. |
Solve : administrator? |
|
Answer» wow can i GET administrator user NAME and password for xp in dos? |
|
| 1669. |
Solve : is this even possible?? |
|
Answer» I want to make a batch file that GETS the ADRESSES of the websites i have open, stores them in a text file, and closes the windows. I want another batch file taht opens the websites LISTED in the text file. If this is possible, it would be great if som1 could help me make the file. I want to make a batch file that gets the adresses of the websites i have open, stores them in a text file, and closes the windows. I want another batch file taht opens the websites listed in the text file. If this is possible, it would be great if som1 could help me make the file. this can be easily done in langauges like Perl/Python etc, but if you want a batch soln, you can try wget. The wget command is from the GNU Tools. Should be possible with it. Please post your solution when it works. :-) uli |
|
| 1670. |
Solve : Running *.bat in a batch file? |
|
Answer» Hi everyone, I was even able to put in a provision that after each bat file was run, it would be renamed to .BAK so it would not be run again. but as the FOR cycle steps through all the .bat files in e:\test there should be no risk of running any of them again, if I understand how FOR works. How did you manage to rename *.bat to *.bak anyway ? I mean, how/where can you do it ? After the do call "%%i" it shouldn't work. |
|
| 1671. |
Solve : File Properties using batch? |
|
Answer» anyone know how i can use a batch file to look up the size\free space on a drive??Since I have to GUESS your OS, you have to guess if this will work for you: Code: [Select]echo off it works for me (Windows XP) but only if I write for /f "tokens=3" %i in ('dir c: | find /i "free"') do echo %i dir c: | find etc. is good dir c: ^| find etc. isn't what's with the "^|" syntax ? :-?The caret (^) acts as a escape character when using DOS SPECIAL characters. I couldn't find much documentation on why you need it, just that without it under certain conditons the parser will error out. Apparently you need to use it when a DOS special SYMBOL is used in a nested command. In the example I gave you: for /f "tokens=3" %%i in ('dir c: ^| find /i "free"') do echo %%i, the pipe (|) is embedded in the FOR command. I know, I know, not much of a response, but use it if you get an error by not using it. Quote The caret (^) acts as a escape character when using DOS special characters. I guess this shows why an expert is called an expert [smiley=thumbsup.gif] It's exactly as you said. In a batch file, if I LEAVE the ^ out it breaks, if it's in, the parser itself will take care of it, just the opposite at the command line. A bit like doubling % in batch isn't it I never had any idea it should work this way. Thanks a lot for the info [smiley=vrolijk_26.gif] [smiley=beer.gif] |
|
| 1672. |
Solve : how to indent output and redirect it to text file? |
|
Answer» I am trying to make the contents of a text FILE look nice, so some lines should be indented following the last LINE. I used the command [highlight]type names.txt >> list.txt [/highlight] in a batch file, but the output is not what I want. The display should look like: Quote type names.txt >> list.txt What display? All you've done is redirected the output to another file. A space is just another character as far as the processor is concerned. What was the alignment in the names.txt file? If this goes back to your other posts about more, then ALIGN the names.txt file using the space bar. more >> names.txt Code: [Select]List of the students in Year 13: Alice Helen Use the spacebar to insert the leading spaces in front of Alice and Helen or better yet use an editor such as EDIT or even EDLIN. 8-) Are you really running MS-DOS or just a look-alike under Windows? |
|
| 1673. |
Solve : "SYSERR" parameter? |
|
Answer» Anyone ever use the "SYSERR" parameter in their DOS batch FILE for checking the "return-code"? If so, can you provide a snippet of the code? I am LOOKING for an aternative to "%ERRORLEVEL%. Could not find any documentation on SYSERR except as a user written C function. Why do you need an alternative to ERRORLEVEL? What are you trying to do? This error situation occurs when trying to delete a file which I don"t have access to; Not sure what this means, but if you don't have access to the file, how do you expect to delete it? 8-)I know this sounds silly; but the "access denied" error situation does occur when a batch cmd file is run for the first time in production, and someone has overlooked granting the APPROPRIATE access to the userAccount. I"ll test the "If exist" clause, and see how it behaves in my .bat file. |
|
| 1674. |
Solve : How to get value in variable from FINDSTR function? |
|
Answer» Hi, |
|
| 1675. |
Solve : DOS Programming Language? |
|
Answer» :question |
|
| 1676. |
Solve : start services? |
|
Answer» i can START PAUSED services in DOS as using "net start" COMMAND (XP_SP2) |
|
| 1677. |
Solve : need help (network dos command)? |
|
Answer» hello..i'm a newbie.i have a question.can i access other pc RESOURCES (ex. CDROM) USING dos command.?I have 2 pc (old) CONNECTED only by printer port(laplink cable) 1pc have the cdrom,the 2nd pc dont have.(you cannot PLACE the cdrom of pc1 to pc2)..the pc2 is formatted (no OS) i want to install WINDOWS 98 but the installation cd is in the cdrom of pc1, how can i install OS using the cdrom of pc1.. |
|
| 1678. |
Solve : Testing Dir for NO Files? |
|
Answer» I have done a review and search of you system and I can't find an answer that way. So I will toss out this question to you all myself. |
|
| 1679. |
Solve : change date display format in DOS? |
|
Answer» How can I change the current date format from DD/MM/YYYY to YYYY-MM-DD? ...since the name rule is 8.3 formatWhy? 8-) PUT the date in a variable and substitute it: :: -------- FOR /F "TOKENS=1-3 DELIMS=/ " %I IN ('DATE /T') DO set datum=%K-%J-%I set datum=%datum:~2% :: ------ Should give you 06-09-12 hope it helps uli Quote Put the date in a variable and substitute it: It DOES work! Thanks a lot. Quote Presumably your OS is a state secret. Try using the KISS method, drop the hyphens: hehehe,,,,,,,This is my own rule. Because all my other files and folders are stored in this 8.3 format, and I don't want an exception, just to keep them look nice and neat . Thanks, Sidewinder.Hi, uli_glueck and Sidewinder, thanks for your contributions to this TOPIC. The code provided DOES work! Now I have an idea on how to deal with the date string. |
|
| 1680. |
Solve : Cryptic (to me) dos syntax? |
|
Answer» every now and then I come across batch files EXHIBITING a strange syntax ".." means "one level up". For example, if you're in Sure - but the OP indicates that CD, or any other valid COMMAND such as DIR, is not shown in the batch file... ..\ can be used as the last directory in the Path statement but here :-? Got me kerfluggled... Quote OK? OK! As I said though I knew the cd.. syntax, what I wasn't sure of, is whether issuing a ".." command LIKE that would be OK'd in a batch file especially at the very beginning of a line. A sort of shorthand writing, so. And very powerful too I tried and saw that if I am, say in C:\PROGRA~1\xerox\nwwia>_ and type ..\..\dosbox-0.65\dosbox.exe not only does it work, but what happened is in just one stroke I skipped 3 cd commands, BACKED up 2 levels and descended 1 side level all in one Great isn't it |
|
| 1681. |
Solve : DOS Batch - Remove all Directories with a specific? |
|
Answer» Looking for syntax to remove all folder on a machine with a specified |
|
| 1682. |
Solve : DOS config sys error loading ghost boot disk? |
|
Answer» I am having trouble getting ghost 8.2 network BOOT up disks to work. |
|
| 1683. |
Solve : Logging into Admin Account through DOS Prompt? |
|
Answer» In my Windows XP, I mainly use a non-admin account to do most things, and to protect myself a little, HOWEVER, some batch file commands require admin RIGHTS, so I usually have to log out of my non-admin, and load up the admin. Is there a way that I can just log into admin right through the dos prompt itself? |
|
| 1684. |
Solve : i need command help? |
|
Answer» this comp I am working on is completely messed up. I have TRIED to reload windows but when it gets started it freezes up and have to close or ignore that message and it just completely blanks out. I know i need to do a complete system restore but there is a file that i need to backup in mydocuments THATS extremely important. I have to do this i assume through DOS because windows will not boot at all. The A drive is not wanting to write anything what do I do?First thing to do is tell us something about your pc. For EXAMPLE your OS, hardware configuration, do you have a legitimate copy of your OS cd :-? Are you trying to boot up from a bootdisk, if so which one. What is your file system NTFS vs Fat32 vs Fat16 :-? First thing to do is tell us something about your pc. For example your OS, [highlight]hardware configuration, do you have a legitimate copy of your OS cd :-? Are you trying to boot up from a bootdisk, if so which one. [/highlight] What is your file system NTFS vs Fat32 vs Fat16 :-? Please answer the highlighted questions Can you boot from a floppy? If not, boot from the CD. You might have to go into bios and change the boot order. Booting from the floppy defaults to 'with cdrom support' and the CD has that as option 2.i've tried booting from the cd and it will not boot the only thing i can try to get the cd to do is to REINSTALL windows and not even a minute after setup is running it gives me an illegal operation message and crashes.When you boot from the CD select option 2. If you don't select an option it defaults to running setup. |
|
| 1685. |
Solve : connecting monitors? |
|
Answer» Help please, |
|
| 1686. |
Solve : Batch file not executing in batch mode?? |
|
Answer» I have a batch file that executes the same command several times and redirects the output to a text file. This used to work flawlessly. Now, after the first time it executes, it says that the file is in use by another process. I ran the batch file without redirecting the output, and it works. So it seems to be narrowed down to the ">" operator. Why is this holding my file open? And how do I fix it? Regardless, shouldn't a batch file wait until the process returns before continuing on to the next command? In theory yes. It seems this redirected output file has no connection to FOO and it's Windows thats opening the redirected file because of the reference on the program call and it's Windows that's closing it, but doesn't get to it right away. This would account for the file being open when the next FOO starts. Just a thought. 8-)Would the Conditional Processing Symbols & or && be of use :-? See here. In the end, it was explorer.exe that had the file open. If there's a window open in the background with the containing folder, it seems Windows keeps checking on the file each time it's updated, so it takes control over the file. With all Explorer Windows closed, it works again. Thanks for all your help |
|
| 1687. |
Solve : How to enable or disable xp firewall from the command line?? |
|
Answer» I recently remote installed Symantec Endpoint virus defense software on a bunch of computers on the same subnet and just found out that installing it didn't automatically disable the Windows firewall on the workstations. (I used to use McAfee in the past, it always disabled the windows firewall automatically.) |
|
| 1688. |
Solve : >> write command help needed? |
|
Answer» how would i code this to give "HELLOWORLD.txt" specific ATTRIBUTES such as hidden or read only? |
|
| 1689. |
Solve : Problem with printing multiple pdf-files via batch file? |
|
Answer» For work I need to print around 360 different pdf-files. the printing is done via a batch file, containing the following code: |
|
| 1690. |
Solve : how to read the number of files in a folder? |
|
Answer» hello Then how to make a loop command for doing 7 times in batch? Like other programming: You use the FOR command with the /L switch FOR /L %%[single letter a-z,A-Z] IN (start,step,end) DO command e.g. Code: [Select]FOR /L %%i IN (1,1,7) DO echo %%i or you can have more than one line in the loop using parentheses Code: [Select]FOR /L %%i IN (1,1,7) DO ( echo This is loop number %%i echo %time% ) or Code: [Select]set start=3 set step=2 set limit=27 echo Here are some odd numbers... FOR /L %%i IN (%start%,%step%,%limit%) DO ( echo %%i ) to see full details type FOR /? at the prompt. If you are used to other languages, you may find that you cannot set and read variables INSIDE the loop as you could in other languages, as cmd.exe expands all variables at runtime, and variables contained in parenthetical expressions like these are blank at runtime. Code: [Select]IF "%variable1%=="%variable2%" ( set message=EQUAL echo %message% ) FOR /L %%i IN (1,1,7) DO ( if "%%i"=="5" set message=FIVE echo %message% ) In those two examples, %message% will be blank inside the parentheses [but not afterwards]. You need to use delayed expansion. Enable it like so setlocal enabledelayedexpansion and the variables use ! instead of % so these would work Code: [Select]setlocal enabledelayedexpansion IF "%variable1%=="%variable2%" ( set message=EQUAL echo !message! ) setlocal enabledelayedexpansion FOR /L %%i IN (1,1,7) DO ( if "%%i"=="5" set message=FIVE echo !message! ) |
|
| 1691. |
Solve : net send isnt working?? |
|
Answer» NET send 0.0.0.0 "msg" why does it return a error, the message alias COULD not be found on the NETWORK?If I remember correctly one or two things have to be set correctly: 1. the service "Messenger" has to be RUNNING on both the sender and the receiver computer 2. File and printer sharing has to be enabled in the firewall setttings of the receiver computer. (I am not sure about the sender computer). |
|
| 1692. |
Solve : Is there a way to loop through a set of commands and send an email after each? |
|
Answer» HELLO All, I have this batch file with the following commands. All commands are executed in sequential order from the "push" directory. This batch file is called in another batch file. I need to send out an email after each "call" command completed. I used the "GOTO" command to jump to the ":MailSend" section and send out the email. However, I don't know how to get back to the "pushd" directory and execute the next "call" command. I would really appreciate your help. Also, if anyone can help me construct a "FOR" loop to iterate to the "call" commands instead of having to write them 3 times in the file. For example, I LIST the first "call" command three times because I want to run it 3 times. I would like to only write it once and loop 3 times or more . I look forward to getting reply from anyone who can assist with these. Thanks.... ECHO ON pushd D:\Program Files\XXX\zzzShared\plugins\com.yy.aa.test.lt.cmdlineexecute_7.2.0.v200803051948 call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt" call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt" call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt" echo Three 15 minutes for 15 users runs completed. call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig1S.txt" call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig1S.txt" echo Two 2 hours for 40 users runs completed. call cmdline -configfile "%USERPROFILE%\dirx\SchedConfigMS.txt" call cmdline -configfile "%USERPROFILE%\dirx\SchedConfigMS.txt" echo Two 2 hours run with 4 stages completed. call cmdline -configfile "%USERPROFILE%\\dirX\SchedConfigLR.txt" echo Twelve hours long duration for 40 users run completed. echo A total of 8 runs completed. popd echo DONE !!! :MailSend popd mailsend1.15b5.exe -smtp server -l "emailaddressfile.txt" -f fromtoemail -sub "Subject" < "msgfilel.txt" :End popd ECHO Run #1 completed. i dunno if this will work but you can make another file with Code: [SELECT]mailsend1.15b5.exe -smtp server -l "emailaddressfile.txt" -f fromtoemail -sub "Subject" < "msgfilel.txt" and in your code add Code: [Select]call thisfile.bat and for for loop Code: [Select]for /L %%a in (1,1,3) do ( call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt" if %%a equ 3 goto A )Hello devcom, Thanks for the quick response. You're awesome!!!!!!!!!!!!!!!!!!!! I took your suggestions and modified my script, it worked beautifully. Added the email code to a file call "MailSend.bat" and call it in the script Code: [Select]mailsend1.15b5.exe -smtp servername -l ".\XXDIR\EmailAddressfile.txt" -f fromemailaddress -sub "subject text" < ".\XXDIR\mesgfile.txt" pushd D:\Program Files\XX Pushd is included in the "Mailsend.bat" because I need it to switch to this directory to execute the next "call" command after sending the email . For the "FOR" loop, I divided all the "call" STATEMENTS into group (i.e A, B, C, D). and called "MailSend.bat" within the loop. Code: [Select]:A for /L %%a in (1,1,3) do ( call cmdline -configfile "%USERPROFILE%\XX\SchedConfig.txt" popd call ".\MailSend.bat" echo A 15 minutes run for 15 users and 1 stage completed. if %%a equ 3 goto B ) popd is included because I need to to switch to mailsend's directory before calling "MailSend.bat" Thanks again devcom Would you mind reviewing other batch scripts for me and make suggestions where I can improve and make them more robust? Glad i could help Quote Would you mind reviewing other batch scripts for me and make suggestions where I can improve and make them more robust? ok just PM me |
|
| 1693. |
Solve : Can FOR command use with range?? |
|
Answer» Hi, |
|
| 1694. |
Solve : Delete files not only in Root but in Subfolders too? |
|
Answer» Ok im TRYING to make a batch program that will delete BAK and TMP FILES throught my HD. but im stuck on one thing. Deleting the folders in the subdirectories too. how can i do this? echo off While the solution posted works for most files, filenames with embedded spaces will be bypassed. A more global solution might be: Code: [Select]echo off for %%x in (tmp bak) do ( for /f "tokens=*" %%a in ('dir /a c:\temp\*.%%x /b /s') do echo del /q/f "%%a" ) ) Using path as a variable will change the system path until the command window is closed. Better to use another variable name or hardcode the directory. The del command has a /s switch for subdirectories. Use at your own risk. Just my 2¢ I dislike posting DESTRUCTIVE batch code, so I added an extra echo prior to the del command. Once you are happy with the preview, you can remove it.Sidewinder, May I ask how do you highlight and frame the code part of your messages? I looked at all toolbar options but I couldn't found any RELATED command. Geza For the code box use the # BBC tag. For the bold highlight, use the "B" BBC tag The icons are located under the subject line when replying to a post. I'm sure SOMEONE else might explain it better, with pictures even. Code: [Select]I got it! Thanks!thanks diablo and sidewinder it works |
|
| 1695. |
Solve : Command Line command for manipulating word file????? |
|
Answer» Dear reader, Is there any command line command to manipulate the word document. Batch code can open a document. End of STORY. Any of the scripting languages that are COM aware can manipulate the document. Example to add header to first page of document: Code: [Select]Const wdHeaderFirstPage = 2 Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Add() With objDoc .PageSetup.DifferentFirstPageHeaderFooter = True .Sections(1).Headers(wdHeaderFirstPage) _ .Range.InsertBefore _ "Written By Sidewinder" End With objDoc.SaveAs "C:\Temp\Test.doc" objWord.Quit Save SCRIPT with a VBS extension and run from a command prompt as cscript scriptname.vbs More information can be found here. Good luck. Thank you Sidewinder It does what i want to do. But sometimes it replaces all header if there is the header in all three (left,center and right) alignment. Is it also possible in case of footer having page number in it? Should maintain the alignment of the page number. Thank you Ramesh Shrestha Quote It does what i want to do. But sometimes it replaces all header if there is the header in all three (left,center and right) alignment. If there is already text in the header, you'll need to capture it, align your new text with the existing text, then push everything back into the header. I added to the existing snippet for a page number footer: Code: [Select]Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Add() With objDoc .PageSetup.DifferentFirstPageHeaderFooter = True .Sections(1).Headers(2).Range.InsertBefore "Written By Sidewinder" End With Set objRange = objDoc.Sections(1).Footers(2).Range Set objTemplate = objDoc.AttachedTemplate objTemplate.AutoTextEntries("Page X of Y").Insert objRange objDoc.SaveAs "C:\Temp\Test.doc" 'objWord.Quit Page number is formatted 1 of N. Hint: Scripting Word can be difficult; try using the Word GUI and record a macro of what you're attempting to do. Viewing the resulting VBA can usually point you in the right direction. Good luck thank you Sidewinder for the reply It will be helpful if you provide me the vbscript for capturing the header and footer content. Thank you Ramesh Shrestha Quote It will be helpful if you provide me the vbscript for capturing the header and footer content. I'm sure it would be. What have you DONE to capture the header and footer? Checking Google might have turned up this article. Have you played with the posted code? Most of the logic was there, a tweak here, a tweak there, and you'd have found a solution: Code: [Select]Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Open("c:\temp\test.doc") sHeader = objDoc.Sections(1).Headers(2).Range.Text sFooter = objDoc.Sections(1).Footers(2).Range.Text WScript.Echo sheader, vbCrLf, sfooter objWord.Quit Did you even try using the Word GUI? Like I mentioned, recorded macros can be somewhat dense, but with a little effort they can be very educational. Quote from: Sidewinder on July 21, 2008, 03:54:09 AM QuoteIt will be helpful if you provide me the vbscript for capturing the header and footer content. Hi Sidewinder, Is there a way to manipulate the Excel file through this just like word? Yes. Any program product that comes with a COM server can be scripted with a COM aware script language (REXX, VBScript, Python, ETC). Just about any Microsoft application from Access to the Zune can be scripted. Surprisingly (or maybe not), simple Microsoft APPS like notepad cannot be scripted other than sending keystrokes to the window. There is even a ActiveX (COM) object for Mozilla Much of the documentation can be found on MSDN and having a editor with intellisense can be very helpful. |
|
| 1696. |
Solve : Have to be in C:\Windows\System32 to run files in that folder? |
|
Answer» ...and I thought that SINCE that is in the System Path, I could run files in C:\Windows\System32 from anywhere? Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem; <may be much more, but the first 2 in blue should be at the beginning That's it! Java had pre-empted Windows at the beginning of my path, and once I moved it back in the queue and restarted, it worked just like I thought it should! Thanks! This happened to me, and I SUSPECT a number of other people. For some reason I'm not sure of, the java install sometimes ADDS the Java binaries folders to the beginning of the PATH system variable, instead of appending them to the end as they should be. Furthermore it does it badly so that the PATH becomes malformed. As you can see, the PATH system variable is a semicolon-separated list of folder paths. For commands external to cmd.exe, the system searches each folder in the PATH system variable in turn. If the list becomes DAMAGED in some way (e.g. a missing semicolon), before it gets to "C:\WINDOWS\system32;C:\WINDOWS;" then the system just gives up & you get the "not recognized as an internal or external command" message. That's why these folders should be at the start. That way, the system finds the commands fast, early in the search. An unfortunate side effect of this method hunting along the PATH variable is that by adding a folder to the beginning of the PATH you can intentionally or accidentally pre-empt an external command with another identically named .exe, since the system executes the first one that it finds. |
|
| 1697. |
Solve : Need help with a bat menu? |
|
Answer» I am new to this, and saw there are some batch menu's.
echo. set /p choice= if 'choice'=='5' goto five if 'choice'=='6' goto six if 'choice'=='7' goto seven if 'choice'=='8' goto eight if 'choice'=='0' goto zero echo. goto menu :five :six :seven :eight :zero goto menu :two echo off cls :menu echo Select Option For Flash Drive Banner echo ==================================== echo [9] Copy echo [10] Paste echo [11] Zip echo [12] Execute batch file echo
echo. set /p choice= if 'choice'=='9' goto nine if 'choice'=='10' goto ten if 'choice'=='11' goto eleven if 'choice'=='12' goto twelve if 'choice'=='0' goto zero echo. goto menu :nine :ten :eleven :twelve :zero goto menu :three echo off cls :menu echo Select Option For Christmas Banner echo ================================== echo [13] Copy echo [14] Paste echo [15] Zip echo [16] Execute batch file echo
echo. set /p choice= if 'choice'=='13' goto thirteen if 'choice'=='14' goto fourteen if 'choice'=='15' goto fifteen if 'choice'=='16' goto SIXTEEN if 'choice'=='0' goto zero echo. goto menu :thirteen :fourteen :fifteen :sixteen :zero goto menu :four echo off cls :menu echo Select Option For New Years Banner echo ================================== echo [17] Copy echo [18] Paste echo [19] Zip echo [20] Execute batch file echo
echo. set /p choice= if 'choice'=='17' goto seventeen if 'choice'=='18' goto eighteen if 'choice'=='19' goto nineteen if 'choice'=='20' goto twenty if 'choice'=='0' goto zero echo. goto menu :seventeen :eighteen :nineteen :twenty :zero goto menu :exit exit Quote from: ontheroad on July 31, 2008, 11:02:49 AM For some reason, I cannot get the exit command to work with this one. You must not have anything else on a label line apart from the label.hmm...i tried what you wrote and it still won't exit. thx thowhy not do Code: [Select]if 'choice'=='Q' exit? Quote hmm...i tried what you wrote and it still won't exit.you wrote Code: [Select]:exit exitand it does not work ? EDIT: try that signs for menus Code: [Select]echo.ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ echo.ş echo.ş echo.ČÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍI tried your "if choice" and it did not work for me. :exit exit ^that did not work for me either... I do not understand why. I do appreciate you guys trying to help...i'm just stuck try Code: [Select]if /I '%choice%' equ 'Q' exitwhat os you have ?You aren't using variables properly. Clue: what is this? %YES, that worked. Thank you for taking your time and assisting me. Greatly appreciate it. Quote from: Dias de verano on July 31, 2008, 12:14:21 PM You aren't using variables properly. Clue: what is this? % My bad Quote from: macdad- on July 31, 2008, 03:45:55 PM Quote from: Dias de verano on July 31, 2008, 12:14:21 PMYou aren't using variables properly. Clue: what is this? % I am surprised at you, macdad. With a SIG like yours as well. ok ok. i just missed the %s and went with it. and yes i think that its a bit to over done(my sig) |
|
| 1698. |
Solve : My C: prompt? |
|
Answer» I feel like I have alot of problems with the C: prompt in itself. Alot of times, it won't show files that do certainly exist and I have to go through a number of steps just to get the dir / function to show that the file does exist. I feel like I have alot of problems with the C: prompt in itself. Alot of times, it won't show files that do certainly exist and I have to go through a number of steps just to get the dir / function to show that the file does exist. Could you answer this question I asked? Quote from: Dias de verano What "steps" are they? Quote many times I will try to open a file from a specific directory and the C: prompt responds with "the file does not exist" even though it does Tell us precisely what you are doing. Give the file name and the directory name and show exactly what you are entering at the COMMAND prompt. Hey Baby ...!! I have the same problem.. It's hard to show you exactly what I'm doing because it doesn't always do it. I just checked it again, to see if it worked or not, and it did (figures)... but, this is pretty much it... C:\Documents and Settings\Compaq_Owner\Perl\us.jpg and the C:prompt would respond that that file did not exist or that the path was not specified. Right now it works. Otherwise, trying to change the name of the directory Documents and Settings by running the code: REN Documents and Settings Diane does not work and responds the system cannot find the file specified. Trying to implement a new instance of C: prompt without having to exit, I haven't been able to figure out yet, even though I've read all of the help commands available (not really the same issue, though). I have to exit or close out of the C: prompt alot of times just to cd to another directory--it just won't do it. These are the first things on my list, I guess. Thank you Diane Quote REN Documents and Settings Diane does not work and responds the system cannot find the file specified. Yes, folder/file names which include spaces should be enclosed in "" otherwise the system will look for a one word folder name, in this case Documents. However, the D & S folder is widely used by the system and if you manage to rename it the system will not be able to find it until you reset necessary Environment Variables, does your level of knowledge allow you to do this? Quote Trying to implement a new instance of C: prompt without having to exit, I haven't been able to figure out yet,While at the Command Prompt enter "Start cmd" (without the "") another Command Prompt window will open. Quote I have to exit or close out of the C: prompt alot of times just to cd to another directory--it just won't do it.Can't advise you on that problem until you tell us exactly what your default directory is and what you are entering at the Command Prompt and give a list of any error messages when this happens. First thing, I can't figure out how to use the freaky quote button. Every time I highlight something then click "quote" the program quotes EVERYTHING!!! Please help!!! Also, "does your level of knowledge allow you to do this?" No, thank you for giving me a heads up. "Can't advise you on that problem until you tell us exactly what your default directory is and what you are entering at the Command Prompt and give a list of any error messages when this happens." My default directory is C:\Documents and Settings\Compaq_Owner> otherwise, I will compile the list of error messages next time they occur. Thanks. Is it safe to ren Compaq_Owner, then? Thank you Diane Quote First thing, I can't figure out how to use the freaky quote button. Every time I highlight something then click "quote" the program quotes EVERYTHING!!! Please help!!!Hilight what you want to quote and copy it to the clipboard (click edit>copy). Go to the Post reply form and click on the quote BBC tag (second from right) then paste the quote between the tags (click edit>paste). Quote Is it safe to ren Compaq_Owner, then?The following is quoted from this site with slight alteration: Quote When you create a user account, Windows XP creates and populates a subfolder of the C:\Documents and Settings folder WHOSE name is the account name. In your case, you'll find a folder named C:\Documents and Settings\Compaq-Owner. That puts it much better than I could. The Compaq-Owner account and folder would probably have been created during the initial Setup process. This is part of what I posted earlier Quote However, the D & S folder is widely used by the system and if you manage to rename it the system will not be able to find it To get to the command prompt windows are you starting Cmd.exe or Command.com? |
|
| 1699. |
Solve : SET will not work, variable keeps its old value? |
|
Answer» The script will be executed via command prompt on XP. |
|
| 1700. |
Solve : renaming a directory? |
|
Answer» I want to rename a directory without using Windows to do it. My default directory is Documents and Settings with Compaq_Owner as a subdirectory.I've just re-read the quoted post and if your problem is typing so many letters to CD that can easily be sorted. You could just type one letter to CD to a specific directory\subdirectory\subdirectoy\subdirectory\filename... You could also open the Command Prompt window by using a desktop shortcut... Interested Whoa - please back off !!! Assuming you are using Windows XP or Vista this is a mine field. Please use the DOS command SET. This will show a list of environmental variables. Included should be :- USERPROFILE=C:\Documents and Settings\Compaq_Owner I do not know how Windows does it, but when it starts and you log on, it determines your user profile, and your emails etc. are kept private in the above folder and are private from those of other user profiles. An awful lot of Windows hinges upon USERPROFILE. Change any PART of the name "C:\Documents and Settings\Compaq_Owner" and you will lose your emails etc., and you may find you have lost Windows altogether - but at least you will get experience of booting into the BIOS !!! Do you really have to type any letters to change directory ? I use Start => Run... => Open => I then type "CMD" and I get an imitation DOS / Command Shell, and automatically it shows me a DOS prompt C:\Documents and Settings\Dad> (Because my DAUGHTER owned this computer when a "Dad" profile was added for me.) From there I have immediate access to "My Documents" and everything beyond, without ever having to type "C:\Documents and Settings\Dad". An alternative to Start => Run... => Open => is a desktop shortcut, which can be aimed anywhere, including :- "C:\Documents and Settings\Compaq_Owner" Regards Alan |
|