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.
| 1701. |
Solve : Need Help Creating a Simple Batch File? |
|
Answer» Hello everyone! Hello everyone! Well, I'm not sure if I know what you mean but I'll try: Code: [Select]echo off cd C:\Documents and Settings\Owner\Cookies start mydirfile.txt exit I don't think this would exactly help your problem, but why don't you install a keylogger, or a screen recorder? Use google, if you don't like the links I provided. PS. Why don't you guys jsut answer him. It doesn't matter what it's for. He's just requesting help.Thanks, Mr. Google! I worked with your coding till I got something that worked: echo off cd C:\Documents and Settings\Owner\Cookies dir >c:\mydirfile.txt exit My next question: I'd like to insert the "sleep" command and "goto start" at the end. If I enter "sleep 1", the txt file will be overwritten every second. But --- I don't want to overwrite, I want to store additional iterations of the text file for each loop - per second, minute, hour or whatever. I figure I may need an "IF" statement that will recognize "c:\mydirfile.txt" already exists and so store a renamed file such as mydirfile1.txt on the c: drive. Once again, I'm clueless about the coding. I can barely manage VBA. Thanks!No problem. I'm not too sure about you next question as I am not to advanced with batch coding, but I think you'll have to do something with a variable like %dirfile%+1 or something although I'm not sure how to do that. Maybe someone else COULD help. Sorry...why are you doing this the "hard" way? I am sure you have Internet proxy server logs , or software that logs internet connections in place?I work for a large federal agency - not the CIA, NSA or anything like that. We help people. As I explained earlier, our agency (bureaucracy) is rigid when it comes to internet tracking. Each office has a server. If the server has a "proxy server log" I don't know what it is or where to find it. At the national level, the agency keeps repeating the mantra about "proper use" of government property. Management at a more local level is more proactive - showing zero tolerance for time-wasting personal surfing. Problem is at the local level we don't have the tools for monitoring - so we invent them. I created an Access-based program that filters cookie text files for apparent patterns of abuse. It's a crude instrument. The question has come up about what to do about employees who routinely delete their cookies before they can be collected and analyzed. So I see the batch file monitoring tool as a supplement to the filtering program - to be used only for cases in which we suspect there's more personal internet use going on than what the cookies suggest. Anyway I didn't get into computers until Windows 95 - so I find batch files intriguing.Another approach would be to write a monitor script (VBScript) that would fire each time a cookie is created in the cookie directory. Quote I created an Access-based program that filters cookie text files for apparent patterns of abuse When the script FINDS a new cookie (file) in the directory, your Access program could be started to do the analysis. VBScript is a subset of VBA, so the transition would be fairly simple. |
|
| 1702. |
Solve : %ERRORLEVEL% IS FROZEN in extended commands within parentheses? |
|
Answer» Hi |
|
| 1703. |
Solve : about COM1 and LPT1???? |
|
Answer» Can anyone GIVE me the command to change the COM1 to LPT1? You can try the mode command:I'm obviously confused Could you explain exactly what it is were talking about? I thought the poster meant changing folder names to change what LTP and the COM ports did, which, certainly isnt possible by the dir command. Quote Can anyone give me the command to change the COM1 to LPT1? I interpreted this to mean the OP WANTED to swap devices. COM1 and LPT1 are reserved device names and cannot be used as file/folder names. whoops i tried that and Mode LPT1=COM1 actually works(runnin Win 2K) but i dont no how to undo it. Help would be apreciated |
|
| 1704. |
Solve : call batch files from within their root [solved]? |
|
Answer» I have several batch files NESTED inside of several folders that I need to execute in a certain sequence. I have created a single batch file to call these nested batch files. This works in that it launches the nested batch files in the order I want, USING the simple call command. The problem is that the batch files execute from the LOCATION of the calling batch file. I need so that each batch file would execute from his own root location. |
|
| 1705. |
Solve : How to count...? |
|
Answer» How do you count the files in a map with of course MS-DOSI'm guessing that map REFERS to a directory. Sidewinder uses that old DOS CALL thing but you can get modern like this Actually it has more to do with variable scope. Variables declared after a setlocal remain in scope until an endlocal statement or the end of the batch file, whichever comes FIRST. By not USING a setlocal statement, variables remain in scope until the shell window is closed. |
|
| 1706. |
Solve : batch file, to see if file/folder exist? |
|
Answer» hey all.. lol guilty until proven inocentYep Try this: Code: [Select]echo off if exist "C:\file.ini" ( echo. File Exists pause exit ) else ( echo Random Text >>"C:\file.ini" exit ) You may have to adapt the code though. |
|
| 1707. |
Solve : Basic loop with choice issue? |
|
Answer» Hey guyz, |
|
| 1708. |
Solve : GET the values from ini file? |
|
Answer» Hi, |
|
| 1709. |
Solve : Defragment batch file help plz!!? |
|
Answer» Hi guys and thanks in advance! |
|
| 1710. |
Solve : batch file find by date? |
|
Answer» I see a bat file that returns a date.... I see a bat file that returns a date The format of the date will determine how to write the batch code. This snippet is designed for DOW mm/dd/yyyy Code: [Select]echo off set dow=%date:~0,3% set dowf=weekend if %dow%==Mon set dowf=Monday if %dow%==Tue set dowf=Tuesday if %dow%==Wed set dowf=Wednesday if %dow%==Thu set dowf=Thursday if %dow%==Fri set dowf=Friday if exist c:\banner\%dowf%\file copy /y file c:\banner\%dowf%\file You'll need to change any references to file. Good luck. Bad luck if your local settings don't use US date format! (There are a few billion people who don't.) My European locale just has a date like this 03/08/2008. No day of the week string. |
|
| 1711. |
Solve : Simple DOS command... take a sec? |
|
Answer» Any remember the COMMAND you use to bring up ADMIN tools? |
|
| 1712. |
Solve : Hosts file Help? |
|
Answer» I did not know where to postt this, but I will post it here.... I want to know if it's possible to create some sort of file(batch or whatever) that can configure the hosts file in a certain way when you open it. Like a file that blocks a certian site when you run it, and then another one which allows the site again, when you run IT... Wow Mr. Google, Wise words from Khasiar. This boy will GO far i hope soAlso I should be humble and remember that we answer questions not just to help and inform the original poster but also anyone else who has a similar problem or is just curious. So. The Hosts file in Windows is a text file. Each line contains an IP address and a host name, in that order, separated by at least one space. Example: Code: [Select]212.140.189.10 www.tesco.com When a request to connect to a host name is made by a program for example a WEB browser, or any other other program, the system looks first in the Hosts file and if the host name is found, the IP address on that line is used. If it is not found, then a DNS lookup is performed. If it is desired to block a particular site, then that host name can be given the IP address of LOCALHOST, the local computer, which is always 127.0.0.1 Code: [Select]127.0.0.1 www.blocked-site.com Now any attempt to read www.blocked-site.com will result in an error page. There is the possibility that malicious editing of the Hosts file could redirect traffic from a desired site to another one. This is why many security applications protect the Hosts file and monitor attempts to alter it. Quote from: Dias de verano on August 03, 2008, 02:49:53 AM Also I should be humble and remember that we answer questions not just to help and inform the original poster but also anyone else who has a similar problem or is just curious. I thought it was 0.0.0.0 that's what I use. I know a little about batch scripts. And yes, my sucurity programs do monitor it. So, I'll give this code a try: Code: [Select]echo off echo 0.0.0.0 www.facebook.com >> hosts exit I have a feeling this isn't quite there yet. Quote from: Mr. Google on August 03, 2008, 09:09:30 AM
127.0.0.1 is the local machine, and using it as a block address in the Hosts file is the normal way. 0.0.0.0 is a "nil host" address and works just as well. Quote I know a little about batch scripts. And yes, my sucurity programs do monitor it. So, I'll give this code a try: It adds a host to be blocked, but how to remove it? something like this maybe Remove a host from hosts file syntax batchfile hostname e.g. call it unblock.bat & use it thus: unblock www.hostname.com Code: [Select]echo off cd /d c:\windows\system32\drivers\etc if exist hosts2 del hosts2 type hosts | find /v /i "%1" > hosts2 copy /y hosts2 hosts I'm not quite sure if I understand that... Quote from: Mr. Google on August 04, 2008, 09:00:41 AM I'm not quite sure if I understand that... I was afraid of that. If you do not understand that code, you should not be poking around in system folders. Quote from: Dias de verano on August 04, 2008, 11:04:38 AM Quote from: Mr. Google on August 04, 2008, 09:00:41 AMI'm not quite sure if I understand that... *ignore comment* |
|
| 1713. |
Solve : Starting a DOS program from an icon on the desktop? |
|
Answer» I have been able to conveniently start a DOS program from a DESKTOP icon. Immediately after installing Norton ANTIVIRUS, the icon did not work the same way. Here is the command line for the icon. C:\486\M90\max.exe d:\imp.fix But the program now loads another file other than the requested imp.fix. What went wrong and what could I do to return it to its earlier STATE? THANK you very much. My best advice is to uninstall Norton (see here) and install any one of Avira, Avast or AVG.8 free antivirus programs. Good luckCheck the Norton's logs and see if your program is listen in any way. Norton may have denied ACCESS. |
|
| 1714. |
Solve : Search and Destroy? |
|
Answer» I am looking to make a SCRIPT that looks for a specific FOLDER in all of the user profiles on a device and removes the specified folder. How would I do this or does anyone have something LIKE this already?What are you wanting to do exactly?Something like this? |
|
| 1715. |
Solve : Environment Variable Substitution.? |
|
Answer» Win XP SP.2 lol, thats my code, i was working on name translator to Japan language. Typical of me, unravelled the mystery about ten seconds after posting my query and knowing how deleting ones own posts is frowned upon decided to let it run. Can't remember why I would have saved your file but thank you for your code Devcom and if you've had experience in auto translating Katakana Morse code to display in Roman FONT in any version of Basic I'd like a few pointers. To solve my query I amended the script to give the output below: Quote Name entered = A V.. Code: [Select]echo off :MAIN set spa=0 set num=0 set /p fullname=Enter name: :LOOP call set tmpa=%%fullname:~%num%,1%% set name=%tmpa% if '%name%' equ '' goto FIN :SET if '%name%' equ 'a' set name=ka& goto END if '%name%' equ 'b' set name=tu& goto END if '%name%' equ 'c' set name=mi& goto END if '%name%' equ 'd' set name=te& goto END if '%name%' equ 'e' set name=ku& goto END if '%name%' equ 'f' set name=lu& goto END if '%name%' equ 'g' set name=ji& goto END if '%name%' equ 'h' set name=ri& goto END if '%name%' equ 'i' set name=ki& goto END if '%name%' equ 'j' set name=zu& goto END if '%name%' equ 'k' set name=me& goto END if '%name%' equ 'l' set name=ta& goto END if '%name%' equ 'm' set name=rin& goto END if '%name%' equ 'n' set name=to& goto END if '%name%' equ 'o' set name=mo& goto END if '%name%' equ 'p' set name=no& goto END if '%name%' equ 'q' set name=ke& goto END if '%name%' equ 'r' set name=shi& goto END if '%name%' equ 's' set name=ari& goto END if '%name%' equ 't' set name=chi& goto END if '%name%' equ 'u' set name=do& goto END if '%name%' equ 'v' set name=ru& goto END if '%name%' equ 'w' set name=me& goto END if '%name%' equ 'x' set name=na& goto END if '%name%' equ 'y' set name=fu& goto END if '%name%' equ 'z' set name=zi& goto END :END set /a num+=1 set exname=%exname%%name% goto LOOP :FIN echo Translated name: %exname% set exname= pause >nul cls goto MAINthis is how ive done this ofc it could be better coz i WROTE it in 10 min Took me 5 min 1. replace.txt (store in same folder as batch, or else use full path and filename in batch) Code: [Select]a,ka b,tu c,mi d,te e,ku f,lu g,ji h,ri i,ki j,zu k,me l,ta m,rin n,to o,mo p,no q,ke r,shi s,ari t,chi u,do v,ru w,me x,na y,fu z,zi 2. Translate.bat Code: [Select]echo off set /p fullname=Enter name: for /f "tokens=1,2 delims=," %%A in (replace.txt) do if /I "%%A"=="%fullname%" set name=%%B echo %name% nah, i think i will never do this in this way you are the master peace! |
|
| 1716. |
Solve : BAT LOG FILE? |
|
Answer» hi im TRYING to log all the results in a bat file but i cant get it right anyone can help me pls echo.>>BackupLog.txt I'll GIVE you a hint, you're creating backuplog.txt if it doesn't exist and TELL it to create a new LINE. Here is another hint, echo.>>Backuplog.txt will just create a blank text file called Backuplog. Another hint on top of that, if you do echo. Hello>>backuplog.txt, you will get a text file with the word Hello in it.and another hint > creates the file if it does not exist, and overwrites the file if it does exist. >> creates the file if it does not exist, and appends to the file if it does exist. Crucial difference. |
|
| 1717. |
Solve : Recognize CD ROM from MSDOS - My driver works ok in Windows? |
|
Answer» Hi Setup cannot run from within Windows NTThat's it. In order to install 98, you have to boot to Win 98 CD. Check boot order in BIOS. It should read: - floppy - CD ROM - hard driveBoot order in BIOS is FLOPPY HARD DRIVE There is no CD ROM listed. The CD ROM works fine when running Windows but the computer doesn't recognize it in MS DOS. Does the computer not recognize it because it is an external drive connected via a USB port ? If so, how do I get the computer to recognize the CD ROM from Ms Dos?The problem you will have first of all is your 2000 being NTFS, Windows 98SE will not be able to be installed to a NTFS partition. If your Windows 2000 is installed to a Fat32 partition then Windows 98 installed to the drive can be done but, you will have an issue with your Boot loader. Your Boot.ini file will have to be edited to reflect a choice of Windows 98 or 2000, as well as your config.sys and autoexec.bat will also have to be edited likely. If you want to tombstone 2000 and run only in 98 then you should be fine as long as FAT32 is your partition type. Its harder to install a backwards OS then a forwards OS for Windows. You could potentially install Windows 98 without need of the CD Rom by creating a folder such as Win98CD on your C: drive with Windows 2000 and 2000's CD Rom support ( will only work if your C drive is FAT32 ). You will have to copy all contents including hidden files from the CD to your hard drive to this folder. Then use a bootable floppy to have access to C: and trick Windows install into believing that the install will be from a prior OS like DOS 6.22 or Win 95. Windows 98 will not know what winnt folder is and will skip over it. You can then navigate to the C:\win98CD folder and execute the setup.exe from there and install Windows 98 from a local hard drive install onto itself. It gives the HD a work out since it is reading and writing all the data, mostly decompressing cab files etc and INSTALLING. In the end your SYSTEM will likely boot up in Windows 98 mode only and you will then have to manually edit the boot.ini file to see a choice of Windows 2000. If you are no expert working with Boot.ini editing you could run into problems. You also could potentially crash your system if soemthing goes wrong, so I would back everything up. It can be done if you are Fat32, but cant be done if you are NTFS without resizing the NTFS partition and creating a Fat32 partition or installing a second HD, which is not an option since this is a laptop. Wow! Thank you for the indepth explanation, I really appreciate it. This computer originally came with Windows 98 and someone upgraded to 2000NT somewhere along the way. If, when the computer is booting up, and I am fast enough, I can press the down arrow and enter, I go to the original operating system instead of booting up into 2000NT. I get a message that says,"The following file is missing or corrupted: RAMDRIVE.SYS there is an error in your CONFIG.SYS file on line 6" And then I am in MSDOS and at C: drive. Do you think I can just re-install the RAMDRIVE.SYS folder and get win98 to come up ? I was just in the process of transferring the Win98 files from the CD ROM to the c: drive when I read your posting. Because I was thinking that I should be able to access the Win98 files from MSDos if they are on the hard drive. I am quite willing to wipe the drive clean with my Stompsoft Drivewasher program and reinstall Win98 from the CD ROM except, like I said, the computer doesn't recognize a CD Rom from the Bios. I don't know what NTFS is but I will research it and learn. I know that my file systemis FAT32 and I can see the WinNT folder under the program files. I have no problem not running 2000 anymore and will be happy to run only 98. How can I access the Win98 folder on C drive when I am in MSDOS ? If I type "Win98" I get an error Thank you again for your help.Since I'm so confused, maybe I should approach this from a different angle. I would like to wipe the drive clean with my drive washer program. Since the computer doesn't recognize the CDROM drive now when I'm in MSDOS, how will I be able to install Windows 98 from the CD ? It probably won't recognize the CDROM then either. Is there another way to transfer the Win98 files to a freshly-wiped hard drive ? Quote from: surfnut Boot order in BIOS is Does the notebook have a physical floppy drive? No. There is no floppy drive in the computer. I do have an old 3.5" external floppy drive somewhere in the basement but it connects via a USB port just like the CDROM so I don't know if the computer will read it when in MSDOS. No wait. I think the external 3.5" drive I have connects via a COM port. I will have to dig it out to make sure. Regardless, there are no drives at all in the computer.First let's lay the GHOST of what you are calling MS-DOS. When you use Start>Run>Cmd you are NOT starting MS-Dos, you are starting the Dos emulator program (commonly called Command Prompt) which is part of the Windows NT system . No NT version of Windows contains MS-Dos. The screen you see when using the Dos emulator is just another Window although you can enter MS-Dos style commands (and a lot more), you are still running in Win.2k. Thats why you get the message: Quote "Setup cannot run from within Windows NT. Shut down WIndows NT and start MS DOS. RUn setup from the MSDOS command prompt." Now to the floppy drive. If you can get the the floppy drive to work in Win.2k it just might be possible to get it and the cdrom to perform by using a Win.98 floppy boot disk which will load a cdrom driver - it's a big might but a remote possibility that your bios can be set to boot from a usb floppy drive! If your floppy drive will perform can you use the notebook to download a Win.98 boot disk image and write it to a floppy drive or do you have access to another pc which will do this? Sorry about being so verbose...Verbose is good. I need all the help I can get. Assuming I can get the floppy drive to work, When you say "Win.98 boot disk image" do you mean the Win98 files from the Win98 CD? IF so, does a floppy disk have enough memory to hold all the files ? If not, which files do I put on the first floppy disk, and then which files do I put on the second disk, etc.. If the floppy disk will perform, I'm sure I can use the computer to transfer files from the Win98 CD to the 3.5" floppy. Assuming that, how do I get the computer to use the Win98 floppy boot disk to load the CDROM driver as you wrote ? Quote from: Surfnut When you say "Win.98 boot disk image" do you mean the Win98 files from the Win98 CD? No, the boot disk image will be downloaded from bootdisk.com and the boot disk will be created from the image. This will require just one blank formatted floppy disk. If it is possible you will boot MS-Dos from the bootdisk which will be in the usb floppy drive. Native MS-Dos does not have usb support so it will be necessary for you to download usb drivers for Dos from bootdisk.com as well, see here.. But first you need to find out if the floppy drive will work. Note there are lots of mights and ifs. Please post the model number of your notebook.It is a Fujitsu Lifebook B-2130. Cancel all bets... I downloaded the B-2130 Users Guide from here and suggest you do the same if you no longer have the printed version which came with the notebook. This confirmed that the floppy drive is NOT to connect to a usb port but via the com port on the connector box which makes a b-i-g difference. (Manual Sect.4 p.50) Before proceeding I now need details of your hard drive, how many partitions there are and what the file system is. So boot to Win.2k, open My Computer, R.click each partition (drive C etc) choose Properties and you'll find the file system there. Also still need to know if the floppy drive is working and if you have the original Win.98 cd which came with the notebook. I think I'm out of luck. The floppy disk drive I have is not for this computer and will not physically connect to the Fujitsu's COM port. It goes into a port that is kind of like a USB-sized port only a bit wider. There is an A; drive and a C: drive listed under My Computer. I don't know why A: drive is listed there because there is no A: drive there. C: drive is FAT32 The Win98 Cd I have is not the original cd. I bought it off EBAY. It came with the manual and the Microsoft Certificate of Authenticity and product key. |
|
| 1718. |
Solve : " Disk I/O Error "? |
|
Answer» I'm USING Win98. |
|
| 1719. |
Solve : Move batch command with no replace if filename exists?? |
|
Answer» I have a DOS batch file that moves files from one directory and sorts them into separate folders alphabetically. The problem is existing files GET replaced. I know I can add the -y SWITCH to be prompted but there's too many prompts. Does anyone know how I can skip if file exists automatically or better yet, rename it? I don't see that option anywhere in dos move command. Was wondering if I can use the "IF" variable somehow. Like IF exists skip or no replace etc. Can't find answer anywhere on web. TIA any help. Here is an excerpt from my batch file: well i have that option Where? Quote from: gitman7 I know I can add the -y switch to be prompted but there's too many prompts. Quote from: gitman7 That's the problem I'm having. Move command doesn't have an option to skip if filename exists. You have the options /Y to overwrite existing files without asking /-Y to ask for permission to overwrite but nowhere that I can see is an option to simply skip files that already exist. My code above will skip if a destination file already exists. exactly. there has got to be a way I WOULD think to put an "IF EXIST" command in there somehow. For example if the filename exists then enter "n" keystroke so I don't have to respond to every prompt or just skip the move command if filename exists. Quote from: gitman7 on July 25, 2008, 12:06:49 PM exactly. there has got to be a way I would think to put an "IF EXIST" command in there somehow. For example if the filename exists then enter "n" keystroke so I don't have to respond to every prompt or just skip the move command if filename exists. did you see the batch file I posted above? YES but I don't understand it at all - way over my head What is %%F? and I don't understand this: setlocal enabledelayedexpansion or any of the rest of it for that matter. sorry. I'm not giving up tho I'm doing some web searching on that right nowWhat should my batch file look like if I wanted to move all the files from C:\BIN to C:\BIN\a\ C:\BIN\b\ C:\BIN\c\ etc. where the first letter of the file matches the letter folder without overwriting existing files in those directories? Quote from: gitman7 on July 25, 2008, 02:10:37 PM What should my batch file look like if I wanted to move all the files from C:\BIN to C:\BIN\a\ C:\BIN\b\ C:\BIN\c\ etc. where the first letter of the file matches the letter folder without overwriting existing files in those directories? Code: [Select]echo off setlocal enabledelayedexpansion for %%D in (a b c d e f g) do ( for /f %%F in ('dir /a-d /b s:\bin\%%D*.*') do ( set src=s:\bin\%%F set dest=s:\bin\%%D\%%F echo Source file: !src! if not exist "!dest!" ( echo Moving !src! to !dest! move "!src!" "!dest!" ) else ( echo !dest! already exists ) ) )Thanks for that! I'm going to study it and try to figure it out. Don't know what the do ) means or the set src=s: what is the s for? and do I need every letter of alphabet in this: (a b c d e f g) ? My actual source directory is L:\!Temp all And my destination folders are L:\!TLF\!, L:\!TLF\0, L:\!TLF\1-9, L:\!TLF\a, L:\!TLF\b, etc. up through every letter of the alphabet. So all files that begin with "a" GO into the "a" folder etc. I'm trying to rewrite your batch so it works here but can't quite figure it out. Quote from: gitman7 Don't know what the do ) means Those are loops. Quote from: gitman7 or the set src=s: what is the s for? Sorry I was trying it out on my computer on drive s. I forgot to change it. Below is correct code. Code: [Select]echo off setlocal enabledelayedexpansion for %%D in (a b c d e f g) do ( for /f %%F in ('dir /a-d /b c:\bin\%%D*.*') do ( set src=c:\bin\%%F set dest=c:\bin\%%D\%%F echo Source file: !src! if not exist "!dest!" ( echo Moving !src! to !dest! move "!src!" "!dest!" ) else ( echo !dest! already exists ) ) ) Quote from: gitman7 and do I need every letter of alphabet in this: (a b c d e f g) ? Well, you know that better than I do. Thanks man! what does the %%D mean? and the %%F? |
|
| 1720. |
Solve : Administrator: cmd.exe box and C:\windows\system32> prompt? |
|
Answer» Well this is what I see when I boot up the computer. Just a blinking DOS prompt after C:\windows\system32> |
|
| 1721. |
Solve : Batch file to check file size then rename? |
|
Answer» I am currently trying to create a batch file to rename a log file to if it exceed 200kb. can anyone help me out. |
|
| 1722. |
Solve : Semi-Adv questions. HELP!!? |
|
Answer» How do i get the batch file to support the drag and drop feature? Like, i want to be able to drag a file on to the batch and then it executes something like this: I mean when I drag a file on to the batch, I want it to be set as %smc% so I can use it like do you mean grab the file with you mouse and drop it onto the batch program. then no you CANT do that. Batch files are not capable of detecting mouse clicks or movement. Quote from: macdad- on August 07, 2008, 01:41:58 PM do you mean grab the file with you mouse and drop it onto the batch program. then no you cant do that. Batch files are not capable of detecting mouse clicks or movement. Macdad, do you ever check before you write? I really WISH you WOULD start doing that. It's not hard. The rest of us do it. If you don't, it's called "running your mouth", I think, in American English. It is not helpful on a forum like this. Create a batch file with this code in it Code: [Select]echo off echo %1 pause 1. Save it to a folder. 2. In Windows Explorer, drop a file or a folder onto it. 3. Tell us what happens. oh cool! it shows the file thanks!! Quote from: kaiyoken on August 07, 2008, 02:29:51 PM oh cool! it shows the file There you go... Dias 1 Macdad 0 ok, now I have a problem. when I drag the file over it works and all, but the directory is reset. meaning is no longer the current folder it set to "c:\documents and setting\user" instead PLEASE show your code Dias when i read this Quote How do i get the batch file to support the drag and drop feature? Like, i want to be able to drag a file on to the batch and then it executes something like this: i thought he ment grabbing the file from a folder and drop it on the batch window while it was running. so sorry for being a chatter box Quote from: macdad- on August 07, 2008, 04:17:16 PM i thought he ment grabbing the file from a folder and drop it on the batch window while it was running. Well, you're right there, you can't do that. here is my old one that works: echo off FOR /F "tokens=1*" %%G IN ('dir /b *.smc') DO Set smc=%%G If [%smc%]==[] goto filenotfound bin\movlm.exe %smc% bin\cutdrv.exe %smc% bin\cutsnd.exe %smc% pause goto end and here is the one im trying to make work >.> set %1 If [%1]==[] goto autofind goto process1 ---other part of code removed--- :process1 cls cd echo ===== cutting ===== bin\makesnd.exe %1 bin\importsnd.exe %1 echo ===== ------- ===== ping localhost -n 2 >Nul pause goto complete the line set %1 does nothing. What are you trying to do? You cannot "set" %1. It ALREADY has a value. hey i've posted first the example of dnd Code: [Select]set var=%1 If [%var%]==[] goto autofind goto process1 |
|
| 1723. |
Solve : Batch Rename Files? |
|
Answer» 01-06-20080559100001.002 <?php thats how i did it with php. there is alot of extra stuff in that script. hopefully someone knows howto do it in dos.Did you use that PHP script to change files on a web server? Or a home server?i uploaded files to the sever and it would rename them all at once. but now i need to be able to rename files on different pcs when im onsite. so i cant just install easy php for example on the pc to rename the files. a batch file would be perfectA batch script can make your LIFE easier and your codes more smaller. Or you can use vbscript to do that for you. id love a batch script. PROBLEM is i have NO idea how to make it. im good with php and bash. not dosThis batch script will probably do it. To rename the files remove the :: on the Ren line after testing to ensure it will do what you want. I have only tested it using six filenames. You will also have to reset the in_file variable to suit your source directory. Note: The code does not cater for space(s) in the path\filename, the Ren command will fail. Good LUCK Code: [Select]echo off cls setlocal set in_file=d:\temp\badname\ for /f "tokens=*" %%a in ('dir /b %in_file%') do call :rename %%a goto :EOF :rename set oldname=%1 set /a newdate=1%oldname:~0,2%-101 if %newdate% lss 10 set newname=0%newdate%%oldname:~2% & goto rename set newname=%newdate%%oldname:~2% :rename :: ren %in_file%%oldname% %newname% echo Old file name = %oldname% echo New file name = %newname% echo. |
|
| 1724. |
Solve : CMD configuration.? |
|
Answer» I seem to have ACCIDENTALLY change CMD's configuration.... |
|
| 1725. |
Solve : BOOT.INI FILE MISSING? |
|
Answer» to make a long story short. i deleted my boot.ini file. its in my recycle bin. i turned computer off and now have seemed to of lost everything. i cant get back into windows 98 and i have access to dos. can i open windows 98 from dos? i am no computer expert but i have tried downloading boot files to no avail. helpAt DOS prompt, type in: |
|
| 1726. |
Solve : set a variable with the output of a command? |
|
Answer» OK, so in bash scripts, it is easy to do whatever you want with programs. if I want the date in the filename, i merely set the filename to be myfile-`date`.txt and the date is added. This is nearly impossible in batch scripting, but i have found out how. This is nearly impossible in batch scripting. What does "nearly" impossible mean? SOMETHING is either possible or it is not. In FACT, including the date in the filename is a trivial task in batch programming. my newest requirement is to have a multi-word command run, such as (for those who are familiar with SVN) svnlook author C:\Repositories\myproject This would output the name of the last person to check in code to myproject I'd like to have a variable with this name in it, such as set AUTHOR= svnlook author C:\Repositories\myproject That, of course, does not work. How can I MAKE it work?! [/quote] In general, we use the FOR command for this kind of thing. If the output of command is a line of text we get the whole line into a variable like this for /f "delims==" %%A in ('command') do set variable=%%A where A is one of a-z or A-Z thanks Dias de VERANO, i hadn't thought of doing it that way before. FB |
|
| 1727. |
Solve : Search for Files NOT OLDER THAN a Certain Date? |
|
Answer» Can anyone help with a command? I am trying to |
|
| 1728. |
Solve : Disc Drive? |
|
Answer» Is there a code that can open or close a DISC drive? Batch file or other?http://www.dreamincode.net/code/snippet92.htm thats visual BASIC though or you could go to start my computer and right click on your cd drive and click ejectprank? first remote shutdown, now open/close cd drive? not a prank, i just wanted to see if i could make a batch file (to run a program or code) to open and close my drives.I have done this before. Quote from: Carbon Dudeoxide on August 19, 2008, 06:36:48 AM Why.........? im not trying to play a prank on my friends, ive read past posts. im not goina make their drives open, close open, close open, close open, close open, close open, close open, close. if i wanted to do that, i'd dowload a simple program off Cnet. Im just looking for code for myself Quote from: qinghao on August 19, 2008, 06:40:12 AM Quote from: EchoLdrWolf316 on August 19, 2008, 06:35:22 AMhow? batch file, Visual Basic? or a DOS command line? Code: [Select]Option Explicitnot a prank, i just wanted to see if i could make a batch file (to run a program or code) to open and close my drives.I have done this before. Private Declare Function CDdoor Lib "winmm.dll" Alias "mciSendStringA" _ (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _ ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Select Case Button Case 1: Call CDdoor("SET CDAudio door open", 0, 0, 0) Case 2: Call CDdoor("set CDAudio door closed", 0, 0, 0) Case 4: End End Select End Sub this VB code I think you know how to use it .so.... Quote from: qinghao on August 19, 2008, 06:53:45 AM Code: [Select]Option Explicituhh? save as what? .................... Try google lol,, okDo you have Nero Burning ROM installed on the machine? Quote from: Dias DE verano on August 19, 2008, 01:18:16 PM Do you have Nero Burning ROM installed on the machine?I have a CD burner Do you, or don't you, have a CD burning package called Nero Burning ROM? |
|
| 1729. |
Solve : Batch Files - Re Posted from another Section? |
|
Answer» I have a Windows PC which cannot be connected to the internet. I have installed Symantec Anti Virus 10.1.5.5000 and want to install VD updates which I have downloaded from another machine which can be connected to the internet. copy x:\ *.* c:\Docume~1\alluse~1\applic~1\symantec\symant~1\7.5\ Quote It doesn't work! The syntax for your command is correct. How does is not work? Error messages? Is the drive letter for the CD the same on all 30 machines? One solution would be to put the batch file on the CD, along with an autorun file. The user would simply insert the disk and wait for the magic to happen. I'm not sure, but do you think Windows is prevent you from accessing 'alluse~1's folder?If it cant connect to the internet, why do you need anti-virus software? Is it on a network?You don't know who is GOING to be using the computers..... However, you have a point. It's not difficult to read... Quote I want to pass the CD around 30 non-networked work stations whose users have restricted permissions. the user might bring in a virus on USB CD's ETC... FB |
|
| 1730. |
Solve : How to extract a string from some text using a batch file.? |
|
Answer» I have some text in the form of drive:\folder1\folder2. I think that =%curdir:~-%n%% is wrong but don't know how to insert a variable inside the % signs. You can't. I won't be home for 8 hours to TEST this, but if you are actually logged in to %cd% as the current directory I think you could do a full DIR and using FOR with Find and appropriate tokens you could extract the folder name from the line which includes "Directory Of". Yes I am logged into %cd%. However, I don't understand "tokens" in a batch file and haven't used FOR before. I'll wait for you. No problem. Thanks I checked, you don't need tokens. You need to parse the output of the cd command. Used without PARAMETERS, it echoes the corrent folder's drive letter and PATH to the console. The %%~nx FOR variable modifier extracts just the final part, the folder name. Code: [Select]for /f "delims=" %%A in ('cd') do set foldername=%%~nxA Some more examples of extracting information about the current folder: 1. folder-info.bat Code: [Select]echo off for /f "delims=" %%A in ('cd') do ( set fullpath=%%A set driveletter=%%~dA set folderpath=%%~pA set foldername=%%~nxA set folderdate=%%~tA ) echo. echo ----------------------------- echo information about this folder echo ----------------------------- echo. echo Drive and path : %fullpath% echo Drive letter : %driveletter% echo Folder path : %folderpath% echo Folder name : %foldername% echo Folder date : %folderdate% echo. 2. An example of output Code: [Select] S:\Test\Batch\curdir>folder-info.bat ----------------------------- information about this folder ----------------------------- Drive and path : S:\Test\Batch\curdir Drive letter : S: Folder path : \Test\Batch\ Folder name : curdir Folder date : 20/08/2008 18:44 Thanks, That's simple and brilliant. Great solution to my problem |
|
| 1731. |
Solve : Find a string of text and wildcard text then copy it to the end of the same line? |
|
Answer» Could someone help me figure this out? I am trying to take the below text string and find in it 25701-Tract then copy that text to the end of the same line separating by comma, then taking the second date which is at the end of the text line JUN 23 2008 12:05 PM and CONVERT it to 06-23-08 and then move it also to the end of the text line after 25701-Tract separating by comma. |
|
| 1732. |
Solve : gobang? |
|
Answer» two player play it |
|
| 1733. |
Solve : How to Read and delete a character from a text file?? |
|
Answer» Hi FRIENDS, |
|
| 1734. |
Solve : taskkill windowtitle no longer works.? |
|
Answer» SINCE disabling UAC in vista, all my command windows now have the title Administrator: *title*. I used to USE the code: Code: [Select]taskkill /FI "WINDOWTITLE EQ *title*">Nul but that no longer WORKS, I've also tried Code: [Select]taskkill /FI "WINDOWTITLE eq Administrator: *title*">Nul and that doesn't work either. Does anyone KNOW what the title should be in order for taskkill to work? cheers FBLikely an error in the syntax, neither command works for me |
|
| 1735. |
Solve : Documentation error :- START ["title"] [/Dpath] [/I] [/MIN] [/MAX] [/SEPARATE |? |
|
Answer» Upon "Start /?" in a command line Windows XP responds with |
|
| 1736. |
Solve : Error Messages -- how to skip? |
|
Answer» When I copying some files I get an access denied message an my BATCH stops. How do I tell the batch to skip over the access denied and CONTINUE the copying? |
|
| 1737. |
Solve : QUERY: install boot disk/cd into C:\? |
|
Answer» Am wondering, you know those MS-DOS or Windows 98 boot disk/cd, can they copied/installed into C:\ and make C:\ bootable?Make C:\ Drive bootable? That's what happens when you turn on your computer. It uses the files in your hard drive to boot from. You have to have a genuine Microsoft install CD to install windows. That should have instructions on it on how to do that. FB: He/she wants to install Win98 instead of the current OS, correct?that's the way I see it. FBThe answer to the OP's question is "yes". 1. Set the computer to boot from CD 2. Boot up. 3. Using the DOS format command, format the C: drive 4 Copy the folder structure including all files and folder to the C drive 5. Using the DOS sys command, make the c: drive bootable with sys c: 6. Change boot order in BIOS to boot from hard drive. Thanks guys for your replies. Yes I totally FORGOTTEN about "sys c:" back from the oldskool DOS days. I believe sys command places io.sys & msdos.sys files in the first sector of the partition so that they get bootstrap LOADED on hard disk startup ... hence bootable. I think I now know how to create my own bootable CD from scratch... building the 1.44MB boot image and using a good cd builder app to load the boot image (MagicISO, Nero, etc.) |
|
| 1738. |
Solve : Priority inheritance after Start "" /LOW? |
|
Answer» I had to add this extra line of code to the start of a batch file :- My principle questions are, when the remainder of the script is executed at low priority which may be suspended when Windows thinks of anything (e.g. disk defrag) to fill up "idle" time, if this LOW priority script invokes DOS or Windows executables, is this low priority inherited by :- Batch files run at the same priority as the command shell. If you run your batch file in a shell window started by: Code: [Select]%comspec% /c start /low %comspec% you'll see in task manager that the command shell runs at low priority. Presumably so do all batch programs that utilize that instance of the shell program. Code: [Select]%comspec% /c start /low <path to started file> If a Windows program is started at the command line using the method above, it runs at the priority the user sets. If a Windows program is launched from the command line without being started, it runs at the priority the programmer wrote it for, unless the program has switches to modify the priority. I am not aware that Windows invokes defrag during idle. Is this a user setting? I do know the indexing service can run at idle, but many people turn off this "feature". Can you not use the sleep or ping command to kill 50 seconds? Thank you very much. I have previously used Task Manger to find out what was hogging the CPU and to kill the culprit, but I never saw, nor was aware of, the ability to see priority levels. After your advice I spent 5 minutes with Task Manager and found that View had the option to show the base priority level column. Now I can see for myself the consequences of my actions BEFORE they bite me in the rear ! You not only gave me a fish for today, you gave me the tools for fishing myself tomorrow !!! I may have used incorrect terminology when I said Windows runs defrag during idle time. This is my understanding of why the disc light on my laptop seems to randomly burst into action when I am doing nothing. The new to me column now shows me that 24 processes are running "Normal", 3 are "High" (why is winlogon.exe set "High" - surely I only need it when I log-on on at start-up ?), whist jqs.exe is "low" and DKService.exe is "Below Normal" - that is my defrag which I thought of as being "idle time". My START "" /LOW addition results in a delay whilst Windows is busy starting up. This typically is only 15 to 20 Seconds, but this last day and perhaps 8 start-ups I have seen delays of up to 50 Seconds when ESET NOD32 finds a fresh virus signature (which can be "giganormus") to install. There may be other situations tomorrow or next month that could require longer than 50 Seconds - and I dread to think what will happen when the next Patch Tuesday comes around !!! So holding off my script until CONCLUSION of the busy start-up is effective, involves minimal delay, and will wait for 50 or even 500 seconds when need arises. A fixed 50 second delay would often be excessive, but occasionally inadequate. Before I discovered START "" /LOW I did consider using SLEEP, BUT when I DOWNLOADED and saw sleep.exe was 124 KB I reconsidered. My first P.C. was a second hand deluxe model with the extra size 20 MEGABYTE hard drive. This established the criteria by which I judge the size of any download. Now I have been dragged screaming and crying out of DOS and into Windows I cannot shake off my upbringing that small is beautiful !!! As a matter of interest, just in-case I have a future need for a "sleep delay" without the burden of a 124 KB executable, how would I use PING, preferably without aggravating some innocent internet user who might retaliate - especially if I hit someone that has control of a zombie army !!! Just one detail remains - I tried to PREFIX a shortcut with "START /LOW" but it never worked - do I need a special syntax, or is this simply impossible ? Once again, many thanks. Alan Some users think ping is a kludge, but I find it keeps with the KISS method of coding. It also does not require a download: Code: [Select]ping -w 1000 -n 51 127.0.0.1 > nul The above code is for 50 seconds (the first ping is nearly immediate) Note: 127.0.0.1 is your local machine, no need to worry about retaliation. I couldn't get a shortcut to a batch file to work; shortcuts are pointer files that only seem to confuse the shell program. Perhaps you can start the program from it's home directory: Code: [Select]%comspec% /c start /low <path to program> Good luck Thank you for all your help. All my questions on this are now fully resolved. I have made a note of your ping delay code. I do not need it now but I am sure I will find a use for it soon. nb ping met a special need last year :- My broadband speed connection was very erratic http://myspeed.visualware.com/ has a super speed test - it not only gives numbers, it also gives graphs of instantaneous speed and delay, and these showed that when I had a bad connection, it was actually full speed for about 200 to 400 mSec about once a second. This gave me good ammunition against my ISP - but their first line Technical support still wanted me to re-check all my cables and telephone filters !!! Then I used DOS to launch a a prolonged burst of pings at 50 mSec intervals, simultaneously with the Windows Speed test, and the Speed test showed the same 500 to 800 mSec intervals each second of zero speed, whilst the ping replies just kept on happening without any loss or delay - clearly demonstrating "Traffic Management" that was affecting my TCP packet speed test, but allowing unrestricted ICMP packets without delay. Once again, many thanks Regards Alan |
|
| 1739. |
Solve : Batch Message? |
|
Answer» What is the code to make a message appear in a batch file, and what is the code to make it wait for a set amount of time?
Code: [Select]echo text Code: [Select]echo text both work perfect, but is there a way to make it wait without displaying anything..., and how do i make it change the title of the DOS windowchanging title is just Code: [Select]title "enter title here" if you've got the >nul the waiting code shouldn't PRINT anythnig to the screen. alternative ping wait: Code: [Select] ping -n 'No. of second' 127.0.0.1>Nul where 'No. of seconds' is replaced by the number of seconds you want to wait. It's not particuarly accurate though. FB Quote from: fireballs on August 25, 2008, 04:24:58 PM changing title is just Code: [Select]title "enter title here"ok, thanks works perfectly Code: [Select]echo off title Macilizer echo Macilizer starting... ping -n 1 -w 2000 1.1.1.1 >nul echo Initializing... ping -n 1 -w 500 1.1.1.1 >nul Choice /M "Do You Want To Run Mac Look-Alike PROGRAMS?" If %errorlevel% EQU 2 goto no If %errorlevel% EQU 1 goto yes :yes echo Starting Battery Meter ping -n 1 -w 2000 1.1.1.1 >nul start "" "C:\Program Files\Mioplanet Battery Meter\Mioplanet Battery Meter.exe" echo Starting Konfablator ping -n 1 -w 2000 1.1.1.1 >nul start "" "C:\Program Files\Pixoria\Konfabulator\YahooWidgets.exe" echo Starting Object Dock ping -n 1 -w 2000 1.1.1.1 >nul start "" "C:\Program Files\Stardock\ObjectDock\ObjectDock.exe" ping -n 1 -w 2000 1.1.1.1 >nul echo Exiting.... ping -n 1 -w 2000 1.1.1.1 >nul exit :no echo Exiting.... ping -n 1 -w 2000 1.1.1.1 >nul exit |
|
| 1740. |
Solve : FTP corrupts images?? |
|
Answer» When I try to upload an images to my website using the ftp command 'put,' the image Always turns out blank. |
|
| 1741. |
Solve : Batch script to check a result from a query.? |
|
Answer» I am trying to create a way to check the result of a query. |
|
| 1742. |
Solve : Copy folders in a batch? |
|
Answer» I am trying to use a bat to backup some folders but it won't copy the folders, only the loose files in the main folder. How do I do this? "I had a discussion with George about new people walking by my office.doc" Xcopy will fail to copy a file if either the source or destination path and filename is, in total, more than 255 characters long. That lady needs educating. Sorry windows 2000 and yes I am working on getting her to shorten the names and not to use SYMBOLS (#$,&) she is getting there. Quote from: sukieb on August 23, 2008, 05:54:48 AM I am working on getting her to shorten the names and not to use symbols (#$,&) she is getting there. Symbols are BAD NEWS especiall the &, known as the "poison character" because of its disruptive effect. This person needs to to go on a "Use of IT" course. I figured it out! I am not sure why this works but what I used is: xcopy "c:\my documents\*" "h:\databackup\*" /m /e /y That copies the folder and their contents plus only those files she has changed since the last backup. My question is this -- will this take care of the error MESSAGE I get because of long file names? I think it should since those will already be copied and won't change because they are old files. how does that only copy files that have been modified since the last backup? /m copies files with archive attribute set. /e copies files and directories, even empty ones. and /y is default you don't need to add it. if you want to copy files that have been changed since a certain date try /d:m-d-y which copies copies files that have been changed on or after the date m-d-y. FB Quote from: sukieb on August 25, 2008, 10:09:42 AM
It's not just the file name length, but the total path length. They will not have been copied, and therefore the archive bit will still be set, and the message will RECUR. Quote from: fireballs on August 25, 2008, 10:17:16 AM how does that only copy files that have been modified since the last backup? Read the xcopy help again, fireballs. /M Copies only files with the archive attribute set, turns off the archive attribute. |
|
| 1743. |
Solve : SubMenu? |
|
Answer» Hi, In MS DOS if possible Not possible.......but maybe possible with a VBS Script....not sure...... Quote but maybe possible with a VBS Script....not sure...... VBScript doesn't do windows very well EITHER. A better choice would be a HTA, the combination of HTML and VBS, no browser required. Quote Adobe Acrobat to open: File, Organizaer ,Open rganizer.what's it like can you send up a snapshot. |
|
| 1744. |
Solve : Look for specific string in file and use it? |
|
Answer» Here's what I want to do: |
|
| 1745. |
Solve : Machine Spec. help.? |
|
Answer» I have been tasked with obtaining some INFORMATION about the PC's in my building. i have 100 pc's and i wish to determine the following. I have been tasked with obtaining some information about the PC's in my building.Hmmm....What Building?lol, sounds a bit dodgy. Basically, i'm a CAD manager and i am trying to asses what my mchine SPECS are for my cad operators, as i may need to upgrade some of them. Just trying to get a feel for what i have. FYI. here is a batch file a student here figured out for me. There is a start up batch for each user i will just call up the batch tomorrow, and assuming you log off tonight your'll be picked up. I will hope to tell the batch to write to a location on the network. Thanks for the help though. Diarmuid ******************* ECHO OFF systeminfo.exe > temp.txt ECHO OFF find "Host Name:" < temp.txt> %ComputerName%.txt find "Processor(s):" < temp.txt>> %ComputerName%.txt find "Total Physical Memory:" < temp.txt>> %ComputerName%.txt find "Virtual Memory:" < temp.txt>> %ComputerName%.txt find "Domain:" < temp.txt>> %ComputerName%.txt find "Logon Server:" < temp.txt>> %ComputerName%.txt ECHO OFF del temp.txt clsI do the same THING but have the luxury of being able to be in windows XP to be able to quality control the systems. I started out with BAT and moved on to scripts that can pull information directly from the windows API with out having to parse info or call on other windows programs using start/call etc. Though I do have some machines that do not have an OS installed, I check the BIOS for time date ram/cpu etc But to give you the degree of quality control we require, I have to check every aspect of the system from
I later wrote a complete WScript File (.wsf) to be able to do all of these cutting QC time down to 5 mins, All the tech has to do manually now, is check the screws are in the right places... Here's a javascript example Copy PASTE it in Notepad rename it as Spec.js The code can be setup to run remotely, or sent back to you as txt file etc. Pretty much anything you can do on your PC you can access it via script, simply search google for msdn WMI tasks Code: [Select]var wbemFlagReturnImmediately=0x10; var wbemFlagForwardOnly=0x20; var jsCrLf=String.fromCharCode(13, 10); var jsQuote=String.fromCharCode(34); //Windows Management Interface function wmiCon(strComp){ try{ var objWMIService = GetObject( "winmgmts://"+ strComp +"/root/cimv2" ); } catch(error){ var strMsg = jsCrLf + "WMI Connection Error # " + error + jsCrLf; WScript.Echo(strMsg); WScript.Quit(0); } return objWMIService; } function wmiSQL(wmiBase){ var objWMIService = wmiCon("."); try{ var colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_" + wmiBase, "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly ); //query } catch(error){ var strMsg = jsCrLf + "WMI Query Error # " + error + jsCrLf; WScript.Echo(strMsg); WScript.Quit(0); } objWMIService.close; return colItems; } var strMemTotal,strHostName,strDomain,strCpuCount, strCPUSpeed = "", strToAdd = "" var colItems = wmiSQL("Processor"); var enumItems = new Enumerator(colItems); for (x=0 ; !enumItems.atEnd(); enumItems.moveNext()) { var objItem = enumItems.item(); if (x >= 1){strToAdd = ", " + x + ") "} else{strToAdd = String(x + ") ")} strCPUSpeed += strToAdd + objItem.MaxClockSpeed(x) + " MHz"; x++; } var colItems = wmiSQL("ComputerSystem"); var enumItems = new Enumerator(colItems); for (x=0 ; !enumItems.atEnd(); enumItems.moveNext()){ objItem = enumItems.item(); strMemTotal = objItem.TotalPhysicalMemory; strHostName = objItem.Name; strDomain = objItem.Domain; strCpuCount = objItem.NumberOfProcessors; x++; } strMemTotal = strMemTotal / 1048576; strMemTotal = Math.round(strMemTotal); var strSaveto = "C:\\" + strHostName + ".txt" var strSysInfo = "HostName: " + strHostName + "\nDomain: " + strDomain + "\nCPU Count: " + strCpuCount + "\nCPU Speed: " + strCPUSpeed + "\nMemory: " + strMemTotal + " MBs"; WScript.Echo(strSysInfo + "\n\nResults Saved to " + strSaveto); var fso, f var ForReading=1, ForWritting=2, ForAppending=8; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.OpenTextFile(strSaveto, ForWritting, true); var strToReplace = /\n/g; //g - global, i - case insensitive, m - multiline search strSysInfo = strSysInfo.replace(strToReplace, jsCrLf); f.write(strSysInfo); f.close(); fso.close; |
|
| 1746. |
Solve : Parameters at command line question? |
|
Answer» I know I can take parameters at command line LIKE: fireballs, you had on % sign too many. To set Pone to the value of the first parameter you would use It works either way for me. you could have: Code: [Select] if %%1=="-password" GOTO password if %%1="-username" goto username exit :username if not %%2=="My Username" (exit) else ( if not %%4=="My Password" exit ) goto code :password if not %%2=="My Password" (exit) else ( if not %%4=="My Username" exit ) goto code is that what your looking for? EDIT: i think we had the same idea, you posted as i was writing a response. FBThat's the one, thought there might have been an actual command. Thanks.While I was posting a reply, I saw the red "While you were typing a new reply has been posted" warning. If you think about it logically, you only have 2 possibilities for the parameter sequence (a) %1 -user %2 username %3 -password %4 password (b) %1 -password %2 password %3 -user %4 username So if you look at %1 you will find out all you need to know Code: [Select]if "%1"=="-user" ( set username=%2 set password=%4 ) else ( set password=%2 set username=%4 ) I suppose my thinking was that using %1 - %9 can be limiting, mainly due to the amount of parameters that can be passed. You can pass any number of parameters, you aren't limited to 9, as you will see if you study the SHIFT command. Also, the %* parameter expands to a string made up of ***all*** of the parameters passed. I see, so the SHIFT command will keep shifting through parameters, so I could have a large amount of them. Nice one. |
|
| 1747. |
Solve : UI To Edit A .bat? |
|
Answer» I'm trying to give my "Macilizer" a configuration UI......just a regular windows message box with 3 check boxes, descriptions for each, and a SAVE button instead of an OK button..... that could be run to configure what is to be run.. dunno what are you mean in this topic but i've edited the code above and should work now thank-you, yes i do have choice.exe, i will try this code when i get back home. (i am at my friend's house CURRENTLY) thanks devcom i had to move house, so i couldn't finish the code. FB |
|
| 1748. |
Solve : Ebooks on DOS? |
|
Answer» Hi can anyone please suggest me an ebook on DOS ? who said anything about programming?see my reply again. I use "if" ... it means i also don't know. so i am just guessing. Any problems with that?nope. Just seemed random to me is all! Quote from: BC_Programmer on May 30, 2009, 09:33:05 PM nope. Just seemed random to me is all!well..if one starts to write code, its more or less considered some kind of programming. If so, then why start with DOS? A real programming language would serve more of the purpose. A real programming language helps "visualize" programming concepts and data structures etc. Furthermore, they can do what DOS batch can do, and much more. Quote from: gh0std0g74 on May 30, 2009, 09:36:56 PM well..if one starts to write code, its more or less considered some kind of programming. If so, then why start with DOS? A real programming language would serve more of the purpose. A real programming language helps "visualize" programming concepts and data structures etc. Furthermore, they can do what DOS batch can do, and much more. well im sure he will eventually pursue programming. but batch requires no compiler\ program to program besides notepad and a mind.I started with Batch programming. Nothing wrong with learning how the basics of scripting works before attempting other languages. If I never learned how to make Batch files, I believe it would have been HARDER [for me] to learn other programming languages. Quote from: BatchFileBasics on May 30, 2009, 09:40:33 PM well im sure he will eventually pursue programming. but batch requires no compiler\ program to program besides notepad and a mind.oh really. how do you suppose your batch file runs? ever heard of cmd.exe? that's a program if you want to call it.command.com I think, what he meant was there was no additional download. Not that that really provides a compelling argument.what im saying is that batch is a simple scripting language to start on to get an idea of syntax Quote from: BatchFileBasics on May 30, 2009, 10:30:22 PM what im saying is that batch is a simple scripting language to start on to get an idea of syntaxbatch syntax is ugly and batch doesn't have a lot of features already present in modern programming languages. batch also tends to lead to inefficient code. its true you can start with batch , but somewhere down the ROAD, you will find its limitations and what it can't provide. you would want to switch, so why not skip the whole DOS PROCESS and start learning how to do real programming now.yes batch isn't the best use of syntax but it gives the scripting virgins an idea of how syntax works. and just jumping into a programming language LIKE c or vb6 looks very overwhelming. To be honest... because I used batch first it took me longer to understand QBASIC, which was my second step. I kept thinking of lines as commands and had no concept of statements or expressions. |
|
| 1749. |
Solve : Child Batch!!!? |
|
Answer» hi all there!!! Can you rephrase your question?i need to creat this batch HAVR u got any idea?And you want this batch script to do what exactly? Quote from: macdad- on May 27, 2009, 10:58:01 AM And you want this batch script to do what exactly?to manage the time of my child's internet connection, i will put several pass, for ex. with 12345>>>1hour with 32145>>>2hours it's agood idea i think!Sounds like a good cause, but just to make sure: You want to monitor how much time your child uses the internet(or just Internet Explorer or Firefox)? And close it if he/she has used it more than so many hours? Quote from: macdad- on May 27, 2009, 11:11:04 AM Sounds like a good cause, but just to make sure:to shut down internet connection if he over time it!This is not really possible in Batch but there is free software designed for this use: http://restrict-internet-access.vista-files.org/ Quote from: macdad- on May 27, 2009, 11:17:16 AM This is not really possible in Batch but there is free software designed for this use:thanks mac i will check itYou could put a batch file in a startup script...and use the sleep command (downloaded seprately) and ipconfig /release (I think that should do it)... Something like... ECHO off set timecount=3600 :loop ipconfig /renew sleep %timecount% ipconfig /release echo Password required to continue! set /p pass= if /i %pass%==PASSWORD1 set timecount=3600 & goto loop rem 3600 is 1 hour. if /i %pass%==PASSWORD2 set timecount=7200 & goto loop rem 7200 is 2 hours. echo Password is incorrect! pause > nul exitOr use Helpmeh's script, by the way nice script, never thought of ipconfig one problem with that approach, is that an icon appears saying "limited or no connectivity" clicking that reveals a dialog with the "repair" button, which renews the IP lease.Could create a for loop to check to see if Firefox or IE was started(Loop every second) but that would include Tasklist. So it seems the software designated for such task would be the only option.or actual supervision.Just so you know.... The passwords can be easily viewed if you edit the batch file. The batch file can simply be CLOSED to stop the timer. |
|
| 1750. |
Solve : Waiting to terminate?? |
|
Answer» How can I make a batch file wait for a GUI application to close. Start /wait doesn't work with GUI applications (note the bolded text). Starts a separate window to run a specified program or command.Although it says that it won't occur in the command script (bat file), it won't wait.In my testing 'start /wait notepad.exe' waits until notepad exits to continue. try it Quote from: uSlackr on May 27, 2009, 10:42:19 AM In my testing 'start /wait notepad.exe' waits until notepad exits to continue. try itStart /wait firefox.exe does not wait. start /wait firefox.exe works for me as expected under Vista Quote from: uSlackr on May 27, 2009, 03:42:00 PM start /wait firefox.exe works for me as expected under VistaTry this and see...It only waits for it to load. echo off echo 1 start /wair firefox.exe echo 2 pauseHelpmeh is right, start /wait doesn't wait for termination of any GUI program. I forget the specifics but you'll need to write a program specifically for this. using some goofy convolution of createProcess(). just start the process, and then call WaitForSingleObject() on the ProcessID.you could also make a loop to test to see if the process is still active. if the process is active wait and check again. Code: [Select]echo off set appName=firefox.exe start /wait %appName% echo.App is running... tasklist |findstr %appName% >nul && call WAIT echo.App in not running... pause :WAIT tasklist |findstr %appName% >nul || exit /b ping -n 1 -w 1000 1.1.1.1 >nul goto WAIT sth like this ?That would only work on computers with tasklist, of course you could put tasklist into the same ZIP as the batch script.. Quote from: macdad- on May 28, 2009, 12:24:22 PM That would only work on computers with tasklist, of course you could put tasklist into the same ZIP as the batch script..Which is XP PRO and possibly Vista...I have Home edition...but I could get tasklist...This worked for me. I am on a PC running XP Pro. Code: [Select]echo off start /wait firefox.exe echo on Quote from: TheHoFL on May 29, 2009, 11:12:07 AM This worked for me. I am on a PC running XP Pro.echo off echo 1 start /wait firefox.exe echo 2 pause Try that. It is supposed to wait until firefox closes...it only waits until it finishes loading."When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt." The above specifies one exception - " This new behavior does NOT occur if executing within a command script." Perhaps there are other exceptions yet to be declared. Firefox breaks the rules. Is it a proper 32 bit GUI ? I have just launched two instances of Firefox, and two of Notepad. Windows Task Manager reports two instance of each on the "Applications" tab and two Notepads but ONLY ONE Firefox on the "Processes" tab. Incidentally, when all Firefox instance are closed, they disappear from the Applications Tab, and normally the Firefox process also shuts down, but sometimes it gets stuck and then CCleaner is unable to clear the Firefox cache until Task Manager has been launched and the Firefox process selected and terminated. I think Firefox is not a suitable choice for evaluating what happens with "normal" software. I am puzzled - what is meant by " This new behavior does NOT occur if executing within a command script." What was the OLD BEHAVIOUR that differs from the "new behavior" ? Was it to wait for termination regardless ? Was it to NOT wait for termination regardless ? Was it that waiting was not subject to a 32 bit GUI restriction ? What is "32-bit GUI application" ? Does this apply to both windowed application and console application. Does the above only apply when the /WAIT option is used ? Or does it apply regardless (since this whole condition is not indented under the /WAIT description) ? Regards Alan Quote from: ALAN_BR on May 30, 2009, 04:01:43 PM but ONLY ONE Firefox on the "Processes" tab.I get 1 per open window... If you right click on each open task, and select go to process, it should give you more than one process. Quote from: ALAN_BR on May 30, 2009, 04:01:43 PM I think Firefox is not a suitable choice for evaluating what happens with "normal" software.I'm not trying to evaluate "normal" software, I'm trying to wait for firefox to terminate. The quote I got from the command prompt (and my testing too), implies that start /wait will not wait for firefox to terminate, which is what I am trying to ACCOMPLISH. |
|