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.
| 7951. |
Solve : Unable to execute the Command? |
|
Answer» hi guys, |
|
| 7952. |
Solve : Need help with variables...? |
|
Answer» I have an executable that returns the CURRENT date in yymmdd format. I have a need to automate the daily creation of a folder with this name, and move or copy files that are being overwritten nightly into this new folder. I thought if I ran this executable and redirected the output to a "date.dat" file, that I COULD use a batch file to type this value to a variable, then use a command like |
|
| 7953. |
Solve : Batch Script Problem...? |
|
Answer» hi all, |
|
| 7954. |
Solve : It doesn't works as a windows service? |
|
Answer» hi, A Windows service is automatically started when your system boots. It may be too early in the process to be mapping drives. Thank you for your help. let me try to explain in my poor english. the mapped drive is already there when service starts. i use this to create the service: net stop backup instsrv BACKUP REMOVE instsrv BACKUP c:\windows\system32\srvany.exe Reg add HKLM\SYSTEM\CurrentControlSet\Services\BACKUP\Parameters /v Application /d c:\windows\system32\backup.bat net start backup First i stop it (if it's running) then i remove it (if it exists) then i create it and i start it i made this batch because it is easier to create the service. the real problem here is (the mapped drive is already there when it runs as a service): local drive - running as a service - ok local drive - not running as a service - ok mapped drive - running as a service - NOT ok mapped drive - not running as a service - ok i hope you have any ideas The service starts before any user is logged in which I think is the problem with mapped drives. All the files probably need to be local or use UNC paths. Try using UNC paths....can't hurt. Good luck. First off all, I don't know how to use UNC Paths. Another way to put the problem (perhaps more easier to explain): i have a mapped drive here called Z (it's already mapped... i'm able to access it, and so on, and so on) in a comand line i wrote z: then xcopy z:\server\*.* "H:\backup\PC_SERVER\E\server\" /Y /I /k /D /H /C /E everything worked. After this test i made a batch file with the two lines:(z: it's already mapped... i'm able to access it, and so on, and so on) z: xcopy z:\server\*.* "H:\backup\PC_SERVER\E\server\" /Y /I /k /D /H /C /E i runned the batch file... everything's fine. Then i put this batch as a service(z: it's already mapped... i'm able to access it, and so on, and so on) nothing happened... Why? I noticed that running as a service, the batch file doesn't change to drive Z: (this only happen with mapped drives, with local drives it works fine) and if it doesn't change to z:, it is not able to xcopy z:\server and it stops Quote After this test i made a batch file with the two lines:(z: it's already mapped... i'm able to access it, and so on, and so on) It probably works because you are signed into the machine. When the batch file is run as a service, there is no user. Quote First off all, I don't know how to use UNC Paths. Sure you do. This is a UNC path: \\computername\sharename When you mapped the drive you used a UNC path: net use h: \\server\backup Why is it necessary to run a backup as a service? You can run the backup from the task scheduler (at startup) or even the startup folder found on the start menu. It would save yourself a lot of grief. Quote from: Sidewinder on January 27, 2010, 06:16:02 AM It probably works because you are signed into the machine. When the batch file is run as a service, there is no user. I just don't want the black window appears on screen even if it's minimizedQuote I just don't want the black window appears on screen even if it's minimized So that is what this is all about. Have you even tried to use the UNC paths? After using Google, I discovered this a common problem with mapped drives and the only realistic solution is the UNC method. Another alternative is to write a script that runs in Windows (VBScript is installed on your machine and does not require the cmd processor.) The problem is the XCOPY switches which may be difficult to duplicate in VBScript. Good luck. using UNC path i have the same problem our conversation pointed me to the security of a share folder... i BELIEVE the solution is to give the right access to the rigth users NETWORK SERVICE??? NETWORK??? ALL?? SYSTEM?? and others. or perhaps i will need to create a user and give him the access through network.... i don't know... but right now it seems that the problem is the service has no access rigths in mapped drive... i 'm going to study this... i will tell you my conclusions. thanks for your help After a search, my first idea was right... it was the access rights of users to mapped drives.... somewhere i read that a mapped drive to be accessed by a service, must be created by a service with administrator rights... suddenly i remember that i have the user administrador with password (created when i installed windows). so i changed my batch files: batch1 (to create the and start the service) net stop BACKUP instsrv BACKUP remove instsrv BACKUP c:\windows\system32\srvany.exe Reg add HKLM\SYSTEM\CurrentControlSet\Services\BACKUP\Parameters /v Application /d C:\windows\system32\backup.bat net start BACKUP batch2 (to be used as the service named BACKUP) net use z: \\server\www *********** /USER:server\administrator :START z: cd\ xcopy *.* "h:\test\" /Y /I /E /k /D /H /C goto START where *********** is the password of administrator Thank you so much. Our conversation helped me a lot. Any time you need something... i'm here ok?Thank you for getting back to us. It never hurts to learn something new. I admit that if the UNC method didn't work (it didn't), my next suggestion would not have been to have the service have administrator rights. Stick around. As on all forums there are many more questions than answers. We can use all the help we can get. Good luck. |
|
| 7955. |
Solve : using pc's as terminals? |
|
Answer» :-/ i need to communicated with a calcom plotter and my terminal SCREEN is down. i used my pc as a terminal once some years ago and i have FORGOTTEN how |
|
| 7956. |
Solve : batch to make folder based on input? |
|
Answer» Hey guyz im trying to make a batch that will create a folder based on user input
C:\batch>type Khasiar.bat Code: [Select]@echo off echo Enter folder name: set /p var= echo var %var% md %var% dir /ad kh* Output: C:\batch>Khasiar.bat Enter folder name: KHAS var Khas Volume in drive C has no label. Volume SERIAL NUMBER is F4A3-D6B3 Directory of C:\batch 01/24/2010 05:25 PM Khas 0 File(s) 0 bytes 1 Dir(s) 303,069,970,432 bytes free C:\batch>Quote from: Khasiar on January 24, 2010, 04:01:26 PM Hey guys I'm trying to make a batch that will create a folder based on user input Code: [Select]@echo off echo Usage xxh.bat "folder name" pause md %1 dir /ad %1* Output: C:\batch>xxh.bat john Usage xxh.bat "folder name" Press any key to continue . . . Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\batch 01/25/2010 12:30 PM john 0 File(s) 0 bytes 1 Dir(s) 303,028,146,176 bytes free C:\batch>Code: [Select]@echo off set /p fname =Folder Name: md %fname% |
|
| 7957. |
Solve : Editing config.sys? |
|
Answer» I am trying to edit a config.sys FILE to allow booting only from CD-ROM. This is the file that I have, but I haven't found a good explaination of what to edit. It needs to be generic, if possible, so it will work on different systems. |
|
| 7958. |
Solve : MS DOS Computer? |
|
Answer» Hi, |
|
| 7959. |
Solve : Batch to read a text file line and save as a variable? |
|
Answer» Hi folks |
|
| 7960. |
Solve : Need help to script 'replace text as save file as'? |
|
Answer» Hi, |
|
| 7961. |
Solve : How to check the entered path is valid or not? |
|
Answer» Hi, |
|
| 7962. |
Solve : Modify Registry entry with batch file? |
|
Answer» I am trying to fix a registry issue that was caused when my company upgraded from OFFICE 2003 to Office 2010. I have tried a few different things but have had no success. Heres the info: |
|
| 7963. |
Solve : can i get a bat file to alert me if it fails?? |
|
Answer» can i get a bat file to email me if it fails? can i get a bat file to email me if it fails? Yes and No ... If it fails it can not report failure, so you need a 2nd PROCESS which could be a different batch file that performs a checkup on the batch that is to be monitored for failure and performs the e-mail through 3rd party software that allows for e-mail sent from COMMAND line. I made a C++ program that checked a Routine1_log.txt file for the date. The batch process started at 12:15am and so if it completed successfully, (got to complete the entire instruction set of the batch file), at the end of this batch file I had a echo. %date%>Routine1_log.txt to pass the date to this log file. The C++ program I wrote would run at 4am and test to MAKE sure that todays date matched that of the Routine1_log.txt file. If it was a match then no e-mail alert. If there was a mismatch, then I would be sent an e-mail. I then was able to check my e-mail first thing in the morning and see what processes failed if any did. It was a very rare occurrance to have a batch malfunction or fail to complete, but it happened 2 times in 5 years. Not to SIDETRACK, but I ended up creating a monitoring system that would give me a phone call and play prerecorded messages to myself as to the problems so I knew where the problem was and was able to get to the site and already know what I was up against before getting there. In addition to programs I wrote in C++, I used a cool software tool called Alert Ping Pro and bought a license of it. http://www.downloadsource.net/1844/AlertPingPro/ Figured I'd share this in case you need additional monitoring such as to make sure network attached devices are LIVE as well as I also had 4 other locations bridged to the central hub and I could tell when a site went offline from the central hub location. Quote also, is there and easy way to schedule a bat file to run every night at a certain time?Yes IF Windows OS using Scheduled Task Manager to trigger execution of batch etc at a specific time. Quote Im trying to setup Jenkins, scheduler, here, but, its not going well. The commands im feeding it work in the cmd window, but, they dont work in Jenkins. I have never used Jenkins, but I am assuming that your dealing with a common problem where you are trying to pass keystrokes to Jenkins that is running in a different window than that of the batch file. Easiest way to make this work is to use a keyboard/mouse macro creator such as jitbit and compile the routine to an exe form which can then be started from the batch file and copy/paste info or enter info into specific fields etc.Dave I know this a month or two later, but I just wanna say thanks for going to the trouble of writing your reply. interesting reading, ill have to look more into each section. regards, redd . Hey, no problem ... usually when there is no response, we all figure that the request for help was resolved. Its all good!And not to worry about the time...it's nice enough you had the courtesy to return with a reply. |
|
| 7964. |
Solve : print sub-directorys? |
|
Answer» How can I PRINT the contents of a sub-directory. Or send them to a FILE that then can be printed. There used to be a LIST COMMAND that would work. Thanks NormaNot really sure what you need. |
|
| 7965. |
Solve : How to verify if a certain program is installed, then make an alert.? |
|
Answer» I need a script that will verify if a program is installed, then create an alert that the program exists on the system. I would APPRECIATE any HELP I can get.Check that the program install folder exists, and whether the executable program file is present in that folder. Tailor as appropriate for 32-bit and 64-bit systems. |
|
| 7966. |
Solve : MSDOS Batch Files: Input Command? |
|
Answer» I'm SURE there is an INPUT type of command for MS-DOS Batch files where I can ask for keyboard input & await a response, and assign Errorlevels to the response. |
|
| 7967. |
Solve : Occasional beep when XCOPY process is running, heard through Sound Card?? |
|
Answer» I was replicating the data of one external hard drive to another by use of a simple xcopy F:\*.* E:\*.* /s/d/y instruction and in the meantime with the data transfer scrolling in the command shell I was on Facebook and also had World of Warcraft running, and I have the game sound set to about 50% so that if I am playing music it is louder than the game. During the XCOPY process transferring about 206GB of data I heard a BEEP which came not from the internal PC speaker, but instead it came from the 5.1 sound system that is connected to my computer. The beeps that are sometimes heard when robocopy is running seem to correspond to situations when a file that has a name that is too long or has characters that are not recognized by the operating system. I have seen the above suggested as explanations for Xcopy beeps also. Also since it is coming via the sound card it's a system sound and if Xcopy does beep whether you hear it or not depends on the sound scheme selected and volume setting. Thanks everyone. And I too expected to find more on Google. Some of the paths and files are long and so I guess it could be this: Quote The beeps that are sometimes heard when robocopy is running seem to correspond to situations when a file that has a name that is too long or has characters that are not recognized by the operating system. Checking the external against the destination is an exact match, so its not an error condition that skips a file or path that is too long. I guess it just is what it is. Just this is the first time I have seen it happen, and the last thing I would have expected was it to be from xcopy process, but thats what it is. I guess I will ignore the occasional beep Thanks everyone Turn the sound down.... |
|
| 7968. |
Solve : Basic Help with XP Command-line utilities? |
|
Answer» Quote from: Jayell I stated at the time that I didn't want to get too far into this but here I am anyway. Quote from: Jayell I'd be a LIAR if I said I hadn't at least wondered about scripts. Ha! ha! ha! ha! HOOK LINE and sinker here. 1,750,000 Google hits. And that's just batch scripting, add another zillion for VB scripting, AWK GAWK etc... Thanks, Dusty. That ought to keep me busy for awhile. |
|
| 7969. |
Solve : command to pause a batch file? |
|
Answer» hi, im writing a really simple autoexec.bat to go on a dos boot disk. I would like to KNOW if there is a command that when USED in a batch file; will WAIT until enter is pressed or space or something and then carry on, because you need to put in NTFSdos on disc after the dos boot disc to carry on properly booting. |
|
| 7970. |
Solve : Lable help? |
|
Answer» Does anyone know how to make a GOTO LABLE comand work only once in a batch file. |
|
| 7971. |
Solve : Re: ms dos? |
|
Answer» Um, I would love to help you, but you NEED to be more specific. Exactly, what do you need? Because, this is what I THINK you're SAYING: |
|
| 7972. |
Solve : I need help with parameters? |
|
Answer» I am trying to correctly use the ATTRIB command in MS dos. I keep getting a message that says: "Parameter format not correct". I am trying to open a file that is locked, and ATTRIB seems to be the only method of opening it, but I cannot get it to WORK. Here is exactly what I TYPE: |
|
| 7973. |
Solve : Backup script help? |
|
Answer» HELLO all, I was wondering could I get help with my backup script. I have got my XCOPY working well. Copies all the files from A to B and only copy's the new or updated files from there on (this backup runs every day). However when I delete a file from A (or move it to another folder) when the script runs again it keeps the original file in B or even makes another copy of the file in B if it was moved ELSE where. What I want to do is to check ALL files and folders in B to see if they exist in A. If they dont exist in A then delete them from B. (basiclly B is a direct mirror copy of A). How would I code it? I know I could simply delete the B files and xcopy the files again from A but that means I will be copying every file again and some of my backups are very big. What I want to do is to keep my incrimental xcopy command and then to have a loop that checks all B files if they exist at A and to ether leave them alone or delete them from B. What I have been trying to do is export a .txt file with all files / directories from B then input each line as a variable -> check veriable exists in A then to ether ignore or delete the file from B then to move to the NEXT line in the text file (therefore the next file in the directory) and save that as the variable and start the loop again until all files (lines) have been processed but so far I have had no luck. Hopefully there is a easier way. Thanks in advance!Quote from: jokenno14 on January 26, 2010, 04:33:15 PM What I have been trying to do is export a .txt file with all files / directories from B then input each line as a variable Compare file names and contents with the Comp command: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/comp.mspx?mfr=true C:\batch>comp /? Compares the contents of two files or sets of files. COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[liNE]] data1 Specifies location and name(s) of first file(s) to compare. data2 Specifies location and name(s) of second files to compare. /D Displays differences in decimal format. /A Displays differences in ASCII CHARACTERS. /L Displays line numbers for differences. /N=number Compares only the first specified number of lines in each file. /C Disregards case of ASCII letters when comparing files. /OFF[liNE] Do not skip files with offline attribute set. To compare sets of files, use wildcards in data1 and data2 parameters. C:\batch> Code: [Select]dir /b c:\*.bat > batfiles.txt dir /b c:\batch\*.bat > batfiles2.txt comp batdiles.txt batfiles2.txt I have not tested the comp command.Quote from: jokenno14 on January 26, 2010, 04:33:15 PM (basiclly B is a direct mirror copy of A). Since you appear to be using Windows 7, try ROBOCOPY with the /MIR option. e.g. Code: [Select]ROBOCOPY A B /MIRQuote from: oldun on January 26, 2010, 06:10:55 PM Since you appear to be using Windows 7, try ROBOCOPY with the /MIR option. Wow! Never heard of ROBOCOPY! looks fantastic! I should only need one line then: robocopy A B /MIR / E /Z right? That will keep both destination and SOURCE the same but will it also act as a incremental backup? Thanks for the help!You do not need /E with /MIR. Also, you only really need /Z when backing up to a network share. |
|
| 7974. |
Solve : What does this script do?? |
|
Answer» We use a script to AUTOMATE the reboot of our servers. The script is run from the task manager with a parameter that indicates the number of times the routine should run before it quits. So it's CALLED like this: serverrebootscript.bat 100 |
|
| 7975. |
Solve : Batch file not responding? |
|
Answer» When I execute my batch COMMAND When I execute my batch command Windows errors related to gui.exe? gui.exe is a process belonging to an advertising program by searchnugget.com. This process monitors your browsing habits and distributes the data back to the author's servers for analysis. This also prompts advertising popups. This process is a security risk and should be removed from your SYSTEM. http://www.liutilities.com/products/wintaskspro/processlibrary/gui/ |
|
| 7976. |
Solve : basic question...? |
|
Answer» hello, i was wondering, is there a way to GET a list of all current DRIVES under dos? Have a comp here without windows installed and having difficulty accessing which drive is the cd-rom... doesnt appear to be D:....Well, I can't FIND any commands of that nature, but If you type A:, then B:, C:, D:, E:, F:, one of them should do it. It's a bit long, but it should work. PERHAPS DOS doesn't "see" the CD-ROM. Did you have it before?no |
|
| 7977. |
Solve : need some help witnh Batch command in Windows? |
|
Answer» HI all, I have LOG Compressor script which USED to work before, suddely it STOPPED working and I am not able to understand the meaning for the following line can some one help me in understanding this if NOT EXIST E:\logs\web\%4 mkdir E:\logs\web\%4 what will this line do ??the batch is started with at least 4 parameters; the 4th is a folder name. If it does not exist it is CREATED. |
|
| 7978. |
Solve : Set Variable Equal to the Second Wednesday of the Month? |
|
Answer» Since the date of the second Wednesday of the month changes every month I am unsure of how to reference this day of the month so I can set it equal to a variable. My plan is to add the logic to a script I run every day to maintain the servers. Instead of manually running a Windows Updates check after Patch Tuesday I want my script to determine if it is the right time in the month to fetch updates. could be diffrent format for you What if they live in (say) Europe? HTTP://ss64.com/nt/date.html Gives a list of date -> locale Also, you may find 'wmic path win32_localtime get day,dayofweek,weekinmonth' to be useful. According to ss64.com it is on XP Pro-win7. Code: [Select]@echo off setlocal EnableDelayedExpansion wmic path win32_localtime get day,dayofweek,weekinmonth for /f "tokens=1,2 delims==" %%A in ('wmic path win32_localtime get day^,dayofweek^,weekinmonth /value') do ( set %%A=%%B ) set dow=%DayOfWeek% set wim=%WeekInMonth% Echo day = %day% echo dow = %dow% echo wim = %wim% :loop.dow if %dow% LSS 3 ( set /a dow+=1 set /a day+=1 ) if %dow% GTR 3 ( set /a dow-=1 set /a day-=1 ) if not %dow% EQU 3 goto :loop.dow :loop.wim if %wim% LSS 2 ( set /a wim+=1 set /a day+=7 ) if %wim% GTR 2 ( set /a wim-=1 set /a day-=7 ) if not %wim% EQU 2 goto :loop.wim echo The second wednesday OCCURS on %day% Sorry for the double post, just realized I had forgotten to clean up my code before posting it. Code: [Select]@echo off setlocal EnableDelayedExpansion for /f "tokens=1,2 delims==" %%A in ('wmic path win32_localtime get day^,dayofweek^,weekinmonth /value') do ( if not "%%A"=="" if not "%%B"=="" set %%A=%%B ) set dow=%DayOfWeek% set wim=%WeekInMonth% :loop.dow if %dow% LSS 3 ( set /a dow+=1 set /a day+=1 ) if %dow% GTR 3 ( set /a dow-=1 set /a day-=1 ) if not %dow% EQU 3 goto :loop.dow :loop.wim if %wim% LSS 2 ( set /a wim+=1 set /a day+=7 ) if %wim% GTR 2 ( set /a wim-=1 set /a day-=7 ) if not %wim% EQU 2 goto :loop.wim echo The second Wednesday occurs on %day%. Thanks guys. As usual I requested help when I needced this right-away but other "hotter" things came up and I haven't gotten a CHANCE to apply your ideas yet. I'll post back for sure when I have. I really appreciate the help. MJ |
|
| 7979. |
Solve : help with dos? |
|
Answer» i accidently hit restart ms-dos and when i turn on my computer it SAYS C:/windows and i DONT know what to TYPE to get it to WORK agian.win <enter> |
|
| 7980. |
Solve : CHOICE vs. SET command? |
|
Answer» I want to use BATCH files to allow a Yes/no prompt e.g. "Do you wish to continue? (Y/N)" but I am having trouble. I saw the CHOICE command, and tried it, but since I am using Version 5.1, I can't use it. This site says the SET command can be used the same way, but I can't figure out how to use the SET command in the same way. It doesn't seem to fit what the CHOICE command is capable of. And I don't know how to write code like this: I'm not a genius PROGRAMMER! Can anyone please tell me how to use SET this way?Code: [Select] I apologize, but I haven't used DOS for 12 years. Quote My lack of understanding just might have something to do with the fact I'm 14 Huh?What I just said is that I am 14 years old. I'm young, and didn't use more that a little of DOS growing up, since Windows came out. At least, that's when I GOT it. Actually, I had one more question. In that example, what if someone types 5? That's not a choice, so it terminates the .BAT file. How do I get it to return to the beginning?That's one of the problems with set. Choice only allowed you to enter a defined response and otherwise beeped if you did not. Code: [Select] @echo off :start set /p var=Enter Option: if %var%==1 goto 1 if %var%==2 goto 2 if %var%==3 goto 3 if %var%==4 goto 4 goto start :1 echo 1 goto end :2 echo 2 goto end :3 echo 3 goto end :4 echo 4 :end Not nearly a clean as CHOICE, but it gets the JOB done. Thank you. I suppose that's it. I'll get back to learning some more advanced functions of DOS. Have a good day, Sidewinder. |
|
| 7981. |
Solve : Copy to clipboard without using clip.exe? |
|
Answer» Hello guys, I've been using this method for a very very long time and got used to it, But then I was wondering if there is another way to copy text to the clipboard without using this file called clip.exe which I always have to carry with it in order to make my batch script work with it. would be nice if some ONE can HELP me. Thanks in advance This works but in modern VERSIONS of windows it asks you if you want to allow it access. Code: [Select] @echo off echo.> %temp%\tmp.vbs set oIE=CreateObject("InternetExplorer.Application") echo.>>%temp%\tmp.vbs oIE.Navigate "about:blank" echo.>>%temp%\tmp.vbs Do Until oIE.ReadyState = 4:wsh.Sleep 50:Loop echo.>>%temp%\tmp.vbs oIE.document.ParentWindow.ClipboardData.SetData _ echo.>>%temp%\tmp.vbs "text", wsh.stdin.readall > %temp%\tmp.txt ECHO aaabbbccc type %temp%\tmp.txt | CSCRIPT //nologo %temp%\tmp.vbs del %temp%\tmp.vbs %temp%\tmp.txt Thanks foxidrive, What I'm really looking for is a way to copy and paste with my batch without the need of clip.exe Now with the script you just posted, the only problem I see is that it involves the use of .vbs script which in Windows 8 all my batch scripts containing .vbs seems to fail. What error do you get? The script above is no good for unattended work anyway, it asks for permission to run it each time. |
|
| 7982. |
Solve : How to use a batchfile in order to make a shortcut on the desktop?? |
|
Answer» Hey guys, |
|
| 7983. |
Solve : check for numerical values in a .txt file? |
|
Answer» I have an MS SQL query that outputs a .txt file containing a 6 character numerical string in the first line, STARTING at pos 1. |
|
| 7984. |
Solve : batch to delete directory and subfolder files? |
|
Answer» Dear all, "Can you please help me in creating a batch file, C:\batch>type deldir.bat Code: [Select]@ECHO off md puli cd puli md subpuli echo puli in subpuli > puli.txt dir type puli.txt cd \ cd batch echo. echo REMOVE directory and subpuli echo. rd /s puli echo. Output: C:\batch>deldir.bat Volume in drive C has no label. Volume SERIAL Number is F4A3-D6B3 Directory of C:\batch\puli 01/25/2010 01:04 PM . 01/25/2010 01:04 PM .. 01/25/2010 01:04 PM 19 puli.txt 01/25/2010 01:04 PM subpuli 1 File(s) 19 bytes 3 Dir(s) 303,027,625,984 bytes free puli in subpuli remove directory and subpuli puli, Are you sure (Y/N)? y C:\batch>dir puli Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\batch File Not Found C:\batch>Thanks friend, for your inputs... the batch file is working fine. Thank you so much.U cud also use this Code: [Select]rd /S /Q NAMEOFTHEFOLDER |
|
| 7985. |
Solve : does anybody know how to email from batch file?? |
|
Answer» hello guys i want to plot FTP Client and want to do setup for email on BATCH FILE! does anybody know about it?Google for "Timo Salmi" and his batch FAQ. You will find scripts for all sorts of THINGS including emailing.I'm using blat.exe for sending e-mails from batch scripts and it works great. Check http://www.blat.net/examples/batch.html out. |
|
| 7986. |
Solve : How to check if a directory is empty or not? |
|
Answer» HI there, I would like to copy files from one directory to another directory. If the source directory is empty, I would like to print a warning MESSAGE and skip the xcopy command. How to do it? Thank you. J.If you test directory size in batch, it will always come up empty (restricted to files). XCOPY has the /s /e /t switches that may be ABLE to do what you need (type XCOPY /? at a command prompt for details) ALTHOUGH putting out a message could be problematic. WinScript is always an option as folders have a SIZE property you can test. Check out The Windows SCRIPT Center and it's links for more info. Hope this helps. Hello, Just made a .BAT file that answers your problem neatly: @ECHO OFF IF NOT EXIST %1 GOTO Error XCOPY %1 %2 GOTO End :Error ECHO Source does not exist. GOTO End :End Call it whatever you want; I call it ZXCOPY.BAT Good luck! |
|
| 7987. |
Solve : Printing Q. Basic files on a USB printer? |
|
Answer» My nephew has created a 'virtual' machine within 'XP'to allow me to use DOS6.22 any own 'Q.Basic SOFTWARE. My computer has USB ports and a paralllel PORT (LPT 1). My INKJET printer has a USB plug. How can I get this printer to print from Q.Basic as WELL as from my Windows Office applications? (Assuming that there is a way)Im not familiar with the way virtual machines work, but you could save the source file as ASCII (Save /A I think, its been a while) to a LOCATION accessible by your main pc and print it from there |
|
| 7988. |
Solve : How to check to see if a service is running on multiple computers? |
|
Answer» Hey all; I'd like to write a batch file (not good with powershell or the wmic command) that reads a text file for computer names, then runs the sc.exe command against each one then builds a list (csv) file that looks like "computername, running or computername, stopped". I greatly appreciate any help. "computername, running or computername, stopped" What information do you want? I don't think you have specified the task properly. Quote from: foxidrive on September 16, 2013, 07:20:05 PM "computername, running or computername, stopped" The end result of what I'm after would be a file called endresult.csv (for example), which would look something like this: computername1,running computername2,running computername3,stopped Does that explain it a bit better?Have you mentioned anywhere which service you are testing? |
|
| 7989. |
Solve : Executing a Remote Batch File? |
|
Answer» I need to execute a batch file on a set of other PC's from my work station. How do I write the batch file so that it executes on the remote pc rather than on my station?I have been FRUSTRATED by this myself. Apparently if the PC's are members of a WORKGROUP you cannot REMOTELY execute jobs. If the PC's are on a DOMAIN you can provided: Before you can launch a script remotely, the system on which it runs has to be For an example of a remote script, CHECK out: http://www.script-info.net/jsvbs/msscript/ws/wsconrunningscriptsremotelyrunningscriptovertherefromhere.php For command line support check out REXEC: (you need to scroll down) http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx Hope this HELPS. |
|
| 7990. |
Solve : XCOPY Error LOG?? |
|
Answer» I use the following XCOPY syntax to backup to an external HDD: |
|
| 7991. |
Solve : Custom Batch TUI OS? |
|
Answer» Thanks......... Thanks........ sorry 2 post |
|
| 7992. |
Solve : Color Text in vbs? |
|
Answer» So I am trying to rewrite one of my batch scripts in vbs to learn, and I have run into a problem. I don't know how to write this section in a different color (other than black). I tried wscript.font.color(0,255,0) which I found somewhere, but It didn't work. Any advice would be great. |
|
| 7993. |
Solve : Create a bartch file that concatenates filename with directory name? |
|
Answer» Hi all, I'm trying to write a batchfile (called "Convert" in the example below) that concatenates from a given directory, all file names in that directory with the directory names of teh subdirectories. E.g. running "Convert" in the RootDir of this directory structure : RootDir > Test1Dir > MyFile.txt would result in a filename "RootDirTest1DirMyFile.txt" The batchfile would need to convert all files in RootDir. Any help really appriciated.Do the files get new names but stay in their original locations, or do they get moved? Quote from: Steven on January 23, 2010, 07:54:03 AM RootDir > Test1Dir > MyFile.txt C:\>type filedirname.bat Code: [Select]@echo off cd \ cd Test1Dir dir copy MyFile.txt xMyFile.txt ren MyFile.txt RootDirTest1DirMyFile.txt dir Output: C:\>filedirname.bat Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\test1dir 01/23/2010 11:23 AM . 01/23/2010 11:23 AM .. 01/23/2010 11:23 AM 8 MyFile.txt 1 File(s) 8 bytes 2 Dir(s) 303,144,689,664 bytes free 1 file(s) copied. Volume in drive C has no label. Volume Serial Number is F4A3-D6B3 Directory of C:\test1dir 01/23/2010 11:24 AM . 01/23/2010 11:24 AM .. 01/23/2010 11:23 AM 8 RootDirTest1DirMyFile.txt 01/23/2010 11:23 AM 8 xMyFile.txt 2 File(s) 16 bytes 2 Dir(s) 303,144,689,664 bytes free C:\test1dir>Thanks all. The difficult thing to get solved is the automatic scan of the entire directory structure. The batch file would need to start from the root directory, and from that point, scan all subdirectories (multiple levels), search all files in those subdirs, and convert the filenames. Quote from: Steven on January 24, 2010, 02:27:52 AM Thanks all. The difficult thing to get solved is the automatic scan of the entire directory structure. The batch file would need to start from the root directory, and from that point, scan all subdirectories (multiple levels), search all files in those subdirs, and convert the filenames. There are ways of doing this. Can I please ask a clarifying question? It seems to me that what you want to do is this: (Where D represents the drive letter) - start in some SUBFOLDER, an arbitrary DISTANCE down the folder tree, say: D:\Some Folder\Some Other Folder maybe\Topdir and look in all the subfolders under that folder, renaming all the files found as follows: take the path from Topdir and the filename, and rename each file with a string which is its path and filename with the slashes removed thus Topdir\animals\cats\lion.txt becomes Topdiranimalscatslion.txt Each file keeping its existing extension and remaining in the folder in which it is found. The previous part of the complete path (e.g. Some Folder\Some Other Folder maybe\) not to be part of the new filename? That is what I hope you can clarify. Is that correct? I have written and tested a batch script that seems to do what the OP requires ... if he/she clarifies as I asked, I will probably post it here, so let's see if they come back... Wouldn't this work? @echo off setlocal enabledelayedexpansion set path2top=D:\somedir\otherdir\ For /f "delims=" %%a in ('dir /b /s %path2top%') do ( set filepath=%%a set filepath=!filepath:\=! REM ren %%a !filepath! echo Rename %%a to !filepath! ) Untested. If it says it has "Renamed" the desired files to the desired name, remove the word REN and RUN the script again. Quote from: Helpmeh on January 24, 2010, 09:57:44 AM Wouldn't this work? I thought the OP WANTED the relative path from some top folder which was not necessarily the root folder of a drive, therefore the full dir /b /s path would have to be processed somehow, and an /a-d might be handy... This is what I hacked out... Code: [Select]@echo off setlocal enabledelayedexpansion REM set top folder set TopFolder="D:\SubRename\Animals" REM make Topdir current directory cd /d "%TopFolder%" REM Get top dir's path for /f "delims=" %%P in ("%TopFolder%") do set TopDirPath=%%~dpP REM Set char to replace Set ReplacedChar=\ REM Set replacement character(s) REM Leave blank for none set ReplaceWith= REM Or e.g. replace with dash REM set ReplaceWith=- REM Or e.g. replace with -$$$- REM set ReplaceWith=-$$$- REM Or e.g. replace with a space This is how you would do a space set "ReplaceWith= " REM For each file in and under top dir... REM Change the filespec from *.* if desired to filter files REM standard wildcard rules apply REM e.g. *.txt to only operate upon .txt files set filespec=*.* for /f "delims=" %%F in ('dir /s /b /a-d %filespec%') do ( REM Find the file's full path, name and extension set FullPath=%%~dpnxF REM Remove part of path above TopDir Set SubPath=!FullPath:%TopDirPath%=! REM Replace char(s) in path and name set NewName=!SubPath:%ReplacedChar%=%ReplaceWith%! REM Inform user of old file path+name and new name echo File: "!FullPath!" echo New name: "!NewName!" REM Rename command syntax REM Rename [Drive:][\Path\]OldName NewName REM Remove REM from following line after testing REM Carry out rename operation REM Remove REM to activate the next line REM Rename "!FullPath!" "!NewName!" echo. ) echo Finished pause Before... Code: [Select]D:\SubRename\Animals>dir /s /b /a-d D:\SubRename\Animals\Test.txt D:\SubRename\Animals\Birds And Fish\Eagle\Test.txt D:\SubRename\Animals\Birds And Fish\Salmon\Test.txt D:\SubRename\Animals\Cats\Lion\Test.txt D:\SubRename\Animals\Cats\Panther\Test.txt D:\SubRename\Animals\Dogs\Bichon Frise\Test.txt D:\SubRename\Animals\Dogs\Poodle\Test.txt D:\SubRename\Animals\Horses\Foal\Test.txt D:\SubRename\Animals\Horses\Mare\Test.txt D:\SubRename\Animals\Horses\Stallion\Test.txt Run the batch... Code: [Select]File: "D:\SubRename\Animals\Test.txt" New name: "AnimalsTest.txt" File: "D:\SubRename\Animals\Birds And Fish\Eagle\Test.txt" New name: "AnimalsBirds And FishEagleTest.txt" File: "D:\SubRename\Animals\Birds And Fish\Salmon\Test.txt" New name: "AnimalsBirds And FishSalmonTest.txt" File: "D:\SubRename\Animals\Cats\Lion\Test.txt" New name: "AnimalsCatsLionTest.txt" File: "D:\SubRename\Animals\Cats\Panther\Test.txt" New name: "AnimalsCatsPantherTest.txt" File: "D:\SubRename\Animals\Dogs\Bichon Frise\Test.txt" New name: "AnimalsDogsBichon FriseTest.txt" File: "D:\SubRename\Animals\Dogs\Poodle\Test.txt" New name: "AnimalsDogsPoodleTest.txt" File: "D:\SubRename\Animals\Horses\Foal\Test.txt" New name: "AnimalsHorsesFoalTest.txt" File: "D:\SubRename\Animals\Horses\Mare\Test.txt" New name: "AnimalsHorsesMareTest.txt" File: "D:\SubRename\Animals\Horses\Stallion\Test.txt" New name: "AnimalsHorsesStallionTest.txt" Finished Press any key to continue . . . After... Code: [Select]D:\SubRename\Animals>dir /s /b /a-d D:\SubRename\Animals\AnimalsTest.txt D:\SubRename\Animals\Birds And Fish\Eagle\AnimalsBirds And FishEagleTest.txt D:\SubRename\Animals\Birds And Fish\Salmon\AnimalsBirds And FishSalmonTest.txt D:\SubRename\Animals\Cats\Lion\AnimalsCatsLionTest.txt D:\SubRename\Animals\Cats\Panther\AnimalsCatsPantherTest.txt D:\SubRename\Animals\Dogs\Bichon Frise\AnimalsDogsBichon FriseTest.txt D:\SubRename\Animals\Dogs\Poodle\AnimalsDogsPoodleTest.txt D:\SubRename\Animals\Horses\Foal\AnimalsHorsesFoalTest.txt D:\SubRename\Animals\Horses\Mare\AnimalsHorsesMareTest.txt D:\SubRename\Animals\Horses\Stallion\AnimalsHorsesStallionTest.txtQuote from: Salmon Trout on January 24, 2010, 11:05:06 AM Hack Mr. Trout you are very thorough and usually accurate. ( I have not tested your latest creation. ) What is the practical application for the batch that Steven, the Original Poster has requested?Thank you Mr Richardson. |
|
| 7994. |
Solve : re-archiving a file without...? |
|
Answer» Quote from: Ocalabob on April 11, 2013, 12:00:47 PM Using WIN7 from a command prompt the line below worked for me: I tested that and it puts "ECHO is off" inside the file. This also works to change the archive attribute but appends a blank line. Maybe the teacher expects the file to be modified, but that's not in the spirit of the task. Code: [Select]echo.>>FOOT-PRO.TMS We still haven't solved this conundrum without moving or copying the file. Quote from: foxidrive on April 12, 2013, 01:38:09 AM Maybe the teacher expects the file to be modified, but that's not in the spirit of the task. I'd argue that GIVING stupid tasks with trick answers isn't in the spirit of learning.I agree. But I figured out a solution. Code: [Select]echo e|edlin /b foot-pro.tms >nul Cons are that it creates a .BAK file, ADDS an EOF marker and isn't meant to handle binary files.Also Edlin is not available on most default installs. Actually I don't think it works Post DOS5 edlin is a default utility in Windows 8 where I tested this. It's also in a default Win7 install, and a W2k install and is in my XP install.I think I figured it out: it's only available on 32-BIT Versions of the OS. which is why I do not have it on my 64-bit Windows 8 or Windows 7. chophillies will have to comment if they have 64 bit systems. edlin and debug are 16 bit tools so don't work in 64 bit systems. debug will write the file too and change the archive bit.Powershell's Set-ItemProperty can set / unset attribute bits, but this is not fundamentally different from using the ATTRIB command, is it? COMPUTERS on campus run windows 7 64 bit. Most 32 bit os have been replaced on campus with the exception of a couple servers i use as vms for my networking class. There i can access a 32bit version of xp. Since the command line course is also available to take exclusively online, i believe the solution she had in mind would probobly not be restricted to the type of os the student is using. Not every student who takes the command line course is required to take the networking course therefore any student with a more modern 64 bit os would be left hanging. I cant wait till class tuesday to find out her magic answerI tried piping echo across to SET /P and redirecting but that still wrote a new line and I also tried redirecting nul into set /p and redirecting that to the output file but that didn't work either. I can't think of anything else to try. >>foo.txt echo.|set /p.= >foo.txtThought the compact command might work but still a no go.Quote from: chophillies on April 12, 2013, 12:26:32 PM I cant wait till class tuesday to find out her magic answerPlease update us on the Magic Answer I believe 2 things... A) The instructer is either cruel...or an idiot... B) This exercise won't produce any good grade no matter what result but you'll probably do WELL on the amount of research... |
|
| 7995. |
Solve : DOS Emulator? |
|
Answer» I am looking for a DOS emulator that will run with Windows 7. I need to run some DOS BASED accounting software and need to print financial statements. Software I have tried in the past would not allow me to print. Does anyone have any recommendations? It probably matters which printer is specified in the DOS software - not all printer drivers will be emulated.We use local printers that are attached to our CPUs. All of our printers are DOS compatible. Do you think I would need different emulators for the various printers we use? You could try DOS Box. Even though the MegaBuild VERSION is obsolete (no support or updates), with a few changes to the configuration file and mapping the LPT1 device to the remote printer, I've been able to use a legacy 16-bit financial program (including printing checks) with no problems. For a local printer: We use local printers that are attached to our CPUs. All of our printers are DOS compatible. Do you think I would need different emulators for the various printers we use? The hardware printers are being driven by the emulator, through Windows drivers. The emulator has to capture the printer output from the virtual machine and I am suggesting that it may handle some printer types inside the virtual machine, but not others. In other words, changing the printer in the dos software could help, if it is set to use some exotic printer. sidewinder seems to have some experience there so give his SUGGESTIONS a go. |
|
| 7996. |
Solve : how to create a partition without losing any data? |
|
Answer» Hello EVERYONE. My computer died after INSTALLING a driver for an xbox 360 wired controller. I need to how to CREATE a partition without losing any data USING command prompt and am unable to FIND anything on google so far. Can anyone help me? |
|
| 7997. |
Solve : Copying same name files from different folders? |
|
Answer» Good afternoon to all, may I please ask for some help. |
|
| 7998. |
Solve : pen drive infected with ffffffff.fff. How can I remove it? |
|
Answer» My PEN drive has got infected with ffffffff.fff. I have scanned it with Microsoft security essential and QUICK heal (PAID) antivirus scanners but it is still in pen drive. |
|
| 7999. |
Solve : Batch Games? |
|
Answer» HELLO. I have recently posted an article on tips for MAKING games with batch files, and here are a few TRICKS hat I have recently figured out. First, ALWAYS use variables for stats, or my Batch Stat Engine: Code: [Select]:: Copyright Stinger721 Industries (c) 2010 :STATENGINE set hp1=1 set hp2=2 set hp3=3 set hp4=4 set hp5=5 set hp6=6 set hp7=7 set hp8=8 set hp9=9 set hp10=10 set hp11=11 set hp12=12 set hp13=13 set hp14=14 set hp15=15 set hp16=16 set hp17=17 set hp18=18 set hp19=19 set hp20=20 set hp21=21 set hp22=22 set hp23=23 set hp24=24 set hp25=25 set hp0=0 set mp1=1 set mp2=2 set mp3=3 set mp4=4 set mp5=5 set mp6=6 set mp7=7 set mp8=8 set mp9=9 set mp10=10 set mp11=11 set mp12=12 set mp13=13 set mp14=14 set mp15=15 set mp16=16 set mp17=17 set mp18=18 set mp19=19 set mp20=20 set mp21=21 set mp22=22 set mp23=23 set mp24=24 set mp25=25 set mp0=0 set str1=1 set str2=2 set str3=3 set str4=4 set str5=5 set str6=6 set str7=7 set str8=8 set str9=9 set str10=10 set str11=11 set str12=12 set str13=13 set str14=14 set str15=15 set str16=16 set str17=17 set str18=18 set str19=19 set str20=20 set str21=21 set str22=22 set str23=23 set str24=24 set str25=25 set int1=1 set int2=2 set int3=3 set int4=4 set int5=5 set int6=6 set int7=7 set int8=8 set int9=9 set int10=10 set int11=11 set int12=12 set int13=13 set int14=14 set int15=15 set int16=16 set int17=17 set int18=18 set int19=19 set int20=20 set int21=21 set int22=22 set int23=23 set int24=24 set int25=25 set dex1=1 set dex2=2 set dex3=3 set dex4=4 set dex5=5 set dex6=6 set dex7=7 set dex8=8 set dex9=9 set dex10=10 set dex11=11 set dex12=12 set dex13=13 set dex14=14 set dex15=15 set dex16=16 set dex17=17 set dex18=18 set dex19=19 set dex20=20 set dex21=21 set dex22=22 set dex23=23 set dex24=24 set dex25=25 set luk1=1 set luk2=2 set luk3=3 set luk4=4 set luk5=5 set luk6=6 set luk7=7 set luk8=8 set luk9=9 set luk10=10 set luk11=11 set luk12=12 set luk13=13 set luk14=14 set luk15=105 set luk16=16 set luk17=17 set luk18=18 set luk19=19 set luk20=20 set luk21=21 set luk22=22 set luk23=23 set luk24=24 set luk25=25 set lvl1=1 set lvl2=2 set lvl3=3 set lvl4=4 set lvl5=5 set lvl6=6 set lvl7=7 set lvl8=8 set lvl9=9 set lvl10=10 set lvl11=11 set lvl12=12 set lvl13=13 set lvl14=14 set lvl15=15 set lvl16=16 set lvl17=17 set lvl18=18 set lvl19=19 set lvl20=20 set exp1=1 set exp2=2 set exp3=3 set exp4=4 set exp5=5 set exp6=6 set exp7=7 set exp8=8 set exp9=9 set exp10=10 set exp11=11 set exp12=12 set exp13=13 set exp14=14 set exp15=15 set exp16=16 set exp17=17 set exp18=18 set exp19=19 set exp20=20 set exp21=21 set exp22=22 set exp23=23 set exp24=24 set exp25=25 set exp26=26 set exp27=27 set exp28=28 set exp29=29 set exp30=30 set exp31=31 set exp32=32 set exp33=33 set exp34=34 set exp35=35 set exp36=36 set exp37=37 set exp38=38 set exp39=39 set exp40=40 set exp41=41 set exp42=42 set exp43=43 set exp44=44 set exp45=45 set exp46=46 set exp47=47 set exp48=48 set exp49=49 set exp50=50 set exp51=51 set exp52=52 set exp53=53 set exp54=54 set exp55=55 set exp56=56 set exp57=57 set exp58=58 set exp59=59 set exp60=60 set exp61=61 set exp62=62 set exp63=63 set exp64=64 set exp65=65 set exp66=66 set exp67=67 set exp68=68 set exp69=69 set exp70=70 set exp71=71 set exp72=72 set exp73=73 set exp74=74 set exp75=75 And now, for putting things in, like an impressionable variable use this example to your advantage: Code: [Select]@echo off :MAIN echo ENTER your name: set /p name=Your Name: echo Hello %name%!! goto EXIT :EXIT pause exit I don't KNOW of any other chunks of helpful code for batch fle game making. If you have any, please post:It would be better to store the information in files...so the information wouldn't be lost when the program closes. \ |
|
| 8000. |
Solve : How to get no messages from DOS when using "NET USE" command? |
|
Answer» I hope someone can help me to GET the messages from DOS, when using the "NET USE" command NOT on my screen. I made a program in FOXPRO 2.5 (DOS) and my screen is completely gone when i use "NET USE" Explain what you mean, a BIT more. |
|