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.
| 151. |
Solve : auto answer yes for uninstallation of winzip? |
|
Answer» Hi... i am looking for a way to automate the step of click the yes button when doing the uninstallation of winzip or any program.. thanks. QUOTE from: bh on JULY 01, 2010, 10:42:19 PM Hi... i am looking for a way to automate the step of click the yes button when doing the uninstallation of winzip or any program.. thanks. Sometimes an echo yes and pipe to the uninstall program will work. C:\TEST>echo YES | uninstall or C:\test>echo Y | uninstall |
|
| 152. |
Solve : Microsoft VBScript runtime error while running it from batch exe file? |
|
Answer» I have CREATED a batch script .EXE file, |
|
| 153. |
Solve : MS DOS booted from Hard drive does not execute any .exe file even from outside? |
|
Answer» I am a 68-years old Neurosurgeon - a die-hard-fan-*censored*-avid-user(for over THREE decades) of MS DOS 6.22 with QBasic1.0, Foxpro for DOS 2.5 |
|
| 154. |
Solve : Wage batch file, help?? |
|
Answer» echo off remove your echo off and run it again. You will spot your mistake easilyAHEM, you didn't set a variable name with the set /a commands. Quote from: Helpmeh on April 15, 2010, 08:23:42 PM AHEM, you didn't set a variable name with the set /a commands.are you REPLYING to me or the OP ? Quote If you use any of the logical or modulus operators, you will need toAlso, the % is used as an operator. So use of the % when using SET /A will generate an ERROR if there is no operand to go with it. Or to put it simply, take out those % things unless you really want them. Quote from: ghostdog74 on April 15, 2010, 09:05:09 PM are you replying to me or the OP ?OP. Quote from: ghostdog74 on April 15, 2010, 05:52:27 PM remove your echo off and run it again. You will spot your mistake easily was fixed here, sorry lost the url for the post. thank you everyone =] |
|
| 155. |
Solve : need to replace strings from file? |
|
Answer» Hi HiCode: [Select]c:\> sed "s/[ \t.]/_/g" textfile Quote 2. Also I need to be replace the string from a file to another string for eg (computer replace to hope)Code: [Select]c:\> sed "s/computer/hope/g" textfile Quote 3. There are 3 strings in a text file sepereted with , need to display the same on the command promptShow samples of your text file next time, and explain clearly what your final output is. Thanks but I would appreciate if it can be done using DOS command. pls helpThis question has been asked and answered many times on the forum. You may have overlooked searching the forum before posting your question. Also if you run set /? from the command prompt, the online HELP should be of immense help. Showing some initiative trumps waiting for a response every time. |
|
| 156. |
Solve : Renaming a file with yesterday's date.? |
|
Answer» Hi folks, I need a little bit of help. I have a file that I need to rename with YESTERDAYS date in the filename. I will be running this script on a Windows Server 2008 machine. C:\batch files>echo ren "timeclock.csv" "7-11-10 timeclock.csv" Any thoughts?See my post. Quote Remove echo when happy. That is, the batch script, as posted, just shows (echos) the command on screen and does not make any changes to files. When you have run it and you are happy with what you see, change "echo ren" to "ren" and save the script. You do realise that commenting out echo off like this -- ::echo off -- means that every line is shown on the screen? And that you don't have to have this if you don't need it? Ah there we go, thanks very much. I totally gapped and missed the echo in front of the ren statement, that is all. Yeah I know that commenting out the echo shows everything, I was going to remove that once everything was working correctly. Thanks again, you have no idea how much headache you've saved me. |
|
| 157. |
Solve : Identify file date? |
|
Answer» Assume the following: location-1 creates a database update file and creates a zip file. Location-2 receives the zip file and will download it only if they do not already have that file. I would like to modify the download batch file to at least identify the date/time of the file and display in on screen with a MESSAGE that says 'this file was created on ____ at ____. If you have this update already, press ESC to abort. |
|
| 158. |
Solve : auto increment for filename and file content? |
|
Answer» how to append a new line into texts? |
|
| 159. |
Solve : Start was unexpected at this time? |
|
Answer» Hey I was making a smiple script to install some stuff, but I GOT the error |
|
| 160. |
Solve : Time management? |
|
Answer» Hi Folks. |
|
| 161. |
Solve : files listed added to folder during last week? |
|
Answer» Hi All |
|
| 162. |
Solve : Hide ping? |
|
Answer» I want to HIDE |
|
| 163. |
Solve : how to extract version of perl while using batch file? |
|
Answer» Dear experts.. based on different versions of Perl, how do I extract the version number (e.g. 5.10 or 5.12) in the examples below The following snippet should help you out. I'm a bit confused. Do you have two versions of Perl installed or do you just WANT the version of Perl that is installed? Code: [Select]echo off setlocal for /f "tokens=4" %%i in ('perl -v ^| find /i "This is perl, "') do ( if not errorlevel 1 echo %%i ) for /f "tokens=9 delims=()" %%i in ('perl -v ^| find /i "This is perl 5, "') do ( if not errorlevel 1 echo %%i ) Good luck and welcome to the forum Thanks so much for your response.. Different machines have different versions of perl installed and I want to extract the version # using a MSDOS batch script. The POSITION of version number seems to change with the text as seen from the provided examples. However, v5.XX.XX seems to be the only relevant string of characters that have, so far, remained consistent across versions. So, is there a way to extract "vX.XX.XX"? Thanks again, Naradi Quote from: naradi on July 15, 2010, 12:38:54 PM However, v5.XX.XX seems to be the only relevant string of characters that have, so far, remained consistent across versions. So, is there a way to extract "vX.XX.XX"? Did the code not work properly? I only have Perl 5.10.0 installed on my machine so I could not test version 5.12.1. If there is an error with the script please post your output. I may have miscounted the tokens. I made one SMALL change to display the "v" with the 5.12.1 version. Code: [Select]echo off setlocal for /f "tokens=4" %%i in ('perl -v ^| find /i "This is perl, "') do ( if not errorlevel 1 echo %%i ) for /f "tokens=9 delims=()" %%i in ('perl -v ^| find /i "This is perl 5, "') do ( if not errorlevel 1 echo v%%i ) OP, since you are using Perl, then use Perl. It has more powerful text processing capabilities than batch Code: [Select]C:\test>perl -version | perl -ne "print if s/(.*[(,][ \t])(v\d+\.\d+\.\d+).*/\2/" v5.10.1 |
|
| 164. |
Solve : date log? |
|
Answer» Hi guys! |
|
| 165. |
Solve : Batch file command to read the sentence at run time? |
|
Answer» Hi, |
|
| 166. |
Solve : Automatic Deletion of Files With Spreadsheet? |
|
Answer» Hello, I am trying to make my life easier at the moment, I have multiple hard-drives and computers containing lots and lots of image files. I have also created an excel spreadsheet with all of these images' information (such as image #, date the image was acquired, type of camera used etc...). However after the images are processed there are many that need to be rejected, these rejected images are manually noted in the Spreadsheet. However I am now looking to create a batch file (or any other possible solution) that looks at the excel spreadsheet, finds out which items are rejected, and then deletes these items from their respective windows folder. Is this possible? yes, it is possible, the whizzy answer would be to have a vba macro that goes out and deletes the files for you This assumes that rows 1 to 4 of column A in Sheet 1 contain path and filenames e.g. Code: [Select]T:\tempvu\Test-2-01.qry T:\tempvu\Test-2-02.qry T:\tempvu\Test-2-03.qry T:\tempvu\Test-2-04.qry You can delete the Rem and MsgBox lines when you are happy that it runs OK Code: [Select]Sub delfile() Sheets("SHEET1").Select Col = "A" StartRow = 1 MAXROW = 4 For Row = StartRow To MaxRow Range(Col & Row).Select MsgBox (Selection.Value) Rem Kill (Selection.Value) Next End Sub Thank you Salmon Trout that does work however there is still something I need help with. On my original post I was a bit unclear on the information that is contained in the Excel Spreadsheet. Since these files are moving to different locations/harddrives very often, their file path/name is not contained in the spreadsheet. What is contained is a different number for each image called its "exposure #". So under the "Exp" column I have a list of all of these various numbers. Similarly, the files themselves, which are in .tif format, also have that same number in their filename. Except for they also have other unassociated numbers in their filename. For example for exposure # 57, the filename would be something like "ABC2JL4_04007_00057_RGB.tif" where the 00057 is the exposure number. So now what would be awesome is if Excel could take the number from the Exp column, and use it to locate its associated .tif file(after say I specified a directory somehow), and then I could just delete that file using the code that you suggested. Am very appreciative of any willing to help!!! Quote from: Salmon Trout on July 14, 2010, 11:13:50 AM
That was carelessly written. Correction: You can uncomment the Kill line and comment out the MsgBox line when you are happy that it runs OK |
|
| 167. |
Solve : creating multiple instances of folders in a directory? |
|
Answer» I am tasked with reorganizing an academic server. I have recently realized that there needs to be another folder in each of the course folders. I don't want to go into EVERY single course folder and create a new folder using the regular windows explorer windows. is there a way to do this repetetive task in the command prompt? Thanks.yes, check out the FOR command - for /? will give help perhaps I should have given an example, so try this Sorry for my ignorance, but I'm relatively inexperienced with the command prompt. That being said, I READ the description of FOR /D and your example of code looks like the (*.*) is telling it to search in a set of files. Let me give you an example directory: │ ├───NE300 │ │ └───AY11-1 │ │ ├───ADDITIONAL Resources │ │ ├───Admin Files │ │ ├───Homework Files │ │ ├───Instructor Files │ │ ├───Lab Files │ │ ├───Lesson Files │ │ ├───Submissions │ │ └───Writs and WPRs There are about 40 more of these course directories (NE300 is a course) and I want to add a folder called JSmith in all of the existing "Instructor Files" folders. Please let me know where I am making my mistake in understanding the code you gave me. Thanks. No, you are right - sort of. Directories can be treated as files, in as much as they have a name that can be filtered by *.*, or whatever. Suppose your master directory is called courses, inside are all of the course folders NE300 NE310 NE320 NE340 etc and within each course there is an AY11-1 folder and inside that there is an Instructor Files directory This is quite easy, make Courses the current directory and execute the following to make JSmith in each Code: [Select]for /D %a in (*.*) do md "%%a\AY11-1\Instructor Files\JSmith" However, I suspect that the actual name of the AY11-1 directory is different in each course; if it is the top level (ie the only one as you seem to indicate in your tree) within the individual course directory - like this Courses ¦ +---NE300 ¦ ¦ +---AY11-1 ¦ ¦ +---Additional Resources ¦ ¦ +---Admin Files ¦ ¦ +---Homework Files ¦ ¦ +---Instructor Files ¦ ¦ +---Lab Files ¦ ¦ +---Lesson Files ¦ ¦ +---Submissions ¦ ¦ +---Writs and WPRs ¦ +---NE310 ¦ ¦ +---AY11-2 ¦ ¦ +---Additional Resources ¦ ¦ +---Admin Files ¦ ¦ +---Homework Files ¦ ¦ +---Instructor Files ¦ ¦ +---Lab Files ¦ ¦ +---Lesson Files ¦ ¦ +---Submissions ¦ ¦ +---Writs and WPRs ¦ +---NE320 ¦ ¦ +---AY11-3 ¦ ¦ +---Additional Resources ¦ ¦ +---Admin Files ¦ ¦ +---Homework Files ¦ ¦ +---Instructor Files ¦ ¦ +---Lab Files ¦ ¦ +---Lesson Files ¦ ¦ +---Submissions ¦ ¦ +---Writs and WPRs ¦ +---NE330 ¦ ¦ +---AY11-4 ¦ ¦ +---Additional Resources ¦ ¦ +---Admin Files ¦ ¦ +---Homework Files ¦ ¦ +---Instructor Files ¦ ¦ +---Lab Files ¦ ¦ +---Lesson Files ¦ ¦ +---Submissions ¦ ¦ +---Writs and WPRs then a nested loop will be needed to identify the relevant PATH to the Instructor Files. Im sure that one of my esteemed colleagues will be able to show a wonderful bracket example, here is my offering using a subroutine call -- blimey it seemed to work first time ! Code: [Select]for /D %%a in (*.*) do Call :ProcFolder "%%a" GoTo :EOF :ProcFolder for /D %%b in ("%1\*.*") do md "%%b\Instructor Files\JSmith" |
|
| 168. |
Solve : Help w/batch merging files? |
|
Answer» Hello, As a test, I combined 3 files (1 record each) into 1 and then removed the blank lines How did you "combine" the files, which software did you use? Please post a screenshot of a hex editor output of test1.txt and test.txtHi, I don't use any software to combine the file, I just use the copy command because I want everything to run in batch: copy *.txt test1.txt /b Here is where test1.txt contains blanks so I run the clean batch to remove the blanks and create the test.txt file. I am not sure if this is what you're ASKING for, but here they are [recovering disk space - old attachment deleted by admin]Suggest you do the lot in one script as below. This should READ your three test files and write them to output omitting blank lines, after testing you can change the inputs/output filenames to whatever you want: Code: [Select]echo off cls for /f "tokens=*" %%1 in (inputfile1.txt inputfile2.txt inputfile3.txt) do ( echo %%1>>outputfile.txt ) |
|
| 169. |
Solve : Cancel Exit Application? |
|
Answer» Hi |
|
| 170. |
Solve : Is One Second too quick for "SHUTDOWN -s -t 1"? |
|
Answer» To shutdown the P.C. I launch a script to run various things that tidy up and remove junk, Is it just as safe to use a 1 Second countdown ? Why wait at all? I customarily shut down using a batch file; I have the delay set to 0. I have been doing this for 6 years in XP, Vista and Windows 7. Windows won't trip the power until it is safe to do so. Quote from: ALAN_BR Is there something important that may take 10 Seconds to complete in the background ? The delay chosen by shutdown -s -t N is number of seconds before Windows commences the shutdown procedure. Nothing happens during that time, other than the display of a message to the user. You might as well skip it altogether if you know you want to shut down and you don't need to save any data. Thank you. I thought one second should be legitimate, but have often come to grief when I attempt a value of zero where the code only expects 1 to 255. Zero Seconds it is then. I am sure that when I launch my script there "should" be nothing that needs to be saved. If I reconsider during the script I can immediately close and abort the script. I just do not see how a final 10 second countdown would allow me to see that a file needed closing, or to tell an application to close its files - and even if I could see, am I not logged out with zero authority once the countdown has started ? I have never managed to close down/abort the countdown, even the top right close button does nothing. For many years Windows 98 would give me, every day, a random selection of BSOD Lost Clusters Reprimand for not closing down windows properly Continuous never ending idle when I told it to shutdown, and I had to pull the plug when the janitor came to lock up the office. I have not learnt respect for Windows, but I have learnt to be wary of the grief and misery it imposes without warning ! ! ! I am not a trail blazer, but am happy to follow in your footsteps. Thank you Regards Alan Quote from: ALAN_BR on July 17, 2010, 11:34:44 AM am I not logged out with zero authority once the countdown has started ? Quite the reverse. If you open a command prompt, and type shutdown /? (This is quite safe, as is just typing shutdown on its own, which has the same effect) you will see all the options available. One of these is shutdown /a (a is for abort) which immediately terminates any pending shutdown. The help states that the /a switch is only usable during the "time-out period", in this context this is the number of seconds which were specified at the command prompt or in a script with the -t option. Note that in the Windows 2000 and XP help the options are preceded by a dash, (e.g. shutdown -s -t 10) whereas in Vista, Windows 7 etc a slash is used (shutdown /s /t 10) but in fact you can use either format. Try this - open two command prompt windows and position them side-by-side. In one, type shutdown /s -t with some suitably large number e.g. 300 (five minutes). Observe the information box that appears. In the other command window, type shutdown /a and see what happens. I imagine a reason for having a short delay might when you are pretty sure the user will be looking at the screen (e.g. it is you) and you just want to assure them or yourself that the shutdown (or shutdown and restart) is actually going to happen, and a longer one might be where you want to give the user plenty of time to save any work that might be in progress. Remember that shutdowns can be triggered remotely over a network by a system admin, who might for example give everybody an hour to get everything saved and log out. As the help makes clear, the options include the ability to include "reasons for shutdown" information. .I am sorry that I doubted the "help" from "SHUTDOWN /?" and also your own advice. My previous experience was that I had zero control once the countdown commenced. I find that the top right corner still does not close the countdown, but I now have the ability to launch CMD.EXE and abort the shutdown, which was not possible last year. Most system changes I put down to a Patch Tuesday update, but I think on this occasion it is what I did before SHUTDOWN. To close down I simply double click a desktop icon (visible because all tasks are CLOSED). This icon launched a tidy-up script which concluded by running CCleaner /AUTO /SHUTDOWN That purged temporary and unwanted files automatically without interaction, and then shut down the computer - 95 times out of 100. There must have been a race hazard somewhere, and on the failure occasions :- Task MANAGER showed that about 5 normal process.exe were missing ; and repeating the launch of the tidy-up script never succeeded, some service or process *.exe was no longer available to support CCleaner. I then created a pure SHUTDOWN script with the single command SHUTDOWN -s -t 10 I then found that whenever "CCleaner /AUTO /SHUTDOWN" failed my new shutdown script would always shut down. I decided that the pop-up screen was totally wrong because :- 1. The top right corner "X" fails to close that window / application as it should, 2. There was no way I could do anything to save the documents as it suggested. I now realise that criticism 2 is only true if CCleaner has caused 5 services to stop. Those 5 services did not seem to be REQUIRED for me to view files and launch task manager etc etc., and "SHUTDOWN -s -t 10" would still operate. I now deduce that whilst Windows is closing down because "SHUTDOWN -s -t 10" told it to do so, some further bits of Windows were closed, and it is probably the loss of these bits in addition to the loss of 5 services which has destroyed all my interactive control My new tidy-up script no longer gives CCleaner the /SHUTDOWN argument, and concludes with the new line SHUTDOWN -s -t 1 I like about 1 second to see it go, and I have never yet thought within 10 seconds of something I forgot to save ! ! Regards Alan I am not convinced that programs like CCcleaner are a good idea. Many people think that gee-whiz "registry cleaners" do more harm than good, that they sometimes cause more problems than they prevent. I do not oppose that view. For my /AUTO mode I use a very light profile that only zaps stuff that I know is not needed, and all the flash cookies that always arrive, and all the Firefox caches in the User profile. This gives me the benefit that my daughters music and video downloads that filled her caches are erased when she shuts down, leaving more free disc space for me (and vice versa). I have a more serious manual mode which is more stringent, but I always scrutinise the analysis and use Google to investigate anything that CCleaner has not previously offered to purge, and only commit to a clean after un-checking any items I have doubts about. The registry was the dreaded end. I only had a cautious cleanse (with backups) before un-installing something, and after un-installing when CCLeaner told me of things that had been left behind when something was removed, I believed it and let it purge them. In my view registry cleaning is no longer the worst bogeyman. There are new kid's in the block :- Secure multi-pass erase ; and even worse Wipe Free Space. I find it incredible that new users of CCleaner are so eager for a new experience they go for maximum effect, and check all the boxes which for safety are NOT checked on a fresh install. They even believe that Wipe Free Space will somehow make more free space available for them to use - and then after the disc has been chundering away for a few hours they abort to see what has been happening and find the entire free space has been lost. Eventually they find the CCleaner forum and users explain what a bad idea it is and point them to documentation, and explain that the free space was overwritten with a monster file that would have been deleted had they allowed CCleaner to finish its work. You just have to cry - or laugh - take your choice ! ! Having said all that, I trust CCleaner as being much safer than many of the expensive cleaners that the naive grab as today's giveaway on GAOTD and similar sites. Regards Alan |
|
| 171. |
Solve : Run a batch file across the network? |
|
Answer» Can anyone give info about RUNNING a batch file across a network? Is it possible? |
|
| 172. |
Solve : Q AND A? |
|
Answer» IQ test...... IQ test......you can use a file processing tool, such as sed for windows. Code: [Select]C:\test>sed "s/Line number two/Line two/" file echo off msg * Line number one loaded! msg * Line two loaded! msg * Line number three loaded! msg * Ending program! Quote Question 2you are not solving the root of the problem. Use a virus scanner to remove the worm, or do it manually such as REGISTRY and system32. Then make an effort to always update your virus signatures, and discipline yourself not to run unknown executables anyhow. Quote Question 3again, if you have downloaded sed Code: [Select]C:\test>sed -n "3s/^score //p" score.txt 85 Quote Question 4If it says its not empty, then go empty them...or you can "force" deletion using switches from some of the delete commands eg del, deltree..etc... Quote ONE QUESTION RIGHT GET 25 MARKS. I WILL BE APPRECIATED IF ANYONE GOT MOST OF THE QUESTION RIGHT.next time, try to research a bit on the internet as well.. Quote from: ghostdog74 on July 18, 2010, 07:56:43 PM you can use a file processing tool, such as sed for windows.Can you give me a script that don't need to download "sed"? Because machine without "sed" will not be able to run the program.progmer, why did you choose such an irritating way of asking your questions? It is bound to limit the help that you get. |
|
| 173. |
Solve : how to record user input and cmd output? |
|
Answer» export them to another FILE or other easier method? |
|
| 174. |
Solve : Net use for a local network connected drive? |
|
Answer» Hi, |
|
| 175. |
Solve : Old computer has HHD earased and want to load now for CAD? |
|
Answer» I have an old computer with 2 HHD's- 1- is small and overloads quickly the other is large- together they can handle WIN98- XP loads but bottoms out with a code 14 |
|
| 176. |
Solve : config.sys in what ditectory is found? |
|
Answer» on a PC running ms-dos or windows 98 the file Config.sys where WOULD this file be placed. in what DIRECTORY In the ROOT directory of C:THANKS |
|
| 177. |
Solve : COPY A FILE TO DESKTOP (XP)? |
|
Answer» hi everyone! |
|
| 178. |
Solve : Need to get advance summary from a jpg? |
|
Answer» Hey guys, |
|
| 179. |
Solve : How to set a time limit for program execution? |
|
Answer» I want to set a time limit of 100 seconds for executing a Java program. I want the Solver program to exit if it has not solved the puzzle within 100 seconds.my solution works the ping can be replaced by sleep.exe (optional download) Quote from: hels on July 22, 2010, 01:22:25 AM (1) The ping command cannot be used to achieve a specific delay. The -n option specifies the number of echo requests to send, and the -w option specifies the timeout in milliseconds to wait for each reply. Thus, there is no guarantee that the time to execute the ping is n*w milliseconds. It can take shorter or longer time. IF you ping a non-existent address then it will always take the maximum timeout. I'm pretty sure that it won't work with localhost. Quote (2) The ERRORLEVEL associated with the Java program execution is not tested. he isn't using the errorlevel of java.exe. he's using the errorlevel of tasklist. |
|
| 180. |
Solve : DIR of remote machine - RunAs?? |
|
Answer» Hi everyone: |
|
| 181. |
Solve : I can get my batch file to run when I run the batch file using devcon.exe? |
|
Answer» But, When I use C# to run a form and try running file below it doesn't work. Even though I have devcon.exe in the same folder as the batch file. If I run it by itself it works. |
|
| 182. |
Solve : Dos Search & Replace STR? |
|
Answer» I would like to search a txt file and replace string with another! need help! |
|
| 183. |
Solve : Copy file from different folder!? |
|
Answer» Hello folks i would like to copy a file from a distant folder like C:\Documents and Settings\Administrator, file being any EXE to Desktop. I would like to run this bat file from desktop itself. can some make a Bat file for this purpose. I have already made it,but it require me to put this bat in the Administrator folder and assigned d: for the file to be saved. Not important! Thank u:Nor clear WANT you want. Some Windows EXE files must be run in their own folders. You can always send it to the Desktop as a Shortcut, but you don't need a batch file to do that.i do not want to cut or move the exe files from their default location: i just want to make a backup of these files, i could just graze the mouse pointer to the files to achieve this , but i want only selective files ,and doesn't making a bat file serve this purpose,,,,i would know the file and what i want copied. If someone has understood my view, could anyone suggest something. MANY thanks:Not really sure what you are doing, but this will copy all the exe files from the administrator folder to the administrator desktop folder. Code: [Select]echo off copy "C:\Documents and Settings\Administrator\*.exe" "C:\Documents and Settings\Administrator\Desktop Save the batch script anywhere on your system, then create a shortcut on the desktop that points back to where you saved the script. Good luck. That bat worked, i just wanted to copy one exe file: will be using this method to other folders as WELL. Its me, and my way of doing things, it saves me a lot of time. I would like to ask few questions:
Thank you for your suggestion. Quote You used double " "for the source folder ( at the beginning and at the end ), but single " for the destination: Is their some meaning behind this. You're being too kind. There is no sinister meaning, simply a typo on my part. I'm surprised it worked. Quote i just wanted to copy one exe file: will be using this method to other folders as well Code: [Select]echo off copy "C:\Documents and Settings\Administrator\oldfilename" "C:\Documents and Settings\Administrator\Desktop\newfilename" oldfilename - is the filename in the administrator folder (filename.exe). newfilename - is the filename in the desktop folder (test.exe). The rename of the file will occur during the copy operation. You can add as many copy statements as you need to the batch file. Be careful not to duplicate any newfilenames. Good luck. The quotes are required because the path names (documents and settings) of both the source and target directories contain embedded spaces.Thanks for replying: even with a typo ,the batch worked. Code: [Select]echo off copy "C:\Documents and Settings\Administrator\oldfilename" "C:\Documents and Settings\Administrator\Desktop\newfilename" The renaming worked too: thank you for your time. Although i had to change something to serve my purpose. Like moving to desktop, but i am happy... Thank you: Would you like a Floppy Disc Robot to help you? http://www.rogerarrick.com/diskrobot/Would you like a Floppy Disc Robot to help you? yes Code: [Select]Would you like a Floppy Disc Robot to help you? Thanks for the offer, but i really don't need a MACHINE to insert/remove a Floppy Disk. But i strongly believe their is always a place for new things in the market, Rogerarrick may be an innovator but with all honestly i don't see its use here. imo 1 out of 100 people could use it. Sorry I'll pass, Marlyane seems interested. |
|
| 184. |
Solve : Setting user permissions on a directory? |
|
Answer» First let me say hi to you all since I just registered and this is my first post. Thanks for your reply! What you NEED, is to change the Access Control List. It doesn't actually change any attributes, but it's an important part of a multi-user network setup. the "cacls" utility is included in XP Pro (if I remember correctly): cacls /T /G username: REPLACE the folder and username with your values of course; is one of R(read),W(write),C(change), or F(Full Control). Quote from: BC_Programmer on July 16, 2010, 05:06:55 AM What you need, is to change the Access Control List. Thanks a bunch, this actually works! This however, brought up another issue that I need to deal with now, which is the following: I have a batch file that does the following: set /P username=Enter a username: mkdir [fileserver]\userdirectories\%username% echo Y|cacls [fileserver]\userdirectories\%username% /T /G [domain]\administrators:F echo Y|cacls [fileserver]\userdirectories\%username% /T /G [domain]\%username%:F <---Which I needed the COMMAND I requested for in the first place When I run the batch file, the directory is created as it should, and the administrators (and other "hard" usernames (such as domaincontrollers, and basically everything that isnt derived from a variable like %username% is permitted to do whatever I gave permissions for. Except, when the batch reaches the point where it needs to give [domain]\%username% permissions, I seem to get an error that says: "No mapping between account names and security IDs was done". I am oblivious of what this means Thanks for your time though, you have helped me great so far!I think I have got it!!! In my original file, I tried to set permissions on a directory on a one-user-per-command kind of base. So... echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\administrator:F echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\my-admin-account;F echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\domaincontrollers:F echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\%username%:F BUT because cacls always overwrites previously set permissions when you declare new ones, everytime I set a new permission, it would wipe the old ones. This means, that when the command line finally got to the "Give %username% permissions on this map", it would REMOVE my own permissions, thus making me unable to actually GIVE permission on that folder for someone else, seeing as I didn't have any permissions of my OWN anymore. So now, I tried to do this: echo Y|cacls [domain]\userdirectories\%username% /T /G [domain]\account1:F [domain]\account2:f [domain]\account3:F.... and so on and so on in ONE command line. This actually does the job! I owe you much, thanks for your help!! |
|
| 185. |
Solve : need batch file to create files and insert date from an input file...? |
|
Answer» Well, I thought I was better at this than I am and I've got a problem I need some help with. I thought this would be simple, but at least right now, apparently I'm brain dead... |
|
| 186. |
Solve : Echoing variables into text documents? |
|
Answer» For some reason, when I run any code along these lines: Ohh, thank you Salmon. I completely understand now. (1) command prompt Code: [Select]S:\>>test.txt echo Rasputin S:\>type test.txt Rasputin S:\> (2) batch file Code: [Select]echo off >test.txt echo Rasputin test.txt... Code: [Select]Rasputin Hmm.. It is working, I must have been doing something wrong. Anyways, thanks again for all your help. |
|
| 187. |
Solve : How can "Macros" be recorded and executed in DOS?? |
|
Answer» I have a work process that requires some functions to be executed in a DOS* like environment. The character SETS that have to be entered are long and fairly complicated. It's not difficult to enter them incorrectly. I would like to be able to record and store these complex commands as pre-programmed keys or "macros". Obviously the idea is to make the process simpler and less time consuming through improved input-speed and accuracy. A macro is a series of scripted actions that is "played" upon demand. The most common activity of a macro is to send simulated keystrokes and mouse clicks to one or more windows. Such windows respond to each keystroke and mouse click as though you had performed it manually, which ALLOWS repetitive tasks to be automated with high speed and reliability. here I've started you off http://www.google.com/search?&q=autohotkey+keyboard+macros |
|
| 188. |
Solve : batch for a multiple print job.? |
|
Answer» I know almost nothing about creating batch files. what happens if he wants to print rtf files or only certain files in a folder Change: dir /b *.txt | sort > alltext.txt to dir /b *.* | sort > alltext.txt or dir /b *.rtf | sort > alltext.txt or dir /b *.%1 | sort > alltext.txt After combining what I learned from your code snippets and http://ss64.com/nt/ I've come up with the following. The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove that as I don't want to print it and it's deleted after the FOR /F command processes. It's not so bad as it will print a list of things in the order they're supposed to be in and that might be useful for my application, but it's still superfluous and I'm a minimalist. also this doesn't require dragging and dropping. but it does require the batch to be given a hidden attribute Code: [Select]ECHO OFF ECHO Creating Directory Listing dir /a:-h /b /-p /o:EN >"list.txt" ECHO Processing Directory Listing FOR /F %%i IN ("list.txt") DO ( REM %%i notepad /p %%i ) ECHO Deleting Directory Listing del "list.txt" ECHO Process Complete. Press a key to exit. PAUSE Now, I don't have an ACTUAL printer to test this on. Only the windows XPS writer. Quote from: marylane on July 27, 2010, 04:04:37 PM Change: +1 fantastic. thanks a lot for the help. Quote from: ErusPrime on July 27, 2010, 04:18:27 PM The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove? findstr /V "list.txt" list.txt > list2.txt copy list2.txt list.txt del list2.txt For example: C:\test>type erus.bat Code: [Select]echo off echo Creating Directory Listing rem dir /a:-h /b /-p /o:EN >"list.txt" dir /b l*.txt > list.txt dir /b n*.txt >> list.txt findstr /v "list.txt" list.txt > list2.txt type list2.txt pause copy list2.txt list.txt del list2.txt echo type list.txt type list.txt pause ECHO Processing Directory Listing For /F %%i in (list.txt) do ( echo %%i rem notepad /p %%i ) ECHO Deleting Directory Listing rem del "list.txt" ECHO Process Complete. Press a key to exit. PAUSE Output: C:\test>erus.bat Creating Directory Listing log.txt nc.txt new.txt NextFile.txt notepid.txt num.txt Press any key to continue . . . 1 file(s) copied. type list.txt log.txt nc.txt new.txt NextFile.txt notepid.txt num.txt Press any key to continue . . . Processing Directory Listing log.txt nc.txt new.txt NextFile.txt notepid.txt num.txt Deleting Directory Listing Process Complete. Press a key to exit. Press any key to continue . . . C:\test>okay. I think that makes sense. I need all the files though and not just l*.txt and n*.txt are the pauses absolutely necessary? sometimes the list is going to be more than 100 lines long. or is that just a "look how it works" kinda thing? Quote from: ErusPrime on July 27, 2010, 07:16:16 PM okay. I think that makes sense. The pauses are not necessary. It was used while testing. I noticed your code got all files and also all directories. How do you print a directory with notepad? Also *.exe files will not print with notepad. I have never used may of the dir options in your batch file so I'm not sure what files you are after. I thought you were only after *.txt files? I'm not sure what this line does: dir /a:-h /b /-p /o:EN >"list.txt" It appears you get more files than needed? Good luck |
|
| 189. |
Solve : copy/xcopy subdirectory???? |
|
Answer» hello there! |
|
| 190. |
Solve : Adding some words end of multiple files? |
|
Answer» HI, i want to rename multiple rar FILES by adding some words at end of filename. ABC.rar > ABC-sheeper.rar 123.rar > 123-sheeper.rar qwe.rar > qwe-sheeper.rar how can i do it by ONE bat file, i want to say rename all rar files to original names plus -sheeper for example. Thank you for help!In a BATCH script: Code: [Select]for %%A in (*.rar) do ren %%~dpnxA %%~nA-sheeper%%~xA At the prompt: Code: [Select]for %A in (*.rar) do ren %~dpnxA %~nA-sheeper%~xA |
|
| 191. |
Solve : Prevent exclamation marks from going away? |
|
Answer» What I am trying to do is use a FOR loop to send the contents of one batch file (STARTING at the 37 line) into another. To do this, I use this code: you can use more I noticed that the help for more says Code: [Select] +n Start displaying the first file at line n in fact more +n skips n lines, and starts displaying the file at line n+1. Code: [Select]del testfile.txt & for /L %%N in (1,1,40) do echo This is line %%N>>testfile.txt echo (1) FOR /f "skip=36" for /f "skip=36 delims=" %%Z in (testfile.txt) do echo %%Z echo (2) more +36 more +36 testfile.txt Code: [Select](1) FOR /f "skip=36" This is line 37 This is line 38 This is line 39 This is line 40 (2) more +36 This is line 37 This is line 38 This is line 39 This is line 40 |
|
| 192. |
Solve : Extracting the date of a file into an excel file? |
|
Answer» Hi All, |
|
| 193. |
Solve : 3 Dos floppy file configuration? |
|
Answer» I wonder if anyone can HELP me. |
|
| 194. |
Solve : shedule time for copy/transfer folders job? |
|
Answer» i want to copy 8 huge folders to external hardisk, but i want to do this one folder each time at schedule time, because those files may ACCESS by others during office hour. Rem date is a command and should be used a variable name %date% is already used as a system variable name, Bill, so it should not be modified or altered. date is a command and should not be used as a variable name. Quote from: only_lonely on July 25, 2010, 01:18:15 AM i got this code to create data folder but somehow it doesn't work perfectlydate is a command and should not be used as a variable name.C:\>date /t Mon 07/26/2010 C:\>echo %DATE% Mon 07/26/2010 C:\>date The current date is: Mon 07/26/2010 Enter the new date: (mm-dd-yy) C:\> Quote from: marylane on July 26, 2010, 09:13:25 AM Yes, and your point is, Bill?The original poster( only_lonely ) used the command "date" as a personal variable: echo off SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%" Good job editing your post bill! Quote from: marylane on July 26, 2010, 09:24:40 AM The original poster( only_lonely ) used the command "date" as a personal variable: Bill, this may or may not be a bad IDEA, as thereafter in that session, (and only in that session) the system variable %date%, which is provided for the user's convenience, will be different from the default (as set in Regional Options in Control Panel). As I say, it may or may not be a bad thing. The sky won't fall, however, Bill. Like I said, only in that session... The following (reply 1 above ) is from the original poster, only_lonely. The name given to the file was not the goal. Using a command, "date" as a personal variable does not work. type ol726.bat echo off SET date="%date:~6,4%-%date:~0,2%-%date:~2,2%" echo date=%date% pause md e:\2\%date% copy C:\1\*.* e:\2\%date% dirol726.bat date="Mo-n-"/-26" the above is mistake Terminate batch job (Y/N)? y p.s. It does not work for this session or any sessionBill posts his usual nonsense. Countdown to ban time... |
|
| 195. |
Solve : Dos Batch Variables? |
|
Answer» Looking for a was to restate if "!LINE!"=="19" in the following example to accept a variable Example: if "!LINE!"==%value% |
|
| 196. |
Solve : Batch Desktop Command? |
|
Answer» Hey. I was wondering if anyone knows a batch script that will show your DESKTOP and minimize all programs. Thanks in advance for ANYONES helpFor batch code normally rundll32 can be helpful, but I had zero luck. This short little snippet will minimize all the open windows: |
|
| 197. |
Solve : random password genrator? |
|
Answer» i made this code to generate random passwords. |
|
| 198. |
Solve : a batch with blank spaces in between? |
|
Answer» how to CREATE a batch with copy as header and end with lpt1? You say "nothing happened". Please say what you are expecting to happen.how to make the cmd do not close after i press any key? so i can drag and drop the file while cmd window open... |
|
| 199. |
Solve : Enter into network? |
|
Answer» Hi folks, But, as we know that dos cannot enter the file on network Could you explain more. Maybe I'm missing something, but where is the network file? Quote echo %cust_name%>>c:\banner\track.xls %ph_no%>>track.xls %printer%>>track.xls %st%>>track.xls Batch code cannot add records to an Excel spreadsheet file. You could create a Comma Separated Values file which can be imported into Excel. Code: [Select]echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>c:\banner\track.csv I can enter the details on the Excel file. I would like to enter the data on home drive that is on network like. \\hphome\vishu This is a network driver but, Dos is not able to enter the file on network and gives error. Quote but, Dos is not able to enter the file on network and gives error. What error? Posting the error will save me time trying to guess it. You keep REFERRING to "DOS" but there is no "DOS" on Windows XP. Are you referring to the NT command prompt? You could try mapping the network drive to your local machine: net use N: \\hphome\vishu You would then refer to your file as n:\banner\track.xls Note: the letter N was arbitrary; chose any unused letter you want. You can also use the UNC notation and refer to your file as: \\hphome\vishu\banner\track.xls As previously mentioned, you cannot use batch code to update an Excel spreadsheet. Good luck. Thanks for the reply. But, it is not working. Is there any way that I can enter on the network path. So, that I can save my output file The syntax of this command is: NET USE [devicename | *] [\\computername\sharename[\volume] [password | *]] [/USER:[domainname\]username] [/USER:[dotted domain name\]username] [/USER:[[email protected] domain name] [/SMARTCARD] [/SAVECRED] [[/DELETE] | [/PERSISTENT:{YES | NO}]] NET USE {devicename | *} [password | *] /HOME NET USE [/PERSISTENT:{YES | NO}] I am getting this message while I done that. Something may be missing. Please help... Help appreciated.. Regards VishuActually I am trying to make a user end dos file. That will save the data on the network. Network has a dedicated space. It is not the shared COMPUTER. It is little bit peculiar. But, I know since we can open drive from computer means in windows XP. So, we should be able to open it from dos. Cause dos is the basic unit of the computer. It can do most of the thing so, I hope it can do this as well. I want to see \\vishu\vishal instead of c:>documents and users\vishu\desktop> I know we do have lots of expert on dos. I hope I will get the answer. And I also want to save my output file on the network. Thanks and regards VishuYou still haven't posted the error message. If you want to put the batch file output on the network, you can you use this: Code: [Select]echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>\\vishul\vishal\banner\track.csv The banner directory must exist on the network drive. OR If you want to put the batch file output on the network, you can you use this: Code: [Select]net use N: \\vishu\vishal echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>n:\banner\track.csv The banner directory must exist on the network drive. You cannot use the UNC path as the current directory, but you can use a drive letter that has been mapped. This could be a permissions problem but you need to be more responsive to my requests for information. Sir, I am not able to get inside the path. Actually it is \\10.120.3.50 Getting error System error 1909 has occurred The referenced account is currently locked out and may not be logged on to. So, I hope bad luck? THANK you for the replie vishu The account you are trying to log in with is locked, you will need to go to the machine authenticating users to \\10.120.3.50 and then unlock your user account. Then go into the settings for the share you are trying to access and make sure that your account has permission to read and write to the share name (I''m guessing in your case it's called 'vishal' Depending upon the OS of the machine, there maybe at least 2 spots you need to change. One is the 'share permissions' and the other is the 'folder/file' permissions. I would suggest temporarily granting full access to everyone to the share until you get it working, then you can lock down the security to only your own account later.Thanks for the reply. I have access to read and write. As I can create any file on the network drive. I can copy and paste anything. Actually working on comp Don't want to reveal the name completely and even network path name. it's like \\10.120.3.50\user mail\agent access\ It is not the correct path but it is like this only. I can enter text word excel zip file in it. Can modify also. I have access. But, I am not able to enter anything using DOS window. I have this form that saves the file on my computer but not on path. What can I do??? Thanks for the information. echo off color f0 echo **********this is a form for all the users************* :1 Echo please enter the following details set /p "cust_name= Pleaser enter customer name : " set /p "ph_no= Pleaser enter Phone number : " set /p "printer= Pleaser enter Printer : " set /p "st= Pleaser enter Service ticket : " set /p "lead= Pleaser enter lead number : " echo %cust_name% echo %ph_no% echo %printer% echo %st% echo %lead% cd\ echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>\\10.120.3.50\agent mail\agent access\track.csv :mo set /p "mo= Do you want to add more details? y or n" if not defined mo goto :mo if "%mo%"=="y" goto :1 else EOF: Make sure you include your path name in quotes if the files have spaces echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>"\\10.120.3.50\agent mail\agent access\track.csv" or try echo %cust_name%,%ph_no%,%printer%,%st%,%lead%>>%TEMP%\track.csv copy %TEMP%\track.csv "\\10.120.3.50\agent mail\agent access\track.csv" You are Thank you so much. I have also clicked on thanks to you. you can see it increasing. You are dude man!!!!!!!!!!!! A thousand of raise to you. Thank you so much. I don't know how to thank you. Really thank you. Thank you thank you. Thank you thank you. Thank you thank you. Thank you thank you. Thank you thank you. Thank you thank you. I know we have masterminds on this forum. And also thank you other dudes who given replies. hat off or head off. Thanks and regards VishuYou're very welcomeThere is a little problem in excel format I want to add the format like Name then next cell phone no and next cell and id etc. All I want to add it into next cell. But datas are entered in single cell. So, how can I avoid it?FIGURED it. Tab will help. |
|
| 200. |
Solve : Batch Script Question? |
|
Answer» Let's say I do a simple clean up command like: Use the redirector '>' '>>' that will not log anything. move does not give you a stdout when it moves SUCCESSFULLY.yeah I know that.. MAYBE if ya actually read the rest......................... well when it successfully moved on my machine it recorded just fine as C:\Tests\01\Fri.txt C:\Tests\01\Mon.txt C:\Tests\01\Sat.txt C:\Tests\01\Sun.txt C:\Tests\01\Thu.txt C:\Tests\01\Tue.txt C:\Tests\01\Wed.txt Code: [Select] S:\>echo hello>test1.txt S:\>echo hello>test2.txt S:\>echo hello>test3.txt S:\>echo hello>test4.txt S:\>echo hello>test5.txt S:\>move t*.txt subdir>report.txt S:\>type report.txt S:\test1.txt S:\test2.txt S:\test3.txt S:\test4.txt S:\test5.txt 5 file(s) moved. S:\> |
|