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.
| 3201. |
Solve : insert line in text file with loop? |
|
Answer» Hello, looks like homework... but until you prove that it isnt, try to useCode: [Select] for /? in cmd The rule of thumb is "Innocent untill proven guilty", which most people don't seem to follow in here...if you are able to use tools for string processing, such as gawk for windows(see my sig), Code: [Select]C:\test>more file.txt line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10 C:\test>gawk "NR%2==0{print;print \"text\";next}1" file.txt line 1 line 2 text line 3 line 4 text line 5 line 6 text line 7 line 8 text line 9 line 10 text the example prints "text" for every 2 lines.I'm actually still trying to figure out what self-respecting school WOULD teach batch.Thanks for the comments so far. I'm not able to use tools like gawk or sed. It isn't possible to use internet on the machine I have to do the task I described. I know it sounds lazy but at the moment I don't have the time to teach myself how to do the trick, so can anybody help me with this? |
|
| 3202. |
Solve : Computer stuck at start up? |
|
Answer» Hi I have an old desktop computer (Windows 95?) which used to work fine until we moved house. it was in storage (did not get damp ETC) and now it will not work. It turns on fine and goes through the page where you can press F2 for set up options etc and then goes to the big blue screen saying with clouds saying Windows 95 but never goes any further. Does anyone know what I can do to sort this out? All i want to do is retrieve some files off of the computer (a big MUSIC playlist thing) and transfer it ONTO another computer but I cannot fix it. The monitor is fine as it works on the other computer we have. Any ideas would be GRATEFULLY received! ThanksIf thats all you need, whip the disk out and plug it into your new pc, or stick it into a usb caddy - it will then be very easy to copy off anything you want!hello again! thankyou very much for your reply. sorry to be a total computer moron but how do i remove the disk? what disk?! thanks!Slave Drive Tutorial |
|
| 3203. |
Solve : How doi get the old file ccording to time it was created?? |
|
Answer» Quote from: DIAS de verano on April 08, 2009, 03:08:46 AM /a-d - directory attribute negated (don't include directories in list)/a-d - directory attribute negated (don't include directories in list) + EXPLICIT include hidden&system file(s) Quote from: kishorei on April 08, 2009, 04:09:28 AM How do i move all these files orderly date wise to a specified folder?care to give some example?Test1.txt craeted at 2/4/09 Test2.txt craeted at 3/4/09 Test3.txt craeted at 4/4/09 Test4.txt craeted at 5/4/09 First i want to sort the above files by date wise and move the old file first. Then i want to sort the REMAINING THREE files and move the old file and so on.. CODE: [Select]@echo off & setlocal enabledelayedexpansion for /f "tokens=*" %%a in ('dir/b/od/tc/a-d *.txt') do ( echo. dir/tc "%%a"|find/i ".txt" set/p c=Move %%a (y/n^)? for %%b in (y Y) do if !c!.==%%b. move "%%a" c:\temp\ && echo done ) |
|
| 3204. |
Solve : Minimise the dos window? |
|
Answer» Is it not possible to minimise the dos window ? Well,get amusements. But I think I will also get amusement if if tou help LMAO when did C come into this?Quote from: BC_Programmer on April 09, 2009, 10:45:39 AM
Quote from: BC_Programmer Most perform this task by writing a small C programthat's what I thought; just confirming... In any case I'd go with the SECOND option, it may be less hip but it works. also it coincides with the method already provided. I'd download cmdow.exe and use CMDOW @ /MIN |
|
| 3205. |
Solve : Monitoring processes to trigger an action? |
|
Answer» Hi there, Therefore, I would like the second application to run after the login has occured. Monitoring system processes I notice a unique programme runs when the login is completed. how do you notice that programme is running?? what the name of it? post your current batch code here.Hi there, I notice the programme is running by going to Windows Task Manager and monitoring the processes. After the user has 'logged in' the same process loads. This is called viewserver.exe. I would like this process to trigger the next stage of the batch file. ThanksCode: [Select]@echo off >$$$.vbs echo q="select * from __InstanceCreationEvent within 1 where " ^& _ >>$$$.vbs echo "targetinstance ISA 'win32_process' and targetinstance.name='viewserver.exe'" >>$$$.vbs echo getobject("winmgmts:").execnotificationquery(q).nextevent echo First stage of batch file for %%a in (cscript//nologo del) do %%a $$$.vbs echo viewserver.exe creation detected echo next stage of the batch fileHi Reno, That is brillaint, thanks... I was using the follwowing but got into trouble. I could sometimes see the error level change, but the next programme would not launch, or both would launch without seeing the trigger.......... @echo off START C:\Programme1 PING 1.1.1.1 -n 1 -w 1000 >NUL :LOOP1 tasklist>C:\tasklist.txt cd c:\ FIND "ViewServer.exe" c:\tasklist.txt PING 1.1.1.1 -n 5 -w 1000 >NUL echo %errorlevel% IF %ERRORLEVEL% EQU 1 GOTO LOOP1 ELSE START C:\SEARCH DEL c:\tasklist.txt if you want to check errorlevel for find then you must move that if Code: [Select]@echo off START C:\Programme1 PING 1.1.1.1 -n 1 -w 1000 >NUL :LOOP1 PING 1.1.1.1 -n 5 -w 1000 >NUL tasklist>C:\tasklist.txt cd c:\ Find "ViewServer.exe" c:\tasklist.txt IF %ERRORLEVEL% EQU 1 GOTO LOOP1 ELSE START C:\SEARCH DEL c:\tasklist.txt that old code was looking for PINGs errorlevel |
|
| 3206. |
Solve : How to insert a carriage return? |
|
Answer» I'm trying to merge a lot of archives in one, with WinXP - CMD |
|
| 3207. |
Solve : Problem printing in dos 6.2? |
|
Answer» try unchecking fast printing direct to port.
The paper size,paper source, and other settings are stored on the PC. reinstalling the driver has the effect of clearing these settings, regardless of how many "years" it has been set; and you've tinkered with a large number of drivers. BC I have re-installed the HP LaserJet lllP and have therefore gone through the panels that you have shown. There is only an Upper Tray [no other] to select and likewise the paper size is 8 1/2 x 11. And the PRINTER informs one when the tray is empty or not quite properly inserted in the tray.. And [as layman] cannot quite see why the printer/program is SELECTIVELY printing files in WSWin.... Of course as an expert you are in a better position to suggest probabilties... whereas my focus may lie in long usage... KenThanks BC, And sorry Kahawn, kinda doing this blindy.Quote from: macdad- on October 27, 2009, 04:40:02 PM Thanks BC, As one who is blind in both eyes... Am now looking to see if there are any more 'contributors' who will dip their toes and perhaps take the thread to 100! Has been suggested elsewhere that it is a problem with 'handshaking'... whatever that implies/means... perhaps that is what you [and BC] are driving at?PROGRESS REPORT Read the HP Printer Manual where it said that to override the Display messages hold down the Alt key and depress the Continue button. IT WORKS... When the Display shows 'MP Load Letter' it will print the Notepad document as well as the WSWin 'archive' file. However this must be done for EVERY PRINTOUT. [unless one is printing multiple pages in that document... not checked this as yet]. The Manual also states that the computer software will override any software in the Printer. So I conclude there is some message in Win 3.1 that brings up the 'MP Load Letter' in the Printer Display. So are there any experts in Win 3.1 that can identify the problem? Thanks PROBLEM SOLVED... Found that when the printer display showed 'MP Load Paper' I looked at the Page Setup for the document in the Computer and found that they were 8 x 11 1/4... changed them to A4 and Voila! the document printed. Now why the settings in the documents changed to Letter is a mystery as I have always been using A4 for preparing my files. In any case I would like to thank macdad and BC for their support and for introducing me to new facets in Dos and Win 3.1. Ken It would have changed when you fiddled about with the drivers, or perhaps tweaked something else; the printer page, or more precisely, what shows up on the printer page, is controlled by the driver but that data is stored in... Win.ini, I believe. Now, if that printer had a more descriptive error message, you might have avoided all this TEDIUM!BC Thanks for your comment BC However I feel that the Printer Display is a very small area and the 'message' fills it.. If I were a computer buff [and perhaps 25 years younger] I would have worked it out quicker... with hindsight it cannot have been clearer : MP Load Letter [sized] Paper! No pressure to solve the problem in retirement. All this 'tedium' [as you put it] has been solved with two simple procedures: re-setting WSWin to its original settings in Wswchange ws [to find the 'drivers'] and looking at the Page Setup before printing. Reflect on the time when I was a Manager/Accountant in a small firm and did not have the patience to wait for the engineer to visit the office and would tackle any problems with the photocopier myself....oh yes, I keep forgetting the display is on the printer, not the screen, not a lot of real estate there. |
|
| 3208. |
Solve : Calling DOS batch file from C programme? |
|
Answer» Has anyone any familiarity with CALLING batch files from C? place the %1 in quotes, as in, "%1". Quotes are only required if a file name has embedded spaces or special characters that would mess up the interpreter. That does not appear to be the case here. I was thinking more along hte LINES of the hyphen, but I checked, hyphen is acceptable either way. |
|
| 3209. |
Solve : SFTP in Dos cmd? |
|
Answer» Hi |
|
| 3210. |
Solve : question about a bat file at login.? |
|
Answer» Thanks for all you help. start IEXPLORE.EXE Internet Explorer works well when INVOKED without a path. For more information you have to get into the Microsoft SDK. |
|
| 3211. |
Solve : saving a file every 30 seconds? |
|
Answer» I am experienced DOS user from back in the old days but have never had this type of problem so I hope someone can help or at least answer this for me. ... Yes and yes. With a goto statement you can make it loop. http://www.vfrazee.com/ms-dos/6.22/help/goto.htm To make it wait 30 seconds, one way is to USE a free third party utility program. ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/ and look for wait.zip Quote We are looking at other methods like a backup program in XP to backup a file or directory every 30 seconds. The data changes in these files and we need to constantly send it to the other computer in case or experiment crashes. Syncback is very nice ( and there is a free version ) backup software. You can read more about it, and download it here: http://www.snapfiles.com/get/SyncBack.html but I don't know if you could schedule it via Windows scheduler for every 30 seconds. Maybe the closest you could get would be once per minute? Unless... you ran Syncback from the command line, and used wait.exe to make the batch file wait 30 seconds... .. it's an idea.... Quote Thanks in advance for any suggestions or help I hope this helps. You can use, presuming you are running an NT family operating system, (Windows NT4, 2000, XP, 2003, Vista, etc) a utility called Sleep.exe which is part of the Microsoft Windows Server 2003 Resource Kit. This will suspend operation for either a specified number of seconds or milliseconds. http://download.microsoft.com/download/8/e/c/8ec3a7d8-05b4-440a-a71e-ca3ee25fe057/rktools.exe Code: [Select] REM This is a "label" :loop REM do some stuff REM wait 30 seconds sleep 30 REM do some more stuff REM goto next quits the loop REM loop again goto loop :next what about: Code: [Select]ping -n 1 -w 30000 1.1.1.1 >nul or Code: [Select]@echo off setlocal enableextensions :SETUP set sec=0 set /a sec=%1 set cout=0 :LOOP set time_1=%time:~-4,1% :ADD set time_2=%time:~-4,1% if not %time_1%==%time_2% (goto COUNT) goto ADD :COUNT set /a cout+=1 if %cout% equ %sec% (goto :EOF) goto LOOP goto :EOF ?? then he dont need any .exe Thanks for the suggestions. We actually like Syncback and it works fine for our needs.....sort of. We are communicating between 2 computers using 2.4Ghz radios that supposedly simulate a network when all is well. One is attached to a helium balloon and will travel up to 30kms before exploding and sending the payload back to earth. We need to transfer data while the unit is working in case we don't RECOVER the payload.We are having a few hiccups and need to get this set up properly before we tackle the automatic save stuff. I also have tried robocopy which is a MS utility, basically a super xcopy command. We can do that in 1 minute saves which is fine. Thanks again for all the help. Dave |
|
| 3212. |
Solve : spaces and batch files? |
|
Answer» Hi,I am trying to find a way to copy a file (*.pst) to somewhere else that I choose. My Copy Batch file looks like this: Amend your For command line to include "Delims=*" and see what happens. Good luckExcellent. That worked PERFECTLY. I probably should have asked this question earlier today and saved about 4 hours of frustration. Thanks a lot. You're very welcome and thanks for coming back to report your success.. Can you explain what that edit does exactly please?I'm no expert but... The For command parses input until a delimiter is found. The default delimiters are space and tab. In your script the first line of pst.txt would be parsed until a space was encountered at which point %%a would be set to the value C:\Documents By using "Delims=*" the default delimiters no longer apply. "Delims=" could also have been used as could any character which does not appear in the input being parsed. As you will know entering For/? at the Command Prompt displays info on the For command.I understand. Thanks again. |
|
| 3213. |
Solve : Displaying the file creation date? |
|
Answer» Quote from: BC_Programmer on May 05, 2009, 02:05:18 PM does DOS even maintain both the modified AND created dates? I'm not sure I remember correctly. There is no created date in MS-DOS 6.22. Version 7.10 and later can store CREATION/modified but only when LFNs are enabled. Quote from: gh0std0g74 on May 04, 2009, 06:15:18 PM because of reasons like what you have posted? requirement changes? in the past you don't need to find out about creation date, but now you do, and then you found out that DOS6.22 doesn't have the facility to allow that? worse, you went to search for a third party tool and found it does the work you want, but is not written to be run on DOS6.22 because its too old? are these valid reasons for you?Wow, steady.. Do you have ANGER issues with MS-DOS? I looked for a third party tool, did I? I was not aware that I'd done that. Have you tried my QBasic SOLUTION? Hi Dias, Thanks for the query, could I trouble you for a few pointers on dissecting the text file (I can DIRECT it to the file ok, but to get chunks back may involve a bit of heartache) Thanks for taking the time to respond, I appreciate the 'help each other out' attitude some people have. I'm not sure if there's any way I can help you out.. All the best,Sorry Dias, just seen your Qbasic solution, I'll give it a try, eternal thanks.Quote from: AlexTheGrater on May 07, 2009, 10:11:27 AM just seen your Qbasic solution Code: [Select]REM Open the file previously created REM Which has the output of DIR open "dirline.txt" for input as #1 REM skip over the first 5 lines of the DIR output for j=1 to 5: line input #1, d$:next j REM Get the next line line input #1, a$ REM I omitted this, it is probably good housekeeping REM to close the file close #1 REM Show the part of the line with the date / time info REM that is, the 10 characters starting at position 29 print "File created on "; MID$(a$, 29, 10) REM exit back to batch file system Thanks, Diaz. It works! You're a star.. |
|
| 3214. |
Solve : This is Bug in .bat file?? |
|
Answer» THANKS, My computer have wscript.exe and cscript.exe. I used file BAT with Quote cscript //nologo scriptname.vbs > file.txt and it worked, thanks again You ran the script twice. |
|
| 3215. |
Solve : pc will not boot from boot devices? |
|
Answer» pc Gateway X500 |
|
| 3216. |
Solve : VBS and JScript bug & how to fix it? |
|
Answer» Dusty and I are collaborating on an FAQ for doing floating-point arithmetic using the Evaluate.vbs script I posted some weeks ago. Among the VBS functions this can access is one CALLED FormatCurrency. This takes a value and displays it as a currency value, i.e. the local currency symbol as defined in Control Panel, that is, $ (dollar) £ (pound), € (EURO) etc, followed by the value expressed with 2 decimal places. Although my local currency is the UK pound, I could only get values showing with a dollar sign. A Google search reveals that this is a known problem, and AFFECTS VBScript and JScript in Vista Service Pack 1, Server 2008, and XP Service Pack 3. Currency and other locale-specific formats such as date, time, etc may not be displayed correctly. |
|
| 3217. |
Solve : Formatting a cd?? |
|
Answer» Two questions: you need to format them if you use packet writing software; which would appear to be the case here. You know, I had forgotten about that. GOOD catch. |
|
| 3218. |
Solve : MS-DOS COMMAND TO OPEN AND EXIT(CLOSE) A WINDOW? |
|
Answer» To those who help us learn. To those who help us learn.I don't use VLC but I'm fairly sure there's a switch that automatically closes it after playing music/etc.you have to know the full path of were it is. Its not LIKE you can type mspaint and have it come up cause it is a internal command. What you can do is make a bat and run it like that so that you wont have to call up the path all the time.Didn't he ask these questions before when he was devduttaa? Yep. I dont check every one |
|
| 3219. |
Solve : Dos "Eventcreate" and Event???? |
|
Answer» I'm sure at one POINT in time I found a command that would allow you search the eventlog for an EVENT, I know you can EventCreate to add an ENTRY, but how do I look for entries and put them to a string if found? |
|
| 3220. |
Solve : retrieving files from a corrupted hard drive? |
|
Answer» when i try to get a list of the Dir for c: drive i get a error message if this is the case how would i be able to know where specific files are located? I'm only trying to retrieve some video and pictures, and some files from quicken. is there a blanket command that i could use to copy the entire c: drive to a external hard drive connected via usb? my usb is the e:cd \ REM start at root directory when i try to get a list of the Dir for c: drive i get a error messageWhat is the error message? |
|
| 3221. |
Solve : How do i make a CMD Prompt..??? |
|
Answer» Quote from: Carbon Dudeoxide on May 02, 2009, 05:58:41 AM maybe i should rephrase to "@OP , you have asked alot on batch previously and i am sure you can find the answer from those posts. why don't you try your best? "How about one person solved the problem with half the effort three put into talking about post COUNTS. Sometimes it would be easier just to ignore the post or repeat yourself.Quote from: fat_basterd21 on May 04, 2009, 09:53:07 AM How about one person solved the problem with half the effort three put into talking about post counts. How about nothing. Dickhead screen name. Yes FB, please change your screen name. And also please don't be a hypocrite.well I've had my dickhead screen name for about 4 years now sorry NOBODY was ever offended before. And how am I a hypocrite? I try to answer questions not tell people to think harder... I wasn't trying to be rude, just STATING you could have answerd the poster the first time with less effort and the lack of rudeness...CORRECTION, the last post of mine I could find on: July 17, 2006, 01:58:01 PM Also I'm offended that anyone is offended by such a funny comedy. Add this line to your .bat file tskill WHINE.exeFB, Your being a hypocrite by this number: Quote from: fat_basterd21 on May 04, 2009, 09:53:07 AM How about one person solved the problem with half the effort three put into talking about post counts. And you didn't help worth a darn and this is just pointless: Quote from: fat_basterd21 on May 04, 2009, 08:09:14 PM tskill whine.exedon't waste your energy, macdad, it isn't worth it. I think my first post was helpful in saying, if all you wanna do is whine about how you already told them in another post your better off to just ignore the post. Or if you would have taken one step further and linked it to an original post while pointing out this is a repeat, fine. "Think harder" is hardly worth posting and is frustrating for the poster. I hope this "Helps" other people to use their head before being an *censored* in the future!Can the abusive language, F_B21. Quote from: fat_basterd21 on May 06, 2009, 05:43:18 PM If all you wanna do is whine about how you already told them in another post your better off to just ignore the post. err... didn't you already say that in another post? And now your basically whining about that here? Unfortunately, all the whining ends here. This topic need not continue. Settle the matter elsewhere, guys. That's what PMs are for. Topic Closed. |
|
| 3222. |
Solve : DOS Command window in second or invisible? |
|
Answer» Quote from: macdad- on May 04, 2009, 11:32:44 AM Oh you have is starting in Startup Manager, not a seperate bat file. Okis Macdad- . I'll try. See you later. Thank. Quote from: macdad- on May 04, 2009, 11:32:44 AM Oh you have is starting in Startup Manager, not a seperate bat file. Startup Manager is a simple program. Don't have the versatility of Startup Delayer. But offer the possibility to insert batch files . By Esgrimidor There is a paid program that does the way of Startup Delayer and this one asking when you enter in the system for the perfil o special bat you desire to execute. With Startup Manager you have to propose before reinitiate. So... I think there is a lot of opportunities. I was seeing the large post we have of scripting in the forum and CERTAINLY is not very difficult for a professional do a special startup. In my case i'm not a professional. Perhaps I HOPE to find the work done. IN this case I think we can ignore the construction of Startup Manager moving the bat to other folder where SM don't see him. Then make all the necesary modifications there and insert with Startup Delayer than interact better with msconfig.exe and subsequently with the register. Startup Manager seems to me a strange program. I does his work without a certainly rule. I don't know because select some executables, dll, and so on, and others no. On resume. I think Startup Delayer is a better program and we can make the additional bats with all our desires and language possibilities and insert with SD. After only is necessary mark or unmark a part of the list of bat to select the way we want the startup. And sure we can modify this with another special script. And certainly I don't have idea of doing this..... I know, there isn't a command for batch that lets you run batch programs in the background(hidden) and I'm not to familiar with Startup Manager either. A member of this forum told me of a program to compile to exe thats permits run in minimize mode. I'm waiting for the link and I proof. Thank a lot Sorry I couldn't help. Quote from: macdad- on May 05, 2009, 12:12:47 PM Sorry I couldn't help. Next time perhaps. I'm happy to be here. Quote from: macdad- on May 04, 2009, 06:51:06 AM Sorry for asking, It's just that of course people ask how to make PRANK batch programs and yours kinda sounds a bit suspicious, but since your doing this to just to CLEAN up the screen, then here: Mmmmmm Startup Manager create the trabajo.bat this bat contains all lines with "Start" Is a line inside another bat ? It's possible with trabajo.bat /MIN ? Seems so if its inside a batch fileUnderstood Privat MESSAGE me you e-mail and I will send it to ya. REAL small and is freeware so no worries.okis. Best Regards pepe |
|
| 3223. |
Solve : How do I Calculate between two date/time strings?? |
|
Answer» I have a program that receives in a string (for the example I put the value in a variable). date calc is easier with vbscript In every way. |
|
| 3224. |
Solve : output to file problem? |
|
Answer» Hello, Start opens a new window and new copy of CMD. Perhaps the file was there but hidden? A new copy of CMD is a bad idea in Batch programming. Unless that is want you really want. I'm fairly new to batch programming so the advice is noted and appreciated. |
|
| 3225. |
Solve : Run another command and Not return control to first batch file? |
|
Answer» I'm running a script and the LAST command is to use NOTEPAD to open a file. |
|
| 3226. |
Solve : just learning? |
|
Answer» Quote from: Reno on April 07, 2009, 10:55:08 PM pinging for 15minutes seems like not a good idea, could have some side-effect which i am not sure of. besides ping delay is not really accurate. that's why in the first PLACE i suggest using vbs sleep function instead of ping. True, but if you are using it on computers which may not have sleep, ping is your best (only) choice. Although it seems fairly accurate...not to nano seconds, but I've made a stopwatch in batch...almost...Quote from: Helpmeh on April 08, 2009, 05:49:41 AM True, but if you are using it on computers which may not have sleep, ping is your best (only) choice. Although it seems fairly accurate...not to nano seconds, but I've made a stopwatch in batch...almost... All Windows computers have VBScript, and can use sleep.vbs. I did look for a virus and Norton said I'm Clean but that dosen't mean everything. I do like to download games and the cracks may have something looming around I use this command for work (I Work for a cable co) to check for NETWORK problems and Iperf is the program they offer but I got tired of typing it in to a command line so I started this file. I ran a test last night with the command and it worked perfectly until I needed to stop. I used CTL-C it asked if I wanted to terminate Y or N of course I said yes......and window gone. That was my only mistake NEXT time I will say No then I can copy my results before closing the window. I will give this out to others in my company so I just want to get it right as I can. Quote >$sleep.vbs echo wsh.sleep 900000 This worked grate is there a way to tell it to stop after 24hrs but not close the window? Isn't there a timeout command I can try. In need to copy it into a text doc to be emailed. Again thank you JamesHey Reno, The code you posted put the command to sleep just as you said but it never recovers. I even shorten the time. When I tested it earlier I did not give it enough time to see if it would run the next test. It is just what I looking for. any ideas James Quote from: olo131 on April 08, 2009, 05:02:41 PM is there a way to tell it to stop after 24hrs but not close the window? Isn't there a timeout command I can try. In need to copy it into a text doc to be emailed.Quote from: olo131 on April 08, 2009, 09:18:29 PM The code you posted put the command to sleep just as you said but it never recovers. I even shorten the time.the code is only for sleep, so after sleep, you have to use some sort of restarting, eg. goto statement, call, restart the batch %0, etc 24 hours stop:15minutes = 4x / hour 24hr x 4x = 96x not exactly 24 hours, roughly around 24hours + 96 * (time needed to run batch file) Code: [Select]@echo off echo. echo CREATED FOR KNOLOGY SPEED TEST by: OLO 131 >$sleep.vbs echo wsh.sleep 900000 for /l %%a in (1 1 96) do ( call:B cscript//nologo $sleep.vbs ) echo 24hrs!! do copy here.. goto:eof :B echo. echo Time and Date of Test echo. Date /t Time /t echo. echo Iperf Speed Test Server xx.x.xx.xxx iperf -c xx.x.xx.xxx -r -w 64k -t 20 -i 1 echo. echo. echo. echo. echo Ping Iperf Server Test ping xx.x.xx.xxx -n 20 -l 64k echo. echo. echo Trace Route Iperf Server tracert xx.x.xx.xxx echo. echo. echo DONE! echo _______________________________________ __________________________________ echo.Reno, You are the MAN I ran my test for 24hr worked perfectly now I will do a search for a stop command. Thank you again, Reno and everyone who helped me James |
|
| 3227. |
Solve : What is the command to....? |
|
Answer» Make all the commands in your BATCH not APPEAR (be DISPLAYED) on the screen?@ECHO offThank you. |
|
| 3228. |
Solve : Kill Disk? |
|
Answer» Newbie here. So right away you know I have a PROBLEM. I have Kill Disk hxxp://www.killdisk.com/ |
|
| 3229. |
Solve : Send mail? |
|
Answer» hi guys There is no built in command in DOS to send mail and if you mean DOS in windows, that is Command Prompt(just to let you know)I saw another thread like this...I think Dias posted a vbscipt code that sends mail. |
|
| 3230. |
Solve : How to use Tab and Enter in a Batch File? |
|
Answer» Hi All, ...open a application where ...If the application requires TAB then it is not a command line application. Either the application is a Windows program or it has its own visual interface. Batch files are used to pass parameters to an application that expects command parameters. KEYBOARD Automation is beyond the intent of Batch files. Kwyvoard Automation is, or close to, impossible for applications that do not allow some control from the command line. You may wish to TRY any one of the many Keyboard Automation Tools found on Google. Or, if you know basic programming, you can use Visual Basic. Keyboard Automation Tools found on Googleif this need to be batch then post that values and about that key's, i can attach my own edited choice.exe wich allow to use special keys like F1 enter tab DEL etc |
|
| 3231. |
Solve : command line arguments in dos? |
|
Answer» HI All, I am new to dos. I have to use some command which should accept source and destination path as command line arguments and the file name to copy. whenever i SUPPLY three arguments my functionality should work. how can i ACHIEVE this? Thanks in advance.can anybody please help me...What do you need help with ? Do you have to create a program to accept and process the parameters, or does this program already exist and you need to know how to supply parameters on the command line ?thank you... i need a program for this. When you say program, you mean batch script ?Actually speaking i do not know how to achieve this...(through batch file or command etc) Please give me possible ways. I am sorry as i am new to this forum as well as dos. So your requirement is receive 3 parameters Source Directory (%1) Destination Directory (%2) Filename (%3) Copy filename from Source to Destination The simplest way is (with no error checking) Code: [Select]Copy %1\%3 %2Thank you gpl. Its working. I have created a batch file with your command. I have passed three arguments to the file while running it. Can we copy the file from ONE machine to other machine? |
|
| 3232. |
Solve : HELP Backing up amsdos program? |
|
Answer» Is there a way I can back up a huge ms dos program to something beside floppy discs? Maybe something that plugs into the floppy drive? THANKS |
|
| 3233. |
Solve : Text file as input?? |
|
Answer» Hi folks. Joedavis, Relevance doesn't worry joedavis. it's irrelevant because they asked how to get a batch to do math, not for a batch to do math.Quote from: joedavis on April 08, 2009, 02:01:35 PM
billrich, we know it's you! We covered FP maths in batch AGES ago. Quote from: On40 on April 08, 2009, 09:52:32 AM Hi folks. see that last part? PS? that doesn't mean, "devote all your time and resources to solving this one, simple problem with various ways of creating one line batch programs that often shell external interactive windows applications" Devcom cliched the CORE of the question- your attempt to address the PS would have been better served with an explanation of the /a switch, rather then the PROVISION of multiple samples that include references to the google calculator and shell the windows calculator. From Set /?: Quote Two new switches have been added to the SET command:Quote from: Dias de verano on April 08, 2009, 02:20:00 PM billrich, we know it's you! We covered FP maths in batch ages ago. LOL, my first draft of my post started with, "billrich... I mean, joedavis..." BC, I hope the Dandy from England with the Spanish name continues to help all the new people. Best of Luck to everyone. Quote from: On40 on April 08, 2009, 09:52:32 AM Its because im going to make a game with database technology.here's a more fun way to make games.Here's some code for crying out loud: This is assuming that the info will only be 1 line in the file on the first line: Code: [Select]for /f %%Z in ('type [path to file]') do set variable=%%Z You should be able to echo %variable%Quote from: devcom on April 08, 2009, 10:12:14 AM file.txt Code: [Select]@echo off for /f "tokens=*" %%a in (file.txt) do set %%a echo %life% pauseOh thanks for the help, but can you please explain what happens and how i type the syntax for the file reading thing? I really want to learn it in and out so i modify and tweak it in alot of directions.try for /? in cmd, for better explanation someone will explain, coz i dont speak Eng so good Thanks people. Especiallly from you devcom! I found out that it could read multi-line info making it more effective. Im going to make that game now! |
|
| 3234. |
Solve : Doskey, and how Macros work? |
|
Answer» I read the help file and spent quite some time (about 6 hours) googling for information on doskey.exe (I believe that's what it's called) and, honestly, couldn't find the ANSWER I was looking for. |
|
| 3235. |
Solve : MS-DOS Question? |
|
Answer» I didnt EXPECT you to do it for me, I posted what i thought it was and then i asked if it was correct... |
|
| 3236. |
Solve : Removing empty directories...? |
|
Answer» imagine my surprise when I found batch discussed in Raymond CHENS blog. Not my finest hour: Getting instructions on doing something I've already donelol and some of the comments too- almost 50% of the time it seems to turn into a nitpicking session. Although I guess that happens with all blog comments...finally! i ALWAYS HATE it when Recycle Bin says it can't delete the empty folder. |
|
| 3237. |
Solve : going crazy!! is this possible??? |
|
Answer» Dias I need your help!!I need to understand how the "maxdatenum" works as I am getting problem when latest date is 4/1/09 instead of 3/31/09.It is still extracting only 3/31/09 even if latest date is 4/1/09 or later. |
|
| 3238. |
Solve : convert screen showing SEARCH results (Vista_) to editable text, how to? |
|
Answer» What is all this loop hole BUSINESS? |
|
| 3239. |
Solve : want silent mode on batch\DOS? |
|
Answer» suppose if my file is in E:\Temp\Avast.arc |
|
| 3240. |
Solve : I need hope (sorry!)? |
|
Answer» I have a script that calls dsrm to delete computer accounts. Some accounts have special "features" and dsrm will not remove them. I understand why, but my problem is that when dsrm fails, it sets the ERRORLEVEL to -2147016643 and I cannot test for it in my batch script. Code: [Select]@echo off for /f "tokens=1-3* delims=:" %%a in ('dsrm cn=bob1,ou=workstations,dc=ourcompany,dc=com -noprompt 1>nul ^|findstr "failed"') do ( if not "%%a" equ "" ( echo.%%a echo.%%c ) ) try thisQuote from: devcom on May 04, 2009, 10:25:53 AM Code: [Select]@echo off 'for' doesn't like the redirection characters in the command. I've tried a couple things to get around this to no avail. Also it appears that dsrm sends the error message to stderr and therefore is not being captured by the for command. I'm currently working with this code: Code: [Select] del %tempout% dsrm %CN% -noprompt 2>>%tempout% for /f "tokens=1,2 delims=: " %%a in (%tempout%) do ( echo b:%%b if /i %%b EQU failed echo "failed" ) to send stderr to a file and read it from there. \\uSlackr devcom, I need a little more help, if you please. I couldn't make your code work as the for command barfed on the >1. Here is the code I wound up with. It sends the stderr output of dsrm to a temp file and looks at that for results (I call is as a subroutine with the CN as a parameter) Code: [Select]:DeleteAcct2 set CN=%1 if %MODE%==Prod ( del %tempout% dsrm %CN% -noprompt 2>>%tempout% 1>nul for /f "tokens=1,2 delims=: " %%a in (%tempout%) do ( if /i %%b EQU failed ( echo "Error deleting %CN%" set /a ErrCount+=1 ) else ( echo Computer account deleted: %CN% set /a ActCount+=1 ) ) ) else ( echo "Mode is %MODE% - not deleting, %CN% >>%inactlog% ) goto :EOFThis seems to work, except the output of the command is two lines and this code attempts to process both lines: Code: [Select]dsrm failed:CN=cn=bob1,ou=workstations,dc=ourcompany,dc=com:The directory service can perform the requested operation only on a leaf object. type dsrm /? for help. How can I stop the for loop from processing the second line? about that last error you get Code: [Select]@echo off for /f "tokens=1-3* delims=:" %%a in ('dsrm cn=bob1,ou=workstations,dc=ourcompany,dc=com -noprompt 1>nul ^|findstr "failed"') do ( if not "%%a" equ "" ( echo.%%a echo.%%c ) ) in for loop you need to escape characters so it must look like 1^>nul back to last question, the easiest way would be using some kind of counter like this: Code: [Select]setlocal enabledelayedexpansion set num=0 for /f "tokens=1,2 delims=: " %%a in (%tempout%) do ( if /i %%b EQU failed ( if !num! equ 0 echo "Error deleting %CN%" set /a num+=1 set /a ErrCount+=1 ) else ( echo Computer account deleted: %CN% set /a ActCount+=1 ) if you want ask question about why i use !! insted of %% google delayed expansionOK, this makes sense and I made it all work (well, almost). I now understand how to escape certain characters - and that's a good thing. Here's my current code: Code: [Select]:DeleteAcct ::Disable and flag the account if not already disabled set CN=%1 if %MODE%==Prod ( for /f "tokens=2 delims=: " %%c in ('dsrm %CN% -noprompt 2^>^&1 ^|findstr "failed" ') do ( if /i %%c EQU failed ( echo "Error deleting %CN%" echo "Error deleting %CN%" >>%errlog% set /a ErrCount+=1 ) else ( echo "Computer account deleted: %CN%" >> %actlog% echo "Computer account deleted: %CN%" set /a ActCount+=1 ) ) ) else ( echo "Mode is %MODE% - not deleting, %CN% >>%inactlog% ) goto :EOF The problem now is that if the delete suceeds, the output in the for command is nothing and the code below it doesn't execute. Thus I get to confirmation of the delete. I can work around it by "assuming" success, but we all know where that gets us. Any thoughts on that? In fact, this solution depends on failure string always containing the word 'failed' .I'm starting to think batch scripting may not be the best solution for this... \\uSlackrdevcom, thanks for the assist. Here's where I landed.
Code: [Select]if %MODE%==Prod ( echo "Trying to delete computer account: %CN%" >> %actlog% echo "Trying to delete computer account: %CN%" set /a ActCount+=1 for /f "tokens=2 delims=: " %%c in ('dsrm %CN% -subtree -noprompt 2^>^&1 ^|findstr "failed" ') do ( if /i %%c EQU failed ( echo "Error deleting %CN%" echo "Error deleting %CN%" >>%errlog% set /a ErrCount+=1 set /a ActCount-=1 ) else ( echo "Computer account deleted: %CN%" >> %actlog% echo "Computer account deleted: %CN%" set /a ActCount+=1 ) ) ) else ( echo "Mode is %MODE% - not deleting, %CN% >>%inactlog% ) goto :EOF All in all, a good batch file exercise! |
|
| 3241. |
Solve : i need a information about DOS batch script? |
|
Answer» hello evry one i just want to know how to make a DOS BATCH script file (.bat) run automatically ? for example a make this simple code : Code: [Select]@ echo off mkdir mydirectry so how to make it run automatically ? Look at at /? And that should help you. Please note that the computer must be on and logged in for programs to run automatically. Quote from: renalte16 on November 07, 2009, 07:13:30 AM hello evry one C:\batextra>type runwithat.bat Code: [Select]@ echo off cd \ cd mydirectory del myfile.txt cd \ rd mydirectory mkdir mydirectory cd c:\mydirectory echo hello > myfile.txt dir (I will schedule runwithat.bat with "At" or scheduled tasks and post back.) Output: C:\batextra>runwithat.bat Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\mydirectory 11/07/2009 12:52 PM . 11/07/2009 12:52 PM .. 11/07/2009 12:52 PM 10 myfile.txt 1 File(s) 10 bytes 2 Dir(s) 304,406,917,120 bytes free Press any key to continue . . . Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\mydirectory 11/07/2009 12:54 PM . 11/07/2009 12:54 PM .. 11/07/2009 12:54 PM 10 myfile.txt 1 File(s) 10 bytes 2 Dir(s) 304,406,917,120 bytes free C:\mydirectory>Following information from XP Help and Support section: <<<"To schedule a new task Open Scheduled Tasks. Double-click Add Scheduled Task. Follow the instructions in the Scheduled Task Wizard. Notes To open Scheduled Tasks, click Start, click All Programs, point to Accessories, point to System Tools, and then click Scheduled Tasks. If you want to configure advanced settings for the task, select the Open advanced properties for this task when I click FINISH check box on the final PAGE of the wizard. Confirm that the system date and time on your computer are accurate, because Scheduled Tasks relies on this information to run scheduled tasks. To verify or change this information, double-click the time indicator on the taskbar. If you leave the password blank and you want the task to run when you are logged on, open the task. On the Task tab, select the Run only if logged on check box. The task will run at its scheduled time when the user who created the task is logged on to the computer.">> C:\batextra>at 13:40 "C:\batextra\runwithat.bat" ADDED a new job with job ID = 1 C:\batextra>at Status ID Day Time Command Line ------------------------------------------------------------------------------- 1 Today 1:40 PM C:\batextra\runwithat.bat C:\batextra>type runwithat.bat @ echo off cd \ cd mydirectory del myfile.txt cd \ rd mydirectory mkdir mydirectory cd c:\mydirectory echo hello > myfile.txt C:\batextra>cd .. C:\>cd mydirectory C:\mydirectory>dir Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\mydirectory 11/07/2009 01:40 PM . 11/07/2009 01:40 PM .. 11/07/2009 01:40 PM 10 myfile.txt 1 File(s) 10 bytes 2 Dir(s) 304,405,028,864 bytes free C:\mydirectory> |
|
| 3242. |
Solve : cprompt? |
|
Answer» give command now for changing password of admin it will ask for authentication for this hmmmm May be want to hack or change the others passwords ?Quote from: VIKRAM Varaprasad on November 07, 2009, 05:20:00 AM May be want to hack or change the others passwords ? yes, that is what I wondered. If so, the answer is NO. There is the chance to do it, but we don't provoke you doing so....... |
|
| 3243. |
Solve : copy batch check drive? |
|
Answer» I want to have a batch file that copies from C to A, typical but the THING is with san disk and other usb drives it CHANGES the letter and instead of changeing it in the batch. Is there a way for it to go and see if its there if not go to the next letter.I am not familiar with batch but can't you just add a folder to the usb drive and have the batch search for the folder then copy the info if the folder is found.that would seem like more of a PAIN then anything. Then he would have to wait a good while till it found it then. |
|
| 3244. |
Solve : Set sub-variable...?? |
|
Answer» I was RUNNING into some problems with set. I was trying to replace the word "Desktop" (without the quotes) with For /f missing from line 2.When I used FOR while doing the other commands, it worked just fine...But how does your code work dusty?Quote But how does your code work dusty? Well, I hope it works. When it's run you would respond to the Set /p with copy desktop\messages.txt What the destination path\filename is didn't appear in your original post. The NEXT line simply sets %%a to the first entry in %command% which would be copy The If command tests %comma% for copy and if true Pushd's the default directory to %userprofile% which is C:\Documents and Settings\Username Then %command% is executed Popd then returns the default directory to where it was before Pushd was executed. Hope this helps and that I haven't made a FOOL of myself again Quote from: Dusty on April 10, 2009, 07:20:52 AM Well, I hope it works.I'll try. But why did you change the FOR loop? Did I do it wrong. EDIT: Doesn't work...I think it's because %userprofile% has spaces in it. I think the only way around it is for a sub-variable...Quote from: Helpmeh EDIT: Doesn't work...I think it's because %userprofile% has spaces in it. I think the only way around it is for a sub-variable... I don't understand why it's not working for you. Any time I run the script and enter Copy Desktop\Messages.txt the file is copied to the default directory which is C:\Documents and Settings\Dusty Any time I run the script and enter Copy Desktop\Messages.txt d:\temp\ the file is copied to d:\temp\ Do you get the advisory message "1 File(s) copied"? Quote from: Helpmeh But why did you change the FOR loop? Did I do it wrong. I think the only change I made to the For loop was to not include the "delims= ". Space is one of the default delimiters and therefore does not have to be specified. No, you didn't do it wrong, both methods produce the same result. Returning to your original script Quote set /p command= This set Command to Code: [Select]"\messages.txtuserprofile" whereas what was wanted was Code: [Select]copy "c:\documents and settings\user\desktop\messages.txt" Change the first If command line to Code: [Select]If /i %comma%==copy set command=%comma% "%userprofile%\%command:~5%" The second If command line is not required. The entire script could now be:Code: [Select]set /p command=Enter Command Path\Filename for /f "delims= " %%a in ("%command%") do set comma=%%a if /i %comma%==copy set command=%comma% "%userprofile%\%command:~5%" %command% A shorter version could be: Code: [Select]set /p command=Enter Command Path\Filename if /i %command:~0,4%==copy set command=%command:~0,4% "%userprofile%\%command:~5%" %command% Quote from: Dusty on April 12, 2009, 10:42:53 PM Returning to your original script What does the ~5 do in this case...I saw an example script when I first started scripting in batch using ~ and a number to cut off certain parts of a variable...and the file won't have the same length...Quote from: Dusty on April 10, 2009, 10:40:51 PM I don't understand why it's not working for you. Any time I run the script and enter Copy Desktop\Messages.txt the file is copied to the default directory which is C:\Documents and Settings\Dusty I got a message stating that the file can't be found, secondly: Thanks, I didn't know that, and FINALLY: Sorry for the double-post...even though we both did Dusty Edit: THANKS! It works GREAT!!! |
|
| 3245. |
Solve : /D:MM-DD-YYYY troubles .... for sorting data by year into folders? |
|
Answer» Trying to group about 374GB of data created over the last 9 years at C:\data into folders by year. Problem I have is that the xcopy /s/d:MM-DD-YYYY/y "/D"switch will grab all data on or after the date specified, and I cant seem to create a range to only grab say 01-01-2008 to 12-31-2008, so I have to have it perform a clean up after xcopying the data to the destination that will remove this newer data from the original SOURCE path so that the next xcopy routine can grab the next group of 01-01-2007 to 12-31-2007 data without passing the newer 2008 and 2009 data into the 2007 folder. ( Scratching my head on how to delete only this range of date/time stamped data after it is xcopied??? ) Trying to group about 374GB of data created over the last 9 years at C:\data into folders by year. Problem I have is that the xcopy /s/d:MM-DD-YYYY/y "/D"switch will grab all data on or after the date specified, and I cant seem to create a range to only grab say 01-01-2008 to 12-31-2008, so I have to have it perform a clean up after xcopying the data to the destination that will remove this newer data from the original source path so that the next xcopy routine can grab the next group of 01-01-2007 to 12-31-2007 data without passing the newer 2008 and 2009 data into the 2007 folder. ( Scratching my head on how to delete only this range of date/time stamped data after it is xcopied??? )I know one POSSIBLE way...but I'm not experienced enough to actually do it. If after each line, you delete the files created after 01-01-YEAR (you already copied them to a different directory). It could be acomplished with FOR...I think Dave, maybe you should consider XXCOPY, which is like XCOPY on steroids, which has a free-for-personal-use version. It is designed to have similar command set to XCOPY. There is also ROBOCOPY, a Microsoft admin tool, which, again, is designed to be be an easy transition from XCOPY, but I think for your problem as mentioned in this thread, consider this: XXCOPY features include: Quote 8. Select the range of file date http://www.xxcopy.com/index.htm Quote from: Dias de verano on April 10, 2009, 04:56:52 PM Maybe you should consider XXCOPY, which is like XCOPY on steroids, which has a free-for-personal-use version. It is designed to have similar command set to XCOPY.It says it's compatible with XPSP3, as you may or may not know, I can't get that...can I still use XXCopy?Quote from: Helpmeh on April 10, 2009, 04:58:40 PM It says it's compatible with XPSP3, as you may or may not know, I can't get that...can I still use XXCopy? Compatible means it works OK with SP3. It doesn't mean you must have it. Quote from: Dias de verano on April 10, 2009, 05:04:36 PM Compatible means it works OK with SP3. It doesn't mean you must have it.Ktry this code, it's not optimized, if you have lot's of small size files, it might run slow. i am not good at xcopy, so i use copy command instead. Code: [Select]@echo off & setlocal enabledelayedexpansion pushd c:\data\ || goto:eof ::get SYSTEM date format set f= for /f "skip=1 tokens=2-4* delims=(./-)" %%1 in ('echo.^|date') do ( set 1=%%1 set 2=%%2 set 3=%%3 for %%$ in (1 2 3) do if yy==!%%$! set f=!f!%%%%$ ) echo date format=%f% ::copy based on year modified for /r %%a in (*) do ( for /f "tokens=1-3* delims=./- " %%1 in ("%%~ta") do set yy=%f% set dest=%%~dpa set dest=c:\test1\!yy!\!dest:%cd%\=! if not exist !dest! md "!dest!" && echo folder !dest! created echo copying %%a --^> !dest! copy "%%a" "!dest!" ) popd WARNING: TRY ON TEST DATA FIRST. i am not responsible for any data lost.Thanks Dias and Reno ... I will give both of your solutions a try in the morning and see which one works better. The XXCOPY seems pretty straight forward with the ability to set range like I need. But I also am interested in checking out Reno's coded solution as well to see how well that works too. Thanks for the effort of all who contributed...based on this info I think I should be all set now. Reno .... VERY Impressed with your solution...Works perfect and no need to delete data from the C:\data location. Now off to sort 374GB of data after a successful test of about 50mb Thanks sooo much !!!! Quote from: DaveLembke on April 11, 2009, 11:43:45 AM Reno .... VERY Impressed with your solution...Works perfect and no need to delete data from the C:\data location.If you run into any problems later, feel free to ask. |
|
| 3246. |
Solve : How to escape from ampersand.? |
|
Answer» Is there any way to REPLACE the occurance of the ampersand character in a string in Dos? they say that in DOS, you use carrot ^ to escape. but if you can use tools like sed (see my sig)This requires an external utility which I was hoping top avoid, besides I don't want to change the occurrences of & in an entire file only a string in a batch file. (but thanks for your reply anyway) Try this Code: [Select]set "str=%str:&=ampersand%" Hi- Quote Code:Yes this works ,but I guess I should mention that I'm still working on getting the target to shortcuts on the desktop and, while my batch file works for .lnk files, it also works for .URL files on the desktop as well.. Except for if the .URL file's target contains an ampersand. Then the target returned from DecodeShortCut.vbs is truncated, so the substitution fails because there is no & to replace. Code: [Select]@echo off Set SHORTCUT=%~1 echo set WshShell = WScript.CreateObject("WScript.Shell")>DecodeShortCut.vbs echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>DecodeShortCut.vbs echo wscript.Echo Lnk.TargetPath>>DecodeShortCut.vbs set vbscript=C:\WINDOWS\system32\cscript DecodeShortCut.vbs For /f "delims=" %%T in ( ' %vbscript% "%Shortcut%" ' ) do set target=%%T del DecodeShortCut.vbs Echo Shortcut %shortcut% Echo Target %target% set target=%target:?=questionmark% set "target=%target:&%=ampersand%" Echo Target %target%>target.txtIs there some way to catch this? Like for example: Code: [Select]@echo off Set Shortcut=%~1 echo set WshShell = WScript.CreateObject("WScript.Shell")>DecodeShortCut.vbs echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>DecodeShortCut.vbs set targetpath=Lnk.TargetPath set "targetpath=%targetpath:&%=ampersand%" echo wscript.Echo targetpath>>DecodeShortCut.vbs set vbscript=C:\WINDOWS\system32\cscript DecodeShortCut.vbs For /f "delims=" %%T in ( ' %vbscript% "%Shortcut%" ' ) do set target=%%T del DecodeShortCut.vbs Echo Shortcut %shortcut% Echo Target %target% set target=%target:?=questionmark% set "target=%target:&%=ampersand%" Echo Target %target%>target.txtDo you think this might work?Quote Do you think this might work?No I tested it and it does not work. Somehow the call to: Code: [Select]echo wscript.Echo Lnk.TargetPath>>DecodeShortCut.vbs returns a string which is already truncated at the position of the &!!Quote from: nubia on April 12, 2009, 11:25:46 AM No I tested it and it does not work. You cannot mix batch and vbs code in that way. Quote You cannot mix batch and vbs code in that way.I see...so is it possible to add a line to DecodeShortCut.vbs that will do the replace? I'm sorry but I know less of vbs code than I do of batch (which is, sad to say , not much).DecodeShortcut.vbs Code: [Select] Set WshShell = WScript.CreateObject("WScript.Shell") shortcut = WScript.Arguments.Unnamed(0) Set Lnk = WshShell.CreateShortcut(shortcut) Target = Lnk.TargetPath If InStr(Target,"&")>0 Then Wscript.echo Replace (Target,"&","AMPERSAND") Else Wscript.echo Target End If set Lnk = Nothing Batch file to use it Code: [Select] @echo off Set Shortcut=%~1 set vbscript=C:\WINDOWS\system32\cscript DecodeShortCut.vbs For /f "delims=" %%T in ( ' %vbscript% "%Shortcut%" ' ) do set target=%%T Echo Shortcut %shortcut% Echo Target %target% Echo Target %target%>target.txt Quote from: Dias de verano on April 12, 2009, 12:47:51 AM Try thisWould that work for precent signs too? |
|
| 3247. |
Solve : Batch pgm to add datetime to filenames, then save to other folder? |
|
Answer» Thank you in advance for any help with this. |
|
| 3248. |
Solve : MS DOS Ping batch file? |
|
Answer» I'm sending a system to Brazil. One of the ISSUES with this system is that I have IP addresses that range from 192.168.0.1 through 192.168.0.12. |
|
| 3249. |
Solve : Sleep command in Vista? |
|
Answer» Hi %1 through %9 are command line arguments. I want to make my own sleep command, but my code doesn't work. Code: [Select]@echo off if not "%2"=="/m" ping localhost -n %1 -w 1000 > nul & exit ping localhost -n %1 -w %3 > nulI want it so if they type sleep 2 it will sleep for 2 seconds, but if they type sleep 2 /m 1500 It would sleep for 2*1500 miliseconds. It just seems to ignore the /m and only runs the first part...why don't you enter echo commands that echo what %1 through %9 are? EDIT: just remembered something: instead of "hard-coding" where the parameter is, use environment variables to store the various settings before you start executing. you can use the SHIFT command- for example: Code: [Select] REM INIT the vars to 0... SET MSWITCH=0 SET FNAME= :START SET GOTSWITCH=0 if %1!==! goto CONTINUE REM TEST %1 here, for switches, filenames, etc. if "%1"=="/m" SET MSWITCH=1 & SET GOTSWITCH=1 if "%1"=="/M" SET MSWITCH=1 & SET GOTSWITCH=1 if %GOTSWITCH%=0 set MCOUNT=%1 shift GOTO START: CONTINUE: if %GOTSWITCH%=1 echo /m switch specified. if %GOTSWITCH%=0 echo /m switch not specified. echo count specified was %MCOUNT% Quote from: BC_Programmer on April 10, 2009, 06:06:29 PM why don't you enter echo commands that echo what %1 through %9 are?What???Quote
That was the concept I was trying to get across. |
|
| 3250. |
Solve : What worning with my BAT script? |
|
Answer» i have 2 text file name: doc.txt and STRING.txt |
|