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.
| 4801. |
Solve : Display special char in env variable?? |
|
Answer» Win2k Sp.4 - Cmd.exe I assume this is because the char needs to be escaped in the Echo When you assume.... It's no good trying to escape the vanished character in the batch, because cmd.exe has already stripped it off. You could protect it by wrapping the whole parameter in quotes and then using the ~ variable modifier in the batch to take them off. Showme.bat Code: [Select]@echo off set parameter=%~1 echo parameter is %parameter% Output of Showme.bat Code: [Select]S:\Test\Batch>showme "=1" parameter is =1 The ~ variable modifier strips any surrounding quotes (if present) from a loop variable or from a passed parameter. It is documented in the help for FOR, so type FOR /? for details. THis method doesn't work with all problem characters, for EXAMPLE &. Thank you Dias. In a reply on post #68095 you escaped all of the ( and ) characters Quote echo Yesterdate = (Date^(^)- 1^)>yesterday.vbs Is there a SPECIAL reason for doing this?The batch file in question works fine without those carets, as I have just now discovered. There are other situations where you do need to escape parentheses so I have GOT in the habit of doing so. If a parenthesis doesn't need ESCAPING, it does no harm to escape it, whereas a parenthesis that should be escaped, but isn't, causes an error. In the code below, the regular expression passed to SED contains parentheses, and because the command invoking SED is inside the parentheses of a FOR command, they need escaping to stop cmd.exe borking. @echo off setlocal enabledelayedexpansion for /f %%i in (qd.txt) do for /f %%J in ( ' echo %%i ^| sed -e s/.*\x22\^(.*\^)\x22.*/\1/ ' ) do set yfn=%%j Thanks again. I understand the need for escaping character(s) in the For command, just couldn't get to grips with escaping ( and ) in the Echo command. |
|
| 4802. |
Solve : error 53 & 6118? |
|
Answer» Hi on a small 3 machine network (2 winxp pro, 1 msdos 6) in a remote office the primary xp2 PC power supplied FAIL. Upon delivering the new PC with the same name and workgroup I'm unable to connect to the share created on the xp from the dos pc. xp2 PC power supplied fail. Upon delivering the new PC with the same name and workgroup I'm unable to connect to the share created on the xp from the dos pc. Disable firewall if safe to do so and test with firewall disabled.Thanks Dave, XP Firewall is disabled. set netbios\tcpip, changed from default, created an lmhost file, confirmed net\system.ini workgroup Hi, This issue has become a MUTE point, looking further in the issues finding a variety of other pieces of equipment failures potenially related to power, surge? lightning? Time the remote office updated, the last 486. Thanks for the consideration. |
|
| 4803. |
Solve : edit to yesterday's date? |
|
Answer» Hi there, You may have to alter the script to suit your date format. New! Improved! You won't have to alter this, it is independent of date format settings. You can fool around with the variables to make different strings as you can see in the 3 examples at the bottom. Code: [Select]@echo off echo Yesterdate = (Date^(^)- 1^)>yesterday.vbs echo Yyyy = DatePart^("YYYY", Yesterdate^)>>yesterday.vbs echo Mm = DatePart^("M" , Yesterdate^)>>yesterday.vbs echo Dd = DatePart^("D" , Yesterdate^)>>yesterday.vbs echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd>>yesterday.vbs FOR /F "tokens=1,2,3 delims= " %%A in ('cscript //nologo yesterday.vbs') do ( set /a Year=%%A set /a Month=%%B set /a Day=%%C ) if %Month% LSS 10 set Month=0%Month% if %Day% LSS 10 set Day=0%Day% REM Examples echo (1) echo. echo Yesterday was: echo. echo Year : %Year% echo Month : %Month% echo Day : %Day% echo. echo (2) echo. echo %Day%/%Month%/%Year% echo. echo (3) echo. echo %Year%%Month%%Day% echo. Output today Friday 10/10/2008: Code: [Select](1) Yesterday was: Year : 2008 Month : 10 Day : 09 (2) 09/10/2008 (3) 20081009Ahhh Dias... Quote O Lord my God, When I in awesome wonder, Although it is -- of course -- immensely flattering to be likened to God, modesty insists that I must decline such a comparison. By the way, if you want to just keep Yesterday.vbs somewhere and call it when you need it, rather than create it from a batch script, it looks like this Code: [Select]Yesterdate = (Date()- 1) Yyyy = DatePart("YYYY", Yesterdate) Mm = DatePart("M" , Yesterdate) Dd = DatePart("D" , Yesterdate) Wd = DatePart("W" , Yesterdate) Wscript.Echo Yyyy&" "&Mm&" "&DdThank you for that but your elevated status is hereby revoked 'cos I couldn't get your New! Improved! version to perform. I think this line:Quote FOR /F "tokens=1,2,3 delims= " %%A in ('yesterday.vbs //nologo') do ( should be: Quote FOR /F "tokens=1,2,3 delims= " %%A in ('cscript //nologo yesterday.vbs') do ( You are right - It depends on which of the two scripting hosts is the default on your system, cscript or wscript. On mine it is cscript, so I can just do... Code: [Select]scriptname.vbs //nologo ...or even (assuming the script file has the .vbs extension)... Code: [Select]scriptname //nologo ...from a batch WITHOUT having to specifically mention cscript.exe, but I forgot that on systems where the other host is the default it would have to use your line, so it is better (more UNIVERSAL) to do it that way, so I have edited the script above. Incidentally, if you get bored with adding //nologo every time, you can make cscript save it as a per-user preference by using it just once with the //S switch when you run a script (any script, it applies to all scripts run with cscript by that user after that, until you change it back again by using //S with //logo) Before (Windows default): Code: [Select]S:\Test\Batch\Yesterday>yesterday Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. 2008 10 10 6 Set //nologo as user's cscript default: Code: [Select]S:\Test\Batch\Yesterday>cscript //nologo //s yesterday.vbs Command line options are saved. 2008 10 10 6 After: Code: [Select]S:\Test\Batch\Yesterday>yesterday 2008 10 10 6 To change it back again: Code: [Select]S:\Test\Batch\Yesterday>cscript //logo //s yesterday.vbs Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. Command line options are saved. 2008 10 10 6 Back the way we were... Code: [Select]S:\Test\Batch\Yesterday>yesterday Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. 2008 10 10 6 |
|
| 4804. |
Solve : Set second line of a file as a variable.? |
|
Answer» Just as I IMAGINED what WENT wrong. |
|
| 4805. |
Solve : Usb Security? |
|
Answer» Right now try to make usb security software like my pendrive vol is "Volume Serial Number is 2404-3726" if the vol no. "2404-3726" match then it open other wise it can't open so no one can load virus in my system it is possible in DOS or any other language pls help me. What? Do you have any code already? I'm not sure how to dismount the flashdrive and only re-mount it when the correct password is entered. This is my "code": Pseudo dismount %~d Set /P volinp=Volume Number: If "%volinp%"=="volume number here" pseudo mount %~d No no not like this we not enter the number like passwords but it match internali if vol no. match then it open other wise eject. or possible in other langage pls help ...So your saying something like this pseudo-code? On USB.INSERT If USB.VOLUME EQU VOLUMENUMBR THEN (exit) ELSE (USB.EJECT=true) yes3 words. Not in BATCH. So in which language is this 3 word is haveQuote from: Deadly D on September 08, 2009, 09:38:04 PM http://www.cprogramming.com/smeezekitty- offer a demonstration.ok then Code: [Select]#include <iostream.h> //some COMPILERS use iostream some iostream.h #include <Stdio.h> #include <stdlib.h> #include <string.h> #define _S "<proper serril number here>" int main(){ int i; char line[60]; char ser[30]; system ("dir X:\*.pes >_temp.tmp"); //change X to the proper drive letter FILE *f = fopen("_temp.tmp", "r"); fgets(line, 0xFFF, f); fgets(line, 0xFFF, f); //fgets(line, 0xFFF, f) //NEEDED? while(line[25+i]){ser[i]=line[25+i]; i++;} //change 25 to the OFFSET of the seril number (25 should be ok) ser[i]=0; fclose(f); system("del _temp.tmp"); cout<<"Number of volume:" <<ser <<endl; if(strncmp(ser, _S, strlen(_S)) == 0){cout<<"OK!\n";} else {/*eject code here*/} return 0; } Thanks for replay @[emailprotected] but can possible to find serial no of pen drive and match.maybe BC_programmer (my buddy i argue with) can help |
|
| 4806. |
Solve : Do Loop?? |
|
Answer» I am trying to perform a function that will send out an email and retry the function until it passes my condition. It has been a few years since I have used batch commands and I am in need of some help. Here is what I have so far: :start C:\>cat gostart.bat Code: [Select]@echo off :start echo Enter errorleve set /p errorlevel= if %errorlevel% GTR 0 goto fail goto start :fail REM c:\Email.bat [emailprotected] echo "Execution Failed" "The scheduled job failed to execute" goto start C:\> gostart.bat Output: Enter errorleve -10 Enter errorleve 0 Enter errorleve 66 "Execution Failed" "The scheduled job failed to execute" Enter errorleve 2 "Execution Failed" "The scheduled job failed to execute" Enter errorleve -7 Enter errorleve |
|
| 4807. |
Solve : Kill an application started through a Novell Client running in Windows XP? |
|
Answer» Dear all, |
|
| 4808. |
Solve : Copy contents of file1,file2 into file3? |
|
Answer» Sir, |
|
| 4809. |
Solve : Help from DOS Expert? |
|
Answer» I am facing probelm in applying the following DOS Commands. |
|
| 4810. |
Solve : available diskspace? |
|
Answer» Hi, |
|
| 4811. |
Solve : Fdisk - problems with extended dos partition? |
|
Answer» It all started with windows vista trying to UPDATE 3 updates and could only complete 2 and the third was trying but kept restarting and saying the same thing. Had a feeling it was something to do with clashing with avg. Anyway had enough of trying to get it to load windows and had nothing but trouble from vista not showing pages over the internet and not compatible with things, so decided to change back to windows XP, but because of this extended dos partition it has not allowed it. I have been through the wars with this laptop, believe me this is the last resort before i smash it to smitherines lol. Have you tried to recreate the primary partition and delete the extended partition ? ? Yes it may well be a hidden recovery partition, but because of this i don't SEEM to be able to format the drive. I have created a partition and tried to delete it but it does not seem to MOVE and when i have loaded up windows vista and xp they won't install, it comes up errors cannot copy this file etc. has 4% of Usage on it and i'm not certain but it had media direct 3 on it, which is a program that lets you play dvd's. I don't know if that has any significance. |
|
| 4812. |
Solve : ö in path in batch file? |
|
Answer» I NEED to make a batch command which enters the date and time in a file. The actual batch file contains: |
|
| 4813. |
Solve : Running 2 programs simultaneously in a batch file? |
|
Answer» How do I execute a video clip (GIF) and a sound clip (AMR) SIMULTANEOUSLY in a batch file? Is it POSSIBLE? It is possible to run both in Windows at the same time.You can run them both, but you can't start them at the same time together. |
|
| 4814. |
Solve : XP/DOS Dual boot? |
|
Answer» Hi all, |
|
| 4815. |
Solve : using XCOPY when directory has a space in name? |
|
Answer» I got the "START" command to work when the APP name has a space in it, but now having the same problem with XCOPY. The DIRECTORY I want to copy has a space in it (Ham Radio) and the command fails. The same fix USED for START doesn't seem to apply to XCOPY. |
|
| 4816. |
Solve : Batch w/ wildcard using external data from text file? |
|
Answer» I'm trying to figure out a means to copy a single file from one location on to multiple workstations, but because the workstation names might change I want to put the names in a text file for the batch to take to plunk into the command. Now I just need to figure out 'upon error' goto next computer in case the pc is down and somehow report the missing computer. what you could try and do is ping each computer and use the errorlevel to tell if the system is on or not. if the system is off then echo the computer name into a text file on the host (the system the batch is running on). |
|
| 4817. |
Solve : move command using batch file help? |
|
Answer» Hello all, I am a beginner using MS-dos so i might not know all the exact terms used to describe my problem. |
|
| 4818. |
Solve : Question about using batchfiles in Windows XP? |
|
Answer» Quote when will you LEARN never give your stuff away text - binary - hex http://home2.paulschou.net/tools/xlate/Quote from: BatchFileBasics on September 07, 2009, 10:08:05 AM text - binary - hexI ALWAYS use that site for converting binary, hex, decimal etc. yea, it came in handy when my friend needed me to "decode" binary he got in a message anyways. i wonder where lufkincy isQuote HEY bc_prog can you decode this:Hey kitty, can you give a ONE LINE command that will decode what you just sent to BC ? Well, maybe three or four lines. |
|
| 4819. |
Solve : processing arguments in batch file? |
|
Answer» processing ARGUMENTS in batch file |
|
| 4820. |
Solve : Checking for SQL backups? |
|
Answer» Hi All |
|
| 4821. |
Solve : How to list all the partitions in the system ?? |
|
Answer» I want a command to list all the partitions in the system, so it tells me in a small list what partitions are, with their labels. How to use Disk Managementnot even close to what the op wants bill...Quote from: BatchFileBasics on September 06, 2009, 10:54:04 AM not even close to what the op wants bill... You are right. I will erase my post. Your answer is much better. Thanks for the help.if you noticed, i didn't post an answer because its just about Quote from: camerongray on September 06, 2009, 09:13:43 AM Have a look at this: http://tinyurl.com/kpd4oh Code: [Select]C:\Documents and Settings\Owner>diskpart Microsoft DiskPart version 5.1.3565 Copyright (C) 1999-2003 Microsoft Corporation. On computer: CHRIS-COMPUTER DISKPART> list volume Volume ### Ltr Label Fs Type Size Status Info ---------- --- ----------- ----- ---------- ------- --------- -------- Volume 0 D DVD-ROM 0 B Volume 1 F DVD-ROM 0 B Volume 2 C Hard Drive NTFS Partition 74 GB Healthy System Volume 3 G Removeable 0 B Volume 4 H Removeable 0 B Volume 5 I Removeable 0 B Volume 6 K Removeable 0 B DISKPART>It will show Volume labels if they are assigned...Quote from: BatchFileBasics on September 06, 2009, 01:50:42 PM if you noticed, i didn't post an answer because its just about WORKED, the diskpart is already included with the Windows 7 PE and it worked the very good way thaaaankkks |
|
| 4822. |
Solve : How can FOR see Hidden files :- FOR %%A IN (*.XYZ) DO my_test %%A? |
|
Answer» I require "my_test" to process EVERY file with the extension XYZ. FOR /F ["options"] %VARIABLE IN ('command') DO command [command-parameters]and I assumed the "usebackq option present" was something pre-existing, either by an option switch when launching CMD.EXE or by a registry hack. I now realise, after scrolling down a page, it is not a pre-existing thing, but a special modifier within the optional options. Time for my aspirins ! ! Thank you for your solution, which has led me into a less incomplete understanding of DIR and FOR. Regards Alan |
|
| 4823. |
Solve : Combining files? |
|
Answer» I know that two files can be combined or added with: Sometimes things turn out simple.check copy /? for what /b does. also, you can make small files and test them out. then you can see what the final file looks like. That's a good idea. I'll do that. ThanksCOPY assumes text files, and will terminate at Control Z and anything ELSE which is not a normally printable character. COPY /B is a BINARY copy, which duplicates every character regardless of whether it is printable. COPY /B file.0* newfile That will work, and is a great way to use up empty disc space. It may however disappoint you, newfile will CONTAIN copies of files in the sequence that they are given by Windows. If you want the contents of file.001 to be followed by file.002 etc etc you need to control the sequence. Regards Alan @OP, if you can afford to install GNU tools (see my sig), common way to do it in *nix can now be done also on Windows Code: [Select]c:\test> cat file.0* >> newfile.txt |
|
| 4824. |
Solve : dos command to strip leading zeros? |
|
Answer» i have files and i want them renames as such: teh cat in teh hat If you can understand that, then you can get rid of leading zeros by recursion. Or iteration. Quote from: Geek-9pm on September 06, 2009, 07:43:31 PM Here is a site that has lots of string manipulation for DOS.http://www.robvanderwoude.com/battech_leadingzero.php Code: [Select]:Loop IF "%Var:~0,1%"=="0" ( SET Var=%Var:~1% GOTO Loop ) |
|
| 4825. |
Solve : Need a help for writing a batch script !!!? |
|
Answer» hi, ECHO ^<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ ARGUMENTS" value="-messagelog stdout -rulesfile "\${resource_name}\""/^> > test.xml Then check the test.xml file to ensure the format is correct. Good luck. Edit: & Welcome to the CH forums.BINGO !!!! Thanks a lot Dusty !! |
|
| 4826. |
Solve : what is "setlocal enabledelayedexpansion"? |
|
Answer» I have been browsing TOPICS and all, and i USUALLY COME ACROSS |
|
| 4827. |
Solve : Comparing extenions and executing.? |
|
Answer» So with my batch file, you are able to drag two files into it. But, I manually have to decide which file is which |
|
| 4828. |
Solve : chatting with CMD? |
|
Answer» hey guys how about...thanks, but thats only part of it i need the user to start talking so if they said Hi: Hello USER: What is your name?: Ashely, and u? set /p name= echo %name% cool name... echo so %name% hows ur day? IF bad GOTO bad IF good goto good :bad echo why? (what ever they said here, it will reply Im sorry) The PROBLEM with IF is that the user has an unlimited range of RESPONSES, choice might be better like so... Code: [Select]Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)" if errorlevel 2 goto Label1 if errorlevel 3 goto Label2 if errorlevel 4 goto Label3 rem code here... FBQuote from: fireballs on August 16, 2008, 05:30:43 AM The problem with IF is that the user has an unlimited range of responses, choice might be better like so...ok, so far i got this: Code: [Select]title Chat with CMD @echo OFF cls echo Hello mate, what is your name? echo What is your name? set /p name= echo welcome %name% cool name... Choice /N /C "GBA" /M "How was your day? Good? (G) Bad? (B) Alright? (A)" if errorlevel 2 goto Label1 if errorlevel 3 goto Label2 if errorlevel 4 goto Label3 :Label1 cls echo why awesome? :Label2 cls echo why badd? :Label3 cls echo alright? echo sounds like something is going on pausebut it doesn't work at the choice, something wrong?what do you mean doesn't work? i might have gotten the errorlevels wrong try debugging... Code: [Select]choice...blah blah echo %errorlevel%sorry for some reason i skipped a number it should just be... Code: [Select]choice... if errorlevel 1 goto good if errorlevel 2 goto bad if errorlevel 3 goto alriteQuote from: fireballs on August 16, 2008, 05:55:55 AM sorry for some reason i skipped a number it should just be...soo this: Quote title Chat with CMD it suddently closes ok this works:Quote title Chat with CMDhe is probably using XP and you Vista. XP doesnt have choice.exe but Vista does thats the problem i think |
|
| 4829. |
Solve : Forcing wait-to-finish for each command in batch files? |
|
Answer» When running a batch file, each command does not seem to wait until a previous command has finished. Thanks wbrost,Start /wait commandORprogram Will wait for the command or program to terminate before continuing. I'm not 100% sure that it works for commands, it should though.Hi everyone... I'm a complete newbie to DOS...so please be gentle with technical terms... I use PDMS at work and DOS/bat files set everything up... The problem is I have a .bat file that fires up a simple PDMS .mac file... The .mac creates a text file.... Then the idea was the original .bat would RENAME/MOVE this text file... What I suspect is happening is that the .mac is creating the text file but my .bat file is carrying on and as there is no text file to RENAME/MOVE it's finishing... Is there a way to say to DOS check/keep checking that C:\text.txt has been fully built and ready to be renamed... I tried to use the suggestion on this post, see below :- C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dice.mac :loop ping -n 1 -w 3000 1.1.1.1 > nul if exist C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt ( echo DOCUMENT exists rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK.txt C:\PDMS\Results\Dice ) else ( echo document doesn't exist go to loop ) Cheers NeilTry "calling" the first batch file. Code: [Select]CALL C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dice.mac Cheers That worked great....the code is now continueing... The problem now is the code is continueing as I wanted...but by the time the code goes back to the .bat :- if exist C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt ( echo Document exists rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt The file is in existance...but it's still been compiled...so cannot be coppied yet... Is there a way to check the compiling is finished before it continues to the rename/move ? Cheers Neil you could check to see if the process is still active using tasklist. Code: [Select]tasklist /FI "imagename eq firefox.exe" change firefox.exe to the name of what you are looking for. If you need to know run the process and watch task manager.Hi...thanks for the reply...not sure if I've included it into my code correctly... But you are correct...when the adm.exe completes running then I want to carry on to the rest of the .bat code... See below how I've used it....please TELL me if it's correct...as it doesn't seem to be making any difference... -- -------- CALL C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dic.mac tasklist /F1 "imaginename eq adm.exe" rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK.txt C:\PDMS\Results\Dice -- -------- Cheers NeilQuote from: NEILD on September 04, 2009, 12:34:03 PM
first thing I see is that the command is /FI not /F1 second is the image name is incorrect it should be "imagename eq adm.exe" I will work on this and see if I can come up with something. There might be some one that already has an example for you to use. ok this will check and see if the process is still active and if not then stop for 15 seconds and try again. Code: [Select]@ECHO OFF :loop CLS set errorlevel= tasklist /fi "imagename eq adm.exe" | find /i "adm.exe"> NUL if /i %errorlevel% GTR 0 goto yes ECHO adm is working! PING -n 1 -w 15000 1.1.1.1 > nul GOTO loop :yes ECHO. ECHO. ECHO adm is finished pause wbrost thanks so much for helping me with this... I've added your changes to my .bat -- ------------- CALL C:\AVEVA\pdms11.6.SP1\pdms.bat TTY SEA SYSTEM/XXXXXX /TEST/DESIGN $m/c:\PDMS\Run_Dic.mac @ECHO OFF :loop CLS set errorlevel= DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp.txt ..................$$$$ coding stops at this point $$$$............ tasklist /fi "imagename eq adm.exe" l find /i "adm.exe"> NUL DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp1.txt if /i %errorlevel% GTR 0 goto yes DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp2.txt ECHO adm is working! DEL C:\AVEVA\pdms11.6.SP1\pdmsuser\temp3.txt PING -n 1 -w 15000 1.1.1.1 > nul GOTO loop :yes ECHO. ECHO. ECHO adm is finished rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK.txt MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK.txt C:\PDMS\Results\Dice -- ------------------------------------------------------ It doesn't seem to completing the full code...it stops part way thgrough... Before I tell you the problem can I confirm that this symbol in the centre is the one on the backslash key on the keyboard...not sure of it's name:- exe" | find I created some dummy files and added delete code...to see how far the code got... The code made it to and past :- set errorlevel= It stopped at this line :- tasklist /fi "imagename eq adm.exe" | find /i "adm.exe"> NUL Have I made another typo ? Cheers Neil I got it working by modifying one line :- Old tasklist /fi "imagename eq adm.exe" l find /i "adm.exe"> NUL New tasklist /fi "imagename eq adm.exe" goto goto loop -- --------------------------- So it now looks like this :- @ECHO OFF :loop CLS ECHO adm is working! PING -n 1 -w 15000 1.1.1.1 > nul errorlevel= tasklist /fi "imagename eq adm.exe" goto goto loop if /i %errorlevel% GTR 0 goto yes :yes ECHO. ECHO. ECHO adm is finished FOR /F "TOKENS=1-4 DELIMS=/ " %%i in ('date /t') DO (SET DATE=%%i-%%j-%%k) rename C:\AVEVA\pdms11.6.SP1\pdmsuser\dice.txt KUPE-DICE-CHECK-%DATE%.txt MOVE C:\AVEVA\pdms11.6.SP1\pdmsuser\KUPE-DICE-CHECK-%DATE%.txt C:\PDMS\Results\Dice -- --------------------------- Thanks for the help... Neil |
|
| 4830. |
Solve : How to rename file in sequence when file name already exists?? |
|
Answer» The below works fine providing that desktop6.ndkOLD1 do not already exist, how can I have it to rename the file in sequence so that it will TRY first desktop6.ndkOLD1 then desktop6.ndkOLD2 etc. |
|
| 4831. |
Solve : Restricting some of the websites...?? |
|
Answer» Hello to all, |
|
| 4832. |
Solve : Copying straight to cd? |
|
Answer» Is it possible to copy a file straight to a cd via BATCH, as in without another program? If the cd has drive-letter-access, e.g. in Windows packet writing, then yes. |
|
| 4833. |
Solve : commands after batch file that pings not working? |
|
Answer» Quote from: Two-eyes on September 05, 2009, 07:43:56 AM @helpmeh: was that an insult?...no wait...don't wanna know... No that wasn't an insult at all. Mods can close threads, but there is no need here. the 6 e-mails saying: a REPLY has been posted on the TOPIC. but now i see a little checkbox down help...let's uncheck it and hope Two-eyes Just forget bout itQuote from: Two-eyes on September 05, 2009, 07:52:54 AM Just forget bout it Gladly |
|
| 4834. |
Solve : Starting from .bat with spaces in filename? |
|
Answer» How can I start an application from a batch FILE when the NAME of the app INCLUDES spaces - for example, to start "run me.exe". |
|
| 4835. |
Solve : Folder backup using timestamp? |
|
Answer» I have created a .bat or .cmd file (actually is there any difference?) which (scheduled daily) enables me to copy 5 files to a folder located on a NAS box, for backup purposes. However, with each new backup the existing folder (and its contents) are gone. How can I avoid that by appending the currently backed up folder with (say) a time stamp? very nice simple way, but it still shows the day abbreviated. I also USE token for dated filenaming. but I use rename to change name to my desired naming. this is good and simple. thanks for sharing it. |
|
| 4836. |
Solve : How Do I Execute Same Command in Current Directory's Children Directories?? |
|
Answer» For any given directory, all I WANT to do is go into each of its immediate child directories and execute the same command. |
|
| 4837. |
Solve : Need help creating a batch file with .wvx extension? |
|
Answer» Background I have a number of WMV files on my website's server and Im creating two sets of links to them. One for instant viewing and the other for downloading it. Creating the download link is easy since its just a link with the full path name (webserver/path/filename.wmv). For the streaming link, I have a "director file" with a .wvx extension which is simply a text file with a short script in it that tells the client PC to execute windows media player to play said wmv file. The *.wvx text file has the following string in it: http://YourWebServer/Path/YourFile.wmv" /> The Task I would like to create a BATCH file that can create a *.wvx file for each of the *.wmv files on the drive. The newly created wvx should have the same name as the wmv file (just different extensions) and also inside the *.wvx should reference to the wmv file on the server. I hope this makes sense. My attempt for %%a IN (*.wmv) do echo " http://Mywebserver/path/%%~na.wmv"/> " > %%~na.wvx I've come up with this string and it does everything for the most parts, but it list the entire string on one line but as you can see in the above example, the string is suppose to be on 5 lines. or the link doesn't work. I know bearly anything about batch files commands so any help will be welcomed @echo off For /f "delims=." %%a in ('dir /b /s PATHTOFILES*.wmv') do ( Echo %%a Echo ^ > %%a.wvx echo ^ >> %%a.wvx echo ^ >> %%a.wvx echo ^ >> %%a.wvx echo ^ >> %%a.wvx ) That should work. I haven't tested it though. If I understand what you want, it is not worthwhile doing it in batch. This kind of job could be DONE in some kind of HTML page with some code for either doing a down load or STARTING a stream. I tried your code Helpmeh, but it didn't work, it didn't even create a .wvx file I substituted ('dir /b /s PATHTOFILES*.wmv') for ('*.wmv') since I placed the batch file in the same directory as the wmv files. But no avail. I'm not familar with any HTML code for creating a metafile for wmv files Geek-9pm, but i'm listening natedj, Does anyone know what you are talking about or what you are trying to do?I though I was clear in the topic but in a nutshell. I need to create a text file to point to a WMV file on my website. (why? .... because linking to it offer a download option in some browers and not actually playing/streaming the file) I've be creating these files manualy i.e. create one, do a "save as", change the file name (thats inside of the string) to the newly target file and so on This is the text file string that is in each .wvx file http://YourWebServer/Path/YourFile.wmv" /> I then save this text file with a .wvx extension. Why do I want a batch file for this ... I have a ton of wmv files that need wvx files to point to them. Where id i get the idea from? http://www.microsoft.com/windows/windowsmedia/howto/articles/webserver.aspx#webserver_topic3 Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject") strFolder = "c:\test" Set objFolder = objFS.GetFolder(strFolder) For Each strFile In objFolder.Files If objFS.GetExtensionName(strFile) = "wmv" Then strBaseName = objFS.GetBaseName(strFile) strFileName = Replace(strFile.Name," ","%20") WScript.Echo strFileName, strBaseName strNewFileName = strBaseName & ".wvx" Set objOut = objFS.CreateTextFile(strNewFileName,True) objOut.WriteLine("<ASX VERSION=""3.0"">") objOut.WriteLine(" ENTRY") objOut.WriteLine("<REF HREF=""http://YourWebServer/Path/" & strFileName & """" & "/>") objOut.Close End If Next output Code: [Select]c:\test> cscript /nologo myscript.vbs I have read over the reference you gave. That looks cool. You can also use Flash player, but that is another story. The issue is your web site does not support real time streaming of video, so the thing from Microsoft with help WMA do a better job and avoid a broken stream. So you want to create the HTML stuff automatically on you PC and then load the files to your site. OK. Now I get it. I used to do that sort of thin when I have a number of sites that I want to have ALMOST the same code on each site but just a few changes from an list. And I did it with a batch file and then uploaded the changed files to my sites. I I did that with batch also. So yea, you can do that. You can do that with a FOR loop. Some of the others here will tell you how to use FOR to substitute the text in a number of files. I am a FOR loop flunky, so I would just create a batch files that would pass a list of names to another batch file to process the text. I had to INCORPORATE a program into the batch that would do the actual text substitution. Never could understand how FOR does that, just easier for me to write a program that opens a file, substitute from a list and writes a new copy of the file to a directory. The vbs thing is what you could use, but I used QBASIC, more primitive, but does the job. |
|
| 4838. |
Solve : unhide hidden folders...? |
|
Answer» can someone guide me how to unhide hidden folders in my flash drive?? can someone guide me how to unhide hidden folders in my flash drive?? Try: Attrib -h "e:\virus 123" Peculiar name for a FOLDER...I was gonna say the same Dusty...maybe you don't want to unhide those and simply format that flash drive...attrib -s -hQuote "virus 123" something seems fishy.....TNX! Dusty .... it works! |
|
| 4839. |
Solve : checking if file names contain spaces? |
|
Answer» As the title READS, I would like to be able to see if a file name contains spaces, or if the path contains spaces. |
|
| 4840. |
Solve : Change file names? |
|
Answer» I have 1000 files of different names, I want to CHANGE their names using a BATCH file to this way |
|
| 4841. |
Solve : batch file program? |
|
Answer» How to show current date WITHOUT prompting the user to enter NEW dateTry using date /t |
|
| 4842. |
Solve : finding current folder in and setting it? |
|
Answer» As the topic reads, i need to find the folder that batch is CURRENTLY in. Then i need to set it to something like %opath% |
|
| 4843. |
Solve : Renaming multiple files at once? |
|
Answer» I would like to rename a large amount of files at once. For EXAMPLE: |
|
| 4844. |
Solve : SOLVED -- Trouble with script run from Scheduled Tasks? |
|
Answer» Hi all, On the flip side, if I logon and execute the same scheduled task or execute the script manually, all applicable files in those locations contained in the parameter file are deleted successfully. It appears the the drive is only mapped when you are logged on and then only if the drive was made persistent. How and when is the drive mapped? Can you MOVE mapping the drive to your batch file? If you need to make temporary mappings for your file and you don't want to screw up any system settings, it's possible to map multiple drive letters to the same network drive. Good luck and glad to see you back Cameron. Many thanks for the reply & welcome back SIdewinder; has been a while. Taking on board your suggestion is the likely way to go - had skipped over the idea a few days ago. Will look into the use of pushd/popd and see how I go. Problem solved, so for anyone interested read on ..... The use of pushd & popd as I'd thought was a go-er was not the way forward. Had issues with how pushd truncated USB network storage device paths. Instead used the 'subst' command. Placement is majorly important due to the 'call' statement - the 'subst' statements must be executed within the 'call' statement (in the same shell). This is how it was resolved .... Code: [Select]set Directories=%~dpn0.txt set Recursive=TRUE for /F "tokens=1,2,3,4 delims=;" %%i in (%Directories%) do ( set Dir=%%i set Age=%%j set Files=%%k set Recursive=%%l call %0 deletefiles ) goto FinishRun :deletefiles SUBST X: %Dir% set RFlag= if %Recursive%==TRUE set RFlag=/S forfiles /P X: /D -%Age% %RFlag% /M %Files% /C "cmd /c @echo Deleting @path as it is older than %Age% days >> %OutputLog%" @echo forfiles /P X:(%Dir%) /D -%Age% %RFlag% /M %Files% /C "cmd /c del /F @path >> %OutputLog%" >> %OutputLog% forfiles /P X: /D -%Age% %RFlag% /M %Files% /C "cmd /c del /F @path >> %OutputLog%" SUBST X: /D @echo. @echo *** Sleep for %SleepTime% seconds *** @echo. @echo. >> %OutputLog% @echo *** Sleep for %SleepTime% seconds *** >> %OutputLog% @echo. >> %OutputLog% sleep %SleepTime% goto :EOF The Parameter file also changed to be explicit in its detail ... C:\batchjobs\logs ;31 ;*.txt ;TRUE C:\batchjobs\logs ;31 ;*.log ;TRUE C:\batchjobs\logs ;31 ;*.zip ;TRUE C:\batchjobs\logs ;7 ;*.bkf ;TRUE \\192.168.0.115\Backup\BKUP\BKUP-DAILY ;8 ;*.bkf ;TRUE \\192.168.0.115\Backup\BKUP\BKUP-SYSSTATE ;2 ;*.bkf ;TRUE \\192.168.0.115\Backup\BKUP\BKUP-WEEKLY ;21 ;*.bkf ;TRUE Hope this is all of some HELP for anyone else too. Cheers, Cameron |
|
| 4845. |
Solve : Convert date from MM/DD/YYYY into YYYYMMDD format? |
|
Answer» Hello all, Convert date from MM/DD/YYYY into YYYYMMDD format Code: [Select]@echo off set dt=mm/dd/yyyy set newdate=%dt:~6,4%%dt:~0,2%%dt:~3,2% echo %newdate% It becomes problematical when using arithmetic on dates. Everything is fine if both dates are in the same month. The real fun begins when you "borrow" days from the previous month. I can't sell a VBS script to anyone today. thanks sidewinder... |
|
| 4846. |
Solve : Turning command prompt while on log on screen? |
|
Answer» Quote from: Salmon Trout on August 31, 2009, 12:45:31 AM Threatening me would be a very bad mistake. lolBut can he do anything about it?you poor UNINFORMED Dense as Plumbum fools. A contrexing is what you could GET. but I doubt time would be wasted on such an endeavor.Hehehehe Endeavor. That's a pokemon move. Quote from: Helpmeh on SEPTEMBER 02, 2009, 08:48:51 PM Hehehehe err yeah... it's also a word.Quote from: BC_Programmer on September 02, 2009, 08:56:49 PM err yeah... it's also a word.proof: http://www.thefreedictionary.com/endeavorNow that the original content was removed and any relevance that this post had to DOS is gone should this get moved to "Off topic" Quote from: mroilfield on September 02, 2009, 11:58:25 PM Now that the original content was removed and any relevance that this post had to DOS is gone should this get moved to "Off topic"yesOr we just LEAVE this topic alone so we can STOP bumping it. Topic Closed. patio. |
|
| 4847. |
Solve : 4 Questions (2 Answered) Tough to Solve...?? |
|
Answer» HELLO to all, As I have four questions (2 solved) which are mentioned below: 1.) I'm using a batch file & it is in Startup folder. It runs every time when I log in. I'm using three commands in it. Every time its shows Ok mesage when a command is executed successfully, so I want to disable the "Ok"mesage, I have used "@ECHO OFF" after every command but it doesn't work. Commands are netsh firewall & netsh interface ip so when they are executed, Ok mesage is appeared, I want to disable the mesage or it should not be appeared. And I also want to ask that Can that blank window be minimized automatically and runs in small window above the clock or in any side so that whenever it runs user can not notify that a batch file is running.? Ans) If we do not want to see any messages OR To get rid of the screen output use redirection and redirect the output to NULL use this method: netsh firewall ... ... 1>nul 2>nul for example ... "netsh interface ip set address name= "Local Area Connection" static 10.0.0.1 255.0.0.0 10.0.0.50 0 1>nul" Then the OK mesage will not be appeared. & when we run a batch file, blank window appears, If we want that window to be minimized then instead of running the batch file directly, run it like so: start /min "" cmd.exe /c d:\Tools\test.bat where d is the drive in which batch file exist. 2.) My second question is that, I want to send a mesage at a particular time, for example at 10.00pm or After one hour of login. The syntax of SENDING mesage is Msg * Hello. Ans) We can use SCHEDULED tasks located in Start --> All Programs --> Accessories --> System Tools --> Scheduled Tasks. Add the Batch File and you can set up when you want it to run. 3.) Can we send the mesage in any colorful window, & Can we change the color of the window (in which mesage appears) or can we change the title of the window when it appears. ? 4.) Can we enable or disable lan or any Local area Connection by any command or by batch file? 1. What is are the commands? 2. Scheduled tasks? 3. To change the color of the command prompt window, type color /? and press Enter. To change the title, the command is title TITLE HERE 4. Why?1. Ah sorry, I seem to have missed that. I don't think there is a way to get rid of the OK message. To start a batch file minimized, use start /min file.bat. 2. Scheduled tasks is located in Start --> All Programs --> Accessories --> System Tools --> Scheduled Tasks. Add the Batch File and you can set up when you want it to run. 3. There is no way to change that. 4. Still, why? Sounds devious to me....Hello Dear, My 3rd question, "Changing title and color of mesage box" Dear I'm not sure but I think its possible but I'm unable to use that command, Below I'm POSTING the syntax of it from a website so may be you can help me about it. http://www.pitrinec.com/bar_help/pg_hlp_cmd_msg.htm -------------------------------------------------------------------------------- Shows message window. Command Tree: Message \ Show Message . Syntax: (Xpos, Ypos, "MessageText", "Title", OKButton) Xpos X-coordinate of the message window position. Ypos Y-coordinate of the message window position. MessageText Text you want to display in the message window. Title Title of the message window. OKButton Can be one of these values: 0 - OK button is not shown. The command must be used to close the message window. 1 - OK button is shown in the message window. . . Example: <#> This macro will display message window <#> (100,100,"This is a message to notify user just about anything....","Message",1) -------------------------------------------------------------------------------- I'm posting link of another site, In that it shows that msgbox is the command of batch file but it doesn't run in cmd. http://www.jpsoft.com/help/index.htm?msgbox.htm http://www.jpsoft.com/help/index.htm?window.htm -------------------------------------------------------------------------------- 4th Question, I'm using a computer which is shared, so I want some of the users not to use lan. I will put the batch file on the startup folder so that it will automatically disables the lan. I hope you understand now. Any way dear, Thanks very much for helping me so much. I will be waiting for your reply. Take Care. Have a Nice DAY. |
|
| 4848. |
Solve : printing in dos to file (filename.txt ASCII) yields a portait output? |
|
Answer» Can anyone TELL me HOE to change the dos print command to yield a landscape output? |
|
| 4849. |
Solve : Batch file erase, don't have a clue? |
|
Answer» On my wife's computer (DELL Latitude) running Windows XP SP2, when I make an autoexec.bat file and place in the root directory after rebooting, the file has been erased. I have gone through this procedure several times and it always gets erased after booting. This is a really simple .bat file that only sets the path. Any ideas? The AUTOEXEC.BAT file may often be found on Windows NT, in the root directory of the boot drive. Windows only considers the "SET" and "PATH" statements which it contains, in order to define environment variables global to all users. And another from this site: Quote Windows XP searches the startup files and processes the environment variable settings in the following order: Here's a long odds reason why you "lose" the file -- if you are using Notepad to create the file, Notepad will append the suffix .TXT to the file when it is SAVED therefore Autoexec.bat will not be found. When saving with Notepad enclose the the filename/suffix to save in " ' e.g. "autoexec.bat" Good luckThanks for the tips. I am editing the file from the dos prompt edit command. I have already created the autoexec.bat.txt file using notepad so that I can just delete the .txt part and run the .bat from prompt. Thanks for the tip about the .nt file. I don't know MUCH about the windows enviroment, just an old dos guy that does a lot of stuff in Dbase. The funny THING is that I use an autoexec.bat file on a different computer and don't have the erase problem. Thanks again, Doug |
|
| 4850. |
Solve : Changing Files names in a sequentail order? |
|
Answer» I have 1000 files of different names, I want to change their names using a batch file to this way |
|