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.
| 8551. |
Solve : BAT File to update files? |
|
Answer» Hii you need a source to update this file from.you can't just update excel files like that. the proper WAY is to open both excel files, one for reading, one for writing. |
|
| 8552. |
Solve : Search for a text string in a file ...? |
|
Answer» I would like the search a specify string in a FILE. I would like the search a specify string in a file.pls read again the help for find. what does /v stands for. You want to get lines with "error" right?Thanks . i think in my case i should use /C in my situation. Also, when i has 2 lines has error it show c:\a.txt: 2 And my next question is how can i capture the "2" as a parameter, because i NEED to echo this to other file. Many thanksuse the for LOOP. set tokens, delims=: and let the for loop parse the output of the find command. then you can capture the output you want. I am sure if you do a search in this FORUM, you can find examples. |
|
| 8553. |
Solve : Pushd? |
|
Answer» Hey guys I am trying to use the pushd command to map a drive and copy a screensaver file. I was then planning on using AD to select the screensaver. Problem is I can't GET the pushd command to work. Any ideas? |
|
| 8554. |
Solve : Copy Batch file? |
|
Answer» I use to know how to create a batch file and for some reason forgot the steps. I want to create a bat file that will copy files from ONE network drive to another and over write with out prompt. Any helpYou may first map both network drives under DOS environment then use the copy command in batch file. The command you will use under Batch file is : Yes I do and here is the bat file I worte and it doesn't workNext time try to be more specific as to what went wrong. "it doesn't work" is not helpful at all.Quote @echo off Or maybe it just needs some quotes?The quotes were the problem. I ADDED a pause in it so I could see why it didn't work - so sorry to sidewinder for not going into more detail. First time using this forum so next time I will give all more info. Thanks to all for your help |
|
| 8555. |
Solve : help with ansi in vista?? |
|
Answer» im trying to enable ANSI.sys in CONFIG.NT , ive added lines DEVICE=%SYSTEMROOT%\system32\ANSI.SYS and DEVICE=%SystemRoot%\system32\VT52.SYS , they both dont work. ansi.sys and vt52.sys i MEAN ive read the documentation on ansi.sys no matter what i do it wont work?What is it you expect ansi.sys to do? If I recall from the WayBack years, you had to send escape sequences from which you could changes colors on the monitor, remap the keyboard, or send printer sequences to a dot MATRIX printer to change the font. Many of the functions of ansi.sys can be done in other ways these days. At one point I had a sequence that CHANGED the command prompt into the Texas flag of Independence. thats pretty much what i expected it to do.. i thought maybe i had forgot the proper way to write an escape sequence but i DOUBLE checked and the sequence is right .. does ansi even work with vista? |
|
| 8556. |
Solve : create folder with previous date? |
|
Answer» Please help me to create folder with PREVIOUS date Dear ghostdog74its difficult for me to help you when you just tell me that, without desribing what you did, your environment , your code especially, etc...you should provide enough details of your output for US to help you. |
|
| 8557. |
Solve : Run command for every line in file.? |
|
Answer» I have written a SCRIPT to generate a LIST of maps for a game. It then strips the .bsp as is required by my menu generation script. Now I need to make the SYSTEM run "menugen " for every line in that list. Every filename is on a new line. Can anyone help?file.txt FRANCE batch file Quote @echo off result Quote menugen "France" <3 Perfect. THANKS |
|
| 8558. |
Solve : admin cr8tor? |
|
Answer» hey can any1 improve this code? |
|
| 8559. |
Solve : saving images from laptop....? |
|
Answer» i have some files i need to save on my laptop but the windows registry ran out i had a crack but whenever i boot windows it says you must REGISTER at the login...i click ok and it says windows is already registered then goes back to the windows user NAMES for login....can i somehow USE DOS and save the files ontop a usb sd card i dont have an A: DRIVE...or is there anyother way of GETTING back into windows?Sorry about your dilemna but we cannot assist with pirated software. |
|
| 8560. |
Solve : Pasting Serial Key? |
|
Answer» i install programs in windows all day when u have to copy and paste 1234, then copy and paste 4321 and then copy and paste abcd all day long Get a better job. PS Johnny has 2 letter 'n's |
|
| 8561. |
Solve : Batch File for Deleting everything in c:\Documents and Settings Folder? |
|
Answer» Hi, im not victimizing anyone's computer, i need this batchfile for my job. i need the documents and settings folder fresh everyday so that when users log in they will be able to load they settings. this has been an issue with our network. This does not make sense...why would the user's need an empty D&S folder to load their settings ? ? I don't think we're getting the complete story.I'm with everyone else. I would strongly advise doing this. If you absolutely must do something like this, I'm sure there are better and safer methods.If this is a practical joke of some sort, don't do it because it's not funny. A lot of important files are kept there. Deleting it could render the computer unusable. Don't do this for jokes or games or because you're pissed at someone.If this network of yours consists of shared computers or computers for public use, check out SteadyState. Otherwise I'm with the other posters. Not only is the Documents and Settings folder critical for the operation of Windows but deleting it's subfolders will break important links with the registry. you dont understand guys. the users who logs in our network have MANDATORY PROFILES w/c is downloaded from a server to the local machine. everytime they log in, they leave a user folder in the Documents and Settings. SOMETIMES when they login to that same machine the MANDATORY PROFILE doesn't load correctly that's why we need to delete the user folder from the previous login. BTW, i need to leave the Administrator, All Users and other hidden system folders there. I just need to delete the user folders which are 6 characters long.But if you delete c:\documents and settings, you delete the administrator account too....Microsoft has this to say: "Profile management should be done preferentially by policy. Mandatory profile use, although permitted, is less manageable and more prone to create administration problems, thus it is not recommended" Quote Sometimes when they login to that same machine the MANDATORY PROFILE doesn't load correctly that's why we need to delete the user folder from the previous login Perhaps you should try troubleshooting why the profiles don't load correctly instead of taking a hatchet to the profile folders. Batch code could do this, but will probably have problems with the six character profile name restriction. VBScript could handle the name length restriction and also has a hook to Active Directory. SteadyState was not helpful? To take care of the 6 character part, couldn't you just use the ? wild card 6, 5, 4, 3, 2, and 1 times? Code: [Select]del ??????.* del ?????.* del ????.* del ???.* del ??.* del ?.* Just an idea, or maybe I'm missing the point (which is only GOOD if someone is trying to stab you or shoot you with a sharp PROJECTILE ). |
|
| 8562. |
Solve : Manipulating Programs with Batch? |
|
Answer» I´m trying to write a batch file that |
|
| 8563. |
Solve : How can I delete a file which is opened by another application by Batch file? |
|
Answer» any chance that pic (osama) could be changed? makes me want to take a carp ! wow, such senseless bitching about. this thread should have stopped at post #3 or #4. wow, such senseless bitching about. this thread should have stopped at post #3 or #4.Why are you flaming me? I'm just trying to intervene..... and that post you are talking about demonstrates the same point as contrex has been saying for a while. And I didn't accuse anyone of wasting space.Let's all cool off here As far as I see, replies 1, 2 and 3 are the same, in essence. #1 says the file can't be deleted when in use, #2 says you need to close the application using it, and #3 is the same as#2. From there on there is nothing useful, just people going way off topic and arguing about nothing. I must insist that there is no flaming - STOP these PETTY arguments. If there is SOMETHING you need to discuss with another member, take it to PMs, not the OPEN forum. I am locking this topic. If you are the original poster and want this topic to be re-opened, please PM myself or another moderator. Thanks. |
|
| 8564. |
Solve : Font size in CMD? |
|
Answer» i KNOW color and mode change the color and size of the command prompt when used like from a batch file but is there a way to change the font size?use the propertites settings?But that changes the command prompt box for ever until someone changes it backQuote But that changes the command prompt box for ever until someone changes it backDo you mean forever in a SINGLE session? If not you could just click "Apply properties to current window only", but you probably want a font command I think. Is there one... I don't know. Quote i know color and mode change the color and size of the command prompt when used like from a batch file but is there a way to change the font size?i can give you an idea. you have to code on your own. It uses the registry key at HLCU\console. You can FIND the key called "FontSize" . Then you can either export this key to a reg file. Then you can change the size load it USING some scripting registry tool such as reg.exe or regedit, or you can directly modify this key through that scripting tool. eg using registry editor and a reg file (have to change the Fontsize inside this file as desired). Code: [Select]regedit /s FontSize.reg or through direct Code: [Select]C:\>reg /f delete HKCU\Console\%SystemRoot%_system32_cmd.exe\FontSize C:\> reg add /? If you not confident , don't try this. |
|
| 8565. |
Solve : saving images from laptop 2....? |
|
Answer» WELL my comp crashed and i had to use a friends windows CD and the key on the back of my laptop wouldnt WORK can you tell me someone who can HELP activate it a windows NUMBER or something in the USMicrosoft |
|
| 8566. |
Solve : Multipurpose Batch File? |
|
Answer» Can you HELP I want to create a bat file that will do the following Copy a folder from a CD to the hard drive You don't need me to TELL you how to do that, do you? Quote I'm unsure of the command to create a shortcut The SHORTCUT command is in the Microsoft Windows NT Resource Kit available here http://www.dynawell.com/support/ResKit/winnt.asp example shortcut -t "c:\test\File To LINK To.exe" -n "c:\test\Shortcut Name" Type shortcut /? for full syntax Quote And with the excel viewer is it possible to make the bat file bypass all the yes, no & next buttons in the installation process? msiexec /i XLVIEW.MSI /qn ACCEPTEULA=1 ASSOCIATE=1 http://www.msfn.org/board/index.php?showtopic=53671&mode=linearplus here's a vbscript to create shortcut. amend to your needs Code: [Select]Set Shell = CreateObject("WScript.Shell") DesktopPath = Shell.SpecialFolders("Desktop") Set link = Shell.CreateShortcut(DesktopPath & "\test.lnk") link.Arguments = "1 2 3" link.Description = "test shortcut" link.HotKey = "CTRL+ALT+SHIFT+X" link.IconLocation = "app.exe,1" link.TargetPath = "c:\blah\app.exe" link.WindowStyle = 3 link.WorkingDirectory = "c:\blah" link.Save |
|
| 8567. |
Solve : many computer problems? |
|
Answer» Ok, so i just finished install CA security system on my computer, and it works fine. But when I try to go ONTO a game or website with any kind of graphics, it says i need to download macromedia flash player. So i went to adobe.com, and there's no way to install it. I tried to go to the troubleshooting PAGES, but they won't show up. Someone told me i needed to get netscape to download flash player, so i tried to get netscape. I ended up DOWNLOADING netscape navigator, i have no idea what that is, but it's all i could get. And i still can't download flash. I went to a new website, and eventually downloaded flash, but when i go BACK to the game or w/e, it still has the same message. And another problem is i can't get into my email accounts either. Nothing will show up at all. Also, i can't create user accounts at all. The computer won't restart either. I have to completely shut it down and turn it on. I think i completely destroyed my computer. I WOULD restore it, but the restore program won't show up when i load it. If anyone has any advice whatsoever, please tell me. I would really appreciate it, |
|
| 8568. |
Solve : Qbasic Comands in ms-dos? |
|
Answer» hey guys i was just wondering if some one can plese give me an exolanation for th comands for q BASI below. |
|
| 8569. |
Solve : Trace? |
|
Answer» What is the command you can use to trace the path to an INTERNET site. |
|
| 8570. |
Solve : what is the default program that Windows XP uses to run a batch?? |
|
Answer» What is the default program that Windows XP uses to run a batch file when you double click on a batch file? What is the default program that Windows XP uses to run a batch file when you double click on a batch file? You just gotta be joking... Are you sitting in an exam room??? Homework or other school projects are handled on the Homework.com forum...This is the SECOND question asking that in two days. It must be coming up in tests. In fact it has already been answered on here, so xgmx is a really lazy student, it seems. Asking for answers within a time limit is taking the p*ss. Do your own homework, test CHEAT. |
|
| 8571. |
Solve : IF DIRECTORY CHANGES SEND A NET SEND?!?!?!?? |
|
Answer» I HAVE A FOLDER CALLED c:\FAX AND WHEN THERE IS A NEW FILE WRITTEN TO IT I WANT TO RUN A BATCH FILE THAT WILL CHECK TO INSURE THERE IS A NEW FILE THERE SINCE LAST TIME. THEN DO A NET SEND TO A USER. I'M ASSUMING I NEED TO USE AN IF STATEMENT. I'M HAVING TROUBLE TO WRITE THE FILE. I HAVE A FOLDER CALLED c:\FAX AND WHEN THERE IS A NEW FILE WRITTEN TO IT I WANT TO RUN A BATCH FILE THAT WILL CHECK TO INSURE THERE IS A NEW FILE THERE SINCE LAST TIME. THEN DO A NET SEND TO A USER. I'M ASSUMING I NEED TO USE AN IF STATEMENT. I'M HAVING TROUBLE TO WRITE THE FILE.don't use capital letters when WRITING. also the least you could do is to read up on how to program in batch. here's a random search for you. There is a section on the if statement and how to use it. also, do check out if /? and "net send ?" and here. I'am Sorry if MyReply is too late but, I hope this solved your problem... ..UNTESTED.. Code: [Select]@echo off REM clear all variable :clear cls set skip=1 set file_%skip%= set new= :loop for /f "skip=%skip% delims=" %%c in ('dir "c:\fax" /s /b /o:d') do ( REM check for new file set file_%skip%=%%c call set /a skip=%skip%+1 goto loop ) if not defined sum set sum=%skip% if /i "%sum%" lss "%skip%" (goto RESULT) else (ping localhost -w 1 >nul&&goto clear) :result call set new=%%file_%sum%%% NET SEND /RIC Youhave new file : "%new%" goto clear |
|
| 8572. |
Solve : is was unexpected at this time ??? |
|
Answer» Attempting to write my first bat script. (knockknock) |
|
| 8573. |
Solve : WINDOWS BROWSE AS INPUT OF BATCH FILE? |
|
Answer» Hi, srry i think my ques is not phrased properly 1) set up a prompt, maybe set /p , so that user can key in the files/folders they want to be moved 2) set up a menu based system, where you list out the files/folders names as number bullets, then let the user key in the numbers ( maybe using commas to separate them ) that corresponds to the files they want to move, then the batch will do the processing..eg Quote from: ghostdog74 on August 31, 2007, 06:22:04 AM Quote from: jasdeepsg on August 30, 2007, 06:51:48 AMsrry i think my ques is not phrased properly thanx for yur suggestion but it there are 100's of files and folders so this is not LOOKING feasible to me and moreover i need GUI .Quote from: jasdeepsg on August 31, 2007, 07:03:23 AM there are 100's of files and folders so this is not looking feasible to me and moreover i need GUI . You need to learn Visual Basic or PAY a professional. minimally, Code: [Select]Option Explicit Dim objDialog,result Set objDialog = CreateObject("UserAccounts.CommonDialog") objDialog.Filter = "Text Files|*.txt" objDialog.Flags = &H0200 'multiple file select objDialog.FilterIndex = 1 objDialog.InitialDir = "C:\TEMP" result=objDialog.ShowOpen If result =0 Then Wscript.Quit Else Wscript.Echo objDialog.FileName End If going further than this, you have to start to learn some real PROGRAMMING... |
|
| 8574. |
Solve : Save Resoults in *.txt file? |
|
Answer» hi all!, |
|
| 8575. |
Solve : Need help logging batch command results? |
|
Answer» We are having problems with our exchange server STARTING up the stores after a cold backup and I want to log each command from the NET Start to a log file to show the RESULTS of each command. |
|
| 8576. |
Solve : Copy only the latest updated files? |
|
Answer» The following: |
|
| 8577. |
Solve : Getting Process ID of running applications from a specific network location? |
|
Answer» Can somebody help me how can I find process ID of the processes running in specific network LOCATION with a DOS COMMAND or batch?try TASKLIST /s |
|
| 8578. |
Solve : Batch File Parameters? |
|
Answer» I have a very simple batch file that echos data to a com port. I need to echo a data string that is passed in via a parameter. The problem is that the data string has spaces so when I try to pass it in to one variable, anything after the space gets cut off.
I nominate this for quote of the Month... It's on XP Pro, but the %~1 was EXACTLY what I was LOOKING for! Thanks! --Dave |
|
| 8579. |
Solve : How to get all properties from a file?? |
|
Answer» Hi, |
|
| 8580. |
Solve : Time converted in to seconds? |
|
Answer» Hi all, you can do your own maths in batch, If you prefer a batch solution, here's one... Code: [Select]@echo off set /a hh=%time:~0,2% set /a mm=%time:~3,2% set /a ss=%time:~6,2% set /a hh*=3600 set /a mm*=60 set /a hh+=mm set /a hh+=ss set /a timeseconds=%hh% echo time %time%, seconds since midnight = %timeseconds% Or, written more compactly, Code: [Select]@echo off set /a hh=%time:~0,2% & set /a mm=%time:~3,2% & set /a ss=%time:~6,2% set /a hh*=3600 & set /a mm*=60 & set /a hh+=mm & set /a hh+=ss set /a timeseconds=%hh% echo time %time%, seconds since midnight = %timeseconds% Thanks, both off you have been a great help |
|
| 8581. |
Solve : Batch file that solves lan problems?? |
|
Answer» Hey! |
|
| 8582. |
Solve : delete file in batch? |
|
Answer» to del file name cracker.exe in all my partition and drives |
|
| 8583. |
Solve : Echo and set? |
|
Answer» hello. i need to now how to make a code like this: I can't actually imagine a school that teaches batch programming ? Plenty of community colleges and introductory Comp Sci courses use batch, QBasic etc as introductions to programming concepts. I can't imagine why when a poster comes here for information, people find a need to editorialize about homework and such. Whether people learn from a book or each other, it's STILL learning. The OP never said a word about homework. Code: [Select]@echo off set /p name=What is your name? for /f "tokens=1-2" %%i in ("%name%") do ( echo Oh! hello %%j ) Many people find that providing ready-made batch files to people, who display little or no interest in the coding issues, for work or school purposes is not why they contribute to help forums. Quote from: Sidewinder on August 31, 2007, 07:41:36 AM The OP never said a word about homework. They seldom do |
|
| 8584. |
Solve : create user account? |
|
Answer» hmm nvm, ... anyway i only want to help my friend change back his administrator account password. erm.... i got 3 pc, 1 sp3 "pirate"1 VISTA and 1 sp2 Which machine ? ? This seems to be a reccurring theme... |
|
| 8585. |
Solve : How to know if a batch's parameter is empty? |
|
Answer» Hi, |
|
| 8586. |
Solve : how to create a log showings specific files? |
|
Answer» i have a main folder, within it, 6 folders inside it...each CONTAINING somtihng(pics)...i want to retrieve only jpg files...just the names... |
|
| 8587. |
Solve : Command output as set variable? |
|
Answer» hi boys and girls of course, |
|
| 8588. |
Solve : Dos command about chkdsk? |
|
Answer» Hi PEOPLE, |
|
| 8589. |
Solve : Need macro? |
|
Answer» I would like a MACRO that will allow me to PRINT all autotext entries into a Word document. I have a macro that will do that for the Normal template, but I have several other templates that it will not work with, even with renaming "NormalTemplate" to the other template's name. Below is what I have to print autotext entries into a Word document for the Normal template. How do I edit this macro to work for other templates? |
|
| 8590. |
Solve : setting up dns suffix via command prompt? |
|
Answer» Hello all, |
|
| 8591. |
Solve : /MAKE switch????? |
|
Answer» Can anyone interpret this script for me, and maybe give me a RESOURCE so I can study this stuff? This is a batch file that runs before CALLING several vb6 .exe's. |
|
| 8592. |
Solve : copy con in batch? |
|
Answer» Alright, what I'm trying to do is create a batch file that'll create the text files I list (the color change is to let me know when it's done at a quick glance). I'm making a sort of calendar, so the files looks like so: Alright, what I'm trying to do is create a batch file that'll create the text files I list (the color change is to let me know when it's done at a quick glance). I'm making a sort of calendar, so the files looks like so: When you say it freezes after the first Copy Con command Copy is waiting for input from the Console (keyboard) to write to the first file. When the input is complete CTRL+Z is necessary to terminate that Copy and continue. No input no continue.. why do you need to use a copy con? Quote from: ghostdog74 on July 01, 2007, 03:32:34 AM why do you need to use a copy con? I was wondering that. I dunno... I thought I'd try copy con because it's new to me. I just need something to create all the files, preferably without a break between commands. Know a better command keyword to use? Thanks for clearing up how copy con works.Quote from: Computer_Hopeless on July 01, 2007, 06:40:03 AM I just need something to create all the files, preferably without a break between commands. Know a better command keyword to use? echo sounds like the command to use. What are the files supposed to contain? If it is OK for them to be empty you could use echo like this echo. > 7-1.txt echo. > 7-2.txt etc Yeah, that'd work. Thanks. Just for the sake of doing more work to try to avoid doing work in the future, what should I use if I wanted to put in, for example, a list of the hours of the day in half hour increments with no break or prompt between commands?Quote from: Computer_Hopeless on July 01, 2007, 06:58:39 AM Just for the sake of doing more work to try to avoid doing work in the future, what should I use if I wanted to put in, for example, a list of the hours of the day in half hour increments with no break or prompt between commands? What, you want to FILL a folder up with 48 empty files which are named after the hours and half hours of the day? I guess something like this would work. I assuming the 24 hour system. If you need a 12 hour system with am & pm then I am sure you can work out what changes are needed. echo. > 00-00.txt echo. > 00-30.txt echo. > 01-00.txt [snip] echo. > 23-00.txt echo. > 23-30.txt (You cannot use a colon in a file name) However, like the other people who have learned to code before you, you will soon be realising that it is a pain in the @ss to keep typing the same thing over and over again, ALSO it makes code which experienced programmers smile at, which is the point at which one learns about one of the fundamental programming constructs, the loop. Loops exist in batch programming language. Here is one which will do the same job as the 48 line batch I outlined above. Code: [Select]@echo off for %%H in (00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23) do ( echo. > %%H-00.txt echo. > %%H-30.txt ) The FOR command could be shortened considerably but I left it like that on purpose so it illustrates the principle better. That's pretty useful to know, but I was asking about having the hours within each date named text file.start a file with >, then add to it with >> echo 00-00 > 7-1.txt echo 00-30 >> 7-1 txt [snip] echo 23-00 >> 7-1.txt echo 23-30 >> 7-1.txt echo 00-00 > 7-2.txt echo 00-30 >> 7-2 txt [snip] echo 23^:00 >> 7-2.txt echo 23^:30 >> 7-2.txt [etc] To fill in the blanks is a trivial exercise which I shall leave for you to complete... Such a batch would be 48 x 31 lines long... 1488 lines... but I expect you can think of a way around that... you can add the time programmatically...here's a vbscript Code: [Select]Dim myTime, objFSO, startTime,count,FilePrefix,objFile Set objFSO= CreateObject("Scripting.FileSystemObject") startTime="00:00:00" count=1 FilePrefix="7_" myTime=FormatDateTime(DateAdd("n",30,CDate(startTime)),vbShorttime) Set objFile = objFSO.CreateTextFile(FilePrefix&CStr(count)&".txt",True) objFile.Write(myTime) objFile.Close count=count+1 Do while myTime <> "00:00" myTime=FormatDateTime(DateAdd("n",30,CDate(myTime)),vbShorttime) Set objFile = objFSO.CreateTextFile(FilePrefix&CStr(count)&".txt",True) objFile.Write(myTime) objFile.Close count=count+1 Loop Thanks again for all the help. When using the FOR command, how would you set a range of numbers within the set, instead of listing them all out? What EXACTLY is and how exactly do I use a "vbscript"? I'll wiki it in the meantime. This is my new batch file, loopcal.bat: Code: [Select]color 02 for %%D in (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30) do ( echo. > 7-%%D.txt ) for %%H in (1 2 3 4 5 6 7 8 9 10 11 12) do ( echo %%H am >> 7-??.txt echo %%H pm >> 7-??.txt ) color 0a It'll create the files, but when it's supposed to print the hours in each one, it tells me: The filename, directory name, or volume label syntax is incorrect. Know where I messed up?Quote from: Computer_Hopeless on July 01, 2007, 09:37:31 AM When using the FOR command, how would you set a range of numbers within the set, instead of listing them all out? FOR /L %%parameter IN (start,step,end) DO command start : The first number step : The amount by which to increment the sequence end : The last number command : The command to carry out, including any command-line parameters. %%parameter : A replaceable parameter: in a batch file use %%G (on the command line %G) So (20,-5,10) would generate the sequence (20 15 10) (1,1,5) would generate the sequence 1 2 3 4 5 Quote What exactly is and how exactly do I use a "vbscript"? I'll wiki it in the meantime. Never use 'em. Scripts for Windows Scripting Host. (Wiki or Google that also) Quote This is my new batch file, loopcal.bat: 1. There are 31 days in the month of July. 2. You need to nest the loops, which is going to bring us to the topic of delayed variable expansion. 3. Those question marks in "echo %%H am >> 7-??.txt" are errors and will generate the message you saw. Can I just ask, forgive me if I am wrong, but is this your homework? If this is a homework project, I predict your teacher will know for sure you didn't write this, so you won't dare submit it, and if it's for your own amusement, I apologise for my nasty suspicions and invite you to pore over this and attempt to puzzle it out by visiting some of the batch tutorials and guides that are plentiful on the web. It's just that many many batch questions start off "I was just wondering [yeah, right!] how to do xyz in a batch file", and there follows a suspiciously detailed and arbitrary specification for some project which nobody would dream up for themselves in a month [28,30 or 31 days!] of Sundays (AM/PM, half hourly intervals, etc etc), which smells strongly of "a teacher wrote this". Forgive my suspicious mind if I have got it all wrong, and in that case please accept the following gift... This is a hacked-together quick and dirty batch file. It's not a definitive solution, it's just how I would choose to make a calendar in a batch. It could be extended to do a whole year, or any month as required, to know which months have 30 or 31 days, even to decide if February has 28 or 29 days that year. Code: [Select]@echo off setlocal enabledelayedexpansion REM With a number loop use the /L switch FOR /L %%A IN (1,1,31) DO ( set filename=7-%%A REM You insist on AM/PM which makes things trickier REM Days start at 12 AM or end at 12 PM??? REM Assume latter REM Pesky old fashioned AM/PM echo 12^:00 Midnight > !filename!.txt echo 12^:15 AM >> !filename!.txt echo 12^:30 AM >> !filename!.txt echo 12^:45 AM >> !filename!.txt echo. >> !filename!.txt FOR /L %%B IN (1,1,11) DO ( set /a hour=%%B REM make look neater with leading zeroes REM for hours 1 to 9 if !hour! LSS 10 set hour=0!hour! echo !hour!^:00 AM >> !filename!.txt echo !hour!^:15 AM >> !filename!.txt echo !hour!^:30 AM >> !filename!.txt echo !hour!^:45 AM >> !filename!.txt echo. >> !filename!.txt ) REM Pesky old fashioned AM/PM echo 12^:00 Noon >> !filename!.txt echo 12^:15 PM >> !filename!.txt echo 12^:30 PM >> !filename!.txt echo 12^:45 PM >> !filename!.txt echo. >> !filename!.txt FOR /L %%B IN (1,1,11) DO ( set /a hour=%%B if !hour! LSS 10 set hour=0!hour! echo !hour!^:00 PM >> !filename!.txt echo !hour!^:15 PM >> !filename!.txt echo !hour!^:30 PM >> !filename!.txt echo !hour!^:45 PM >> !filename!.txt echo. >> !filename!.txt ) ) Here's 7-23.txt Code: [Select]12:00 Midnight 12:15 AM 12:30 AM 12:45 AM 01:00 AM 01:15 AM 01:30 AM 01:45 AM 02:00 AM 02:15 AM 02:30 AM 02:45 AM 03:00 AM 03:15 AM 03:30 AM 03:45 AM 04:00 AM 04:15 AM 04:30 AM 04:45 AM 05:00 AM 05:15 AM 05:30 AM 05:45 AM 06:00 AM 06:15 AM 06:30 AM 06:45 AM 07:00 AM 07:15 AM 07:30 AM 07:45 AM 08:00 AM 08:15 AM 08:30 AM 08:45 AM 09:00 AM 09:15 AM 09:30 AM 09:45 AM 10:00 AM 10:15 AM 10:30 AM 10:45 AM 11:00 AM 11:15 AM 11:30 AM 11:45 AM 12:00 Noon 12:15 PM 12:30 PM 12:45 PM 01:00 PM 01:15 PM 01:30 PM 01:45 PM 02:00 PM 02:15 PM 02:30 PM 02:45 PM 03:00 PM 03:15 PM 03:30 PM 03:45 PM 04:00 PM 04:15 PM 04:30 PM 04:45 PM 05:00 PM 05:15 PM 05:30 PM 05:45 PM 06:00 PM 06:15 PM 06:30 PM 06:45 PM 07:00 PM 07:15 PM 07:30 PM 07:45 PM 08:00 PM 08:15 PM 08:30 PM 08:45 PM 09:00 PM 09:15 PM 09:30 PM 09:45 PM 10:00 PM 10:15 PM 10:30 PM 10:45 PM 11:00 PM 11:15 PM 11:30 PM 11:45 PM School has been out for a while, this is just for my own curiosity and amusement. Thank you again for the help. I'll mess around with what you've given me and get back to you in a while. This loop tool (the only loops I'd ever used before were on the school calculators) will be exceptionally useful in the future. Thanks. |
|
| 8593. |
Solve : GOTO :END IF MORE THAN ONE INSTANCE FOUND RUNNING..??? |
|
Answer» im COMPILING a batch file into a .EXE file with "quick batch file compiler" set /a n=0 Something like that would work but I don't have a bat2exe converter handy to test so the batch file just comes up as cmd.exe. this is what HAPPEND... Code: [Select] C:\Documents and Settings\VM-WARE>"C:\Documents and Settings\VM-WARE\Desktop\batch.exe" C:\Documents and Settings\VM-WARE>set /a n=0 C:\Documents and Settings\VM-WARE>set fn=batch.exe | was unexpected at this time. C:\Documents and Settings\VM-WARE>for /f "usebackq delims=" %I in (`tasklist | findstr /i /c:"batch. exe"`) do ( C:\Documents and Settings\VM-WARE> Quote set /a n=0 Try that, I added a '^'.Thanx DeltaSlaya it seems to work ok now.. But i have a small problem though. My app called BATCH.EXE opens in 4 instances of itself simultaneously at user logon which open 4 CMD windows, because i have BATCH.EXE set for startup in these 4 startup locations: { HK_LM , HK_CU , All Users StartUp Folder & Current Users StartUp Folder } so your code works somewhat, but it will read out: Code: [Select] if 4 equ 2 exitso i put in a few more lines like this Code: [Select]if %n% equ 2 exit if %n% equ 3 exit if %n% equ 4 exit so now all of the open cmd windows at user logon all close-exit because they all take the line: Code: [Select]if %n% equ 4 exit so now how is it possible to close all but one of them if all 4 are running simultaneously ..?? you have a design problem.Well I don't see why you need to start it from four places? Whats the point when you're going to close three anyway? The only way I see that you can do it, still won't be reliably is to have each one check at a different time, by pinging for a random amount of time... eg Quote ping -n %random~0,1% localhost >nul There would be other more complicated ways, and there's probably a simple way too. But I see this as an avoidable problem by not starting the program more than once in the first place...IS this code suppose to ping at a random number..?? because when i run it nothing seems to happen.. Code: [Select]ping -n %random~0,1% localhost >nul'>nul' suppresses the output so you won't experience anything apart from a hopefully random delay. You can make it further random by assigning a few random numbers to '-w %random:~0,2%'. For that to work you can't ping yourself, you have to ping a non-existent IP address. OR, to do away with all the randoms you could just ping a website and the programs may each have marginally different response times. Again, I'm sure this isn't the best way, there's probably another way thats 100% RELIABLE but I'd still like to know why you need to open it four times, it sounds, no offense, suspiciously like how a virus would like to open EDIT: Woops, I see why it wasn't working, I missed out the semi-colon... Quote ping -n %random:~0,1% localhost >nulHey thanx for all your help DeltaSlaya.. But it just doesn't really seem to be working out for me though, because at least 2 instances of the process always seem to ping at the same random number and then they both close together. so all instances of the process just wind up self terminating themselves.. the reason I use all 4 of those startup entires is just for fail-safe measures that I take to ensure that my File will always be ran at every users startup on my PC. So my next question would be: What other programing languages {that are fairly easy to learn} could I transfer my Batch-App into that would allow me to code it, so it can only be opened in one instance of itself. Fail-safe? Such a procedure would be more appropriately named 'fail-prone'... To add a startup registry entry simply create an entry in this key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run By saving the following as a *.reg file: Quote REGEDIT4 Something like that should work I don't really know how to write .reg files.Hey, is there anyway to make my app install & run as a System Service...?? then check to see if the service is installed ok, and if it can't install itself as a system service then have it register itself to startup at: HK_LM & HK_CUWhat do you mean make your app install? It's only a batch file converted into executable format. Again, I personally see no reason for making an application start at two different locations. To make it a service it's just Services instead of Run in the key I believe, not 100% sure. But why would you want it to run before the operating system starts? Yes you can check if the program is registered in the registry. 'REG QUERY /?' in a command prompt. |
|
| 8594. |
Solve : costomize pause message? |
|
Answer» I read on a really OLD webpage that there was a way to change the PAUSE MESSAGE but the LINK was broken. anyone know anything about it?yea .. |
|
| 8595. |
Solve : Shutdown dialog batch file? |
|
Answer» Is there a WAY (using a batch file or by command line) to display the Windows 98 shutdown dialog box? How do you use rundll.exe to display it? I think the shutdown dialog is located somewhere inside the shell32.dll. :-?Check out this page.... http://www.robvanderwoude.com/index.html |
|
| 8596. |
Solve : 134 disk error ????? when I ping Google DNS. I can't get my ADSL to work>? |
|
Answer» Hi. I have a new pc , new HDD and winxp. I cant GET my ADSL to work. Have treid all that the tech guys have been over. |
|
| 8597. |
Solve : Old 386 start issue? |
|
Answer» Noob here on the board, I tried a search on this with no luck. I have my old 386 that has been sitting in the garage for about 6 years. I would like to FIRE it up and retreive some old files. I think it has DOS 3.3. When I turn it on it PASSES the RAM check but runs into a XCMOS checksum failure. It asks for the boot disk to be installed in A:. I do not have the disk but one of the posts directs to a site where I can down load one. One of the problems is A: is a 5-1/4" and I have no way to write a disk in this size. B: is a standard 3-1/2" so I can make a new disk for that drive if I can get the PC to look there first. There is also some info missing about the hard drives in the table. Is there a way for me to get this running? Would the bios values be different if the drive was partitioned intoC:, D:?The type would remain the same regardless of partitioning. Quote I have another PC about 6 years old that is running Windows 95? would I be able to read the drive if I just plugged it in to it?If you set it as a slave and boot to 95 it might be able to read the drive. The newer bios might also auto detect the drive. Those were some days......... Unless I miss my guess, starting an HD with improper specs can lead to data damage, oops. I seem to remember that type 27 was put in your own specs, which should be able to be located on the Seagate website. [google the drive & some archive should has the correct heads, cylinders, pre-comp & what not] bios is VERY low level, so the answer there is NO, the bios allows initial access, fdisk specs the drive sizes...; format cleans it up & boot time can set the drive lettering. [well beyond this DISCUSSION] what I would do: 1] verify proper either type [for YOUR computer {mostly they were standard, but}] or specs [see above] 2] plug those puppies into the bios [having a boot disk may help a little {RESETTING A&B might work too}] 3] get you OLD files & yeah. setting this drive as a slave in a new computer might not really be a good idea. an OLD standard 'large' size was 30Mb, ANYthing larger had to have multiple partitions.It's alive! 27 didn't work but I was finally able to get the drive info from http://www.pc-disk.de/. 47 is the number to enter your own specs on this one. I wasn't able to get anywhere on the Mitsubishi site. It starts up the way it used to. It doesn't appear that I have done any damage to the data with improper drive specs. This was a big drive in its time and had to have 2 partitions to operate. I need to get some floppies so I can transfer the files off the drive and then I can burn them onto a CD. It'll take a handful of disks and then only make a small dent in the CD capacity. How times change. Thanks for all of the help! SteveGlad you are all fixed up and thanks for posting back. There's a reason they let us old farts on the forum. |
|
| 8598. |
Solve : how to make a new user in cmd?? |
|
Answer» title says it all really |
|
| 8599. |
Solve : scandisk? |
|
Answer» Hi, 1. No such thing as scandisk that I know of. Thanks a lot for the info Dark Blade... Quote from: Deerpark on September 02, 2007, 03:22:35 AM yes scandisk was the disk checking utility for the older Win9x based systems. Chkdsk is the scandisk equivalent on 2000/XP/Vista Got it!!! |
|
| 8600. |
Solve : CTRL + C in dos? |
|
Answer» can i use the ctrl+c commands in dos. can i use the ctrl+c commands in dos.and what do you want to do with it after its in the clipboard? if your purpose is to copy to "clipboard" and "paste" it somewhere, then the copy (or move) command is for you. if you just want to "manipulate" the file names in "clipboard" , then do it in batch...(or others)...otherwise, define what you will be doing once you have got them into the "clipboard".i need to copy sertain folders but the destination where they go is most of the time different, so i was thinking i could make a batch that would copy them and then i only need to paste them in the right folder.Quote from: Upham on August 31, 2007, 07:13:39 AM i need to copy sertain folders but the destination where they go is most of the time different, so i was thinking i could make a batch that would copy them and then i only need to paste them in the right folder.explain what causes the destination folders to be different every time and how? there are like 10 destinations, sometimes they need to go to destination 4 and an other time to destination 9 etc... just depends on the projectsorry. you are not specific enough. can't help you here.like im SAYING there are for example 10 different destinations, and where i need to paste just depends on what i am working on at that moment.Well you could always have the program running and have an entry type batch file such as: Code: [Select]@echo off :main set variable= set /p variable=Which location would you like to paste to: if %variable%==1 goto one if %variable%==2 goto two if %variable%==3 goto three if not %variable%==1 goto main if not %variable%==2 goto main if not %variable%==3 goto main :one copy "C:\File\To\Copy" "C:\Place\To\Be\Copied" :two copy "C:\File\To\Copy" "C:\Place\To\Be\Copied" :three copy "C:\File\To\Copy" "C:\Place\To\Be\Copied" I'm not sure if thats what your looking for or not though. |
|