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.
| 6051. |
Solve : How can one access an archive (.7z specifically) from a batch program?? |
|
Answer» How can one access an archive (.7z specifically) from a batch program. not your average simple batch code... Really? The commands look pretty similar to those for the Winzip and WinRar command line utils. For example to add all the text files in a folder to an archive called Files.7z... Code: [Select]7za.exe a -t7z files.7z *.txt Very simple indeed. ahhh, brings back memories of PKZIP and PKUNZIP switches... or maybe I should shudder, I don't know.Quote from: BC_Programmer on February 03, 2009, 02:51:11 PM ahhh, brings back memories of PKZIP and PKUNZIP switches... or maybe I should shudder, I don't know. I use rar.exe every day, and I have fond memories of LHarc, ARJ, ACE, etc. GUIs are for wimps. heh. one more problem. for some reason, after downloading the 7za.exe and designating the proper folder that its in, it STILL wont recognize the 7z (command) (switches) (archive name) (file names) command line. I'm working on an xp, but i dont think that should matter. any ideas? What do you mean "won't recognize"? Describe what happens. Give examples of code used and any error messages. If the folder has spaces in the name are you using quotes? Likewise for file names. Did you download the right package? And extract the executable? Are you running a 64 bit OS? Yes i downloaded that one. i was proud of myself for not just downloading the top one, which is usually standard protocol when downloading. I'm actually using the %* variable so that files can be just clicked and dragged into the program's icon, which is the equivalent of typing the file's full directory and name w/ file extension in quotes. i love that lil variable the only ERR i'm getting is sayin that "7z is not RECOGNIZED as a comand." 7z a -mx9 TheBox.7z %* thats the code they give on the web site posted above (someone else's post.) ......................... Ignore that. solved it. =) the command is 7za.exe, i thought i was mistaken cause i had tried 7z and 7z.exe. forgot the A. but thanks everyone. you all have been huge help, and if anyone ever wants help lemme know |
|
| 6052. |
Solve : Need help for a batch file? |
|
Answer» Is a little batch to run ip config I make because one of my friend is scare of command prompt! (since I use choice.exe I know is only work in vista or maybe other...). Anyway I think I make some bug an I need a cleanup. Plx can you tell me what to do (or COPY paste the code with modification)? Thx a lots! P.S. 1.Sorry for my bad english since is not my native language 2. You are free to add your credit to the code or make it look better =) The choice commands are using invalid switch syntax: Thx for the tip so i guess choice /n /c qsp can work with choice.exe but not .com an /n /c:qsp work with both. anyway I'm currently trying to remove some an repost it after I add windsock repair...but actually I don't know where to put it in the code (after ip renew? after...). Also I guest by copy choice.com in the same folder of the batch will make it work in windows xp an vista (since I think choice.exe don't work in xp...)Quote from: BatchFileCommand on February 02, 2009, 06:19:57 PM If you put @echo off at the beginning. You don't need all those @'s . Also thx for the tips! Is my second batch file (First 1 was hello world XD) so is a little If backward compatibility is not a concern, then use the Vista choice options as /c qsp. Both choice.exe (NT prior to Vista) and choice.com (DOS) will break with a space between the /c switch and the choices. Repeating the last suggestion, use @echo off at the top of your file and remove the @ from the other echo statements. To prevent writing duplicate code, put the ipconfig /renew and ipconfig /release statements in subroutines where you can call them at the appropriate times. Quote anyway I'm currently trying to remove some <junk> an repost it after I add windsock repair...but actually I don't know where to put it in the code (after ip renew? after...) Repairing the winsock catalog is done with the netsh utility. Not sure you should put it here or design a batch application for netsh separately. Good luck. |
|
| 6053. |
Solve : Can I use md to link to a network computer to determine the OS? |
|
Answer» I have code to CREATE the directory I WANT on a networked computer, but I need to determine the OS in order to write to the correct drive (C for XP or D for 2000). Is it POSSIBLE or do I have to use net use. |
|
| 6054. |
Solve : need a command that tests for a drive letter? |
|
Answer» im trying to write a batch file that writes a file to a usb pen drive There maybe no files on the usb stick so i cannot use the IF EXIST command IF exist will find the root folder. Consider changing your way of thinking on how to resolve your problem and use the MS DOS command "MOUNTVOL" as follows. In this example certain commands have been "remmed" out for safety. rem By using the "MOUNTVOL" command USB drives used as backup-to-disk targets rem can be either removed or PLUGGED back in. rem By using the "NET SHARE" command USB drives may be shared out to users. c: cd C:\windows\system32\ cls @echo. @echo. rem This command displays both the details of the corresponding Volume Names and Paths @echo on call mountvol.exe @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem These commands removes the "volume mount point" from the "specified directory" @echo on rem This commands removes the drive letter F: from the USB device name rem mountvol.exe F: /D rem This commands removes the drive letter G: from the USB device name rem mountvol.exe G: /D @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem This command displays both the details of the corresponding Volume Names and Paths @echo on call mountvol.exe @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem These commands assign the "volume mount point" to the "individual directory" rem Should you be required to use the "volume mount point" for different USB Drives rem You can mountvol different "individual directory" so long as there is only 1 rem USB drive plugged in at once. @echo on rem mountvol.exe F: \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\ rem mountvol.exe F: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\ rem rem mountvol.exe G: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\ @echo off rem F:\ = \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\ rem G:\ = \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\ @echo. @echo. pause rem *************** cls @echo. @echo. rem This command displays both the details of the corresponding Volume Names and Paths @echo on call mountvol.exe @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem This command displays the available "shares" @echo on net share @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem This command stops sharing the available "shares" @echo on net share F /delete net share G /delete @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem This command shares out the USB directory drive with an assigned shared name @echo on net share F=F: net share G=G: @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem This command displays the available "shares" @echo on net share @echo off @echo. @echo. |
|
| 6055. |
Solve : How to get physical drive's device id using DOS command? |
|
Answer» There are 24 physical drives attached to a system. |
|
| 6056. |
Solve : AUTOMATIC BACKUP COMMAND? |
|
Answer» I am USING windows xp pack 2 and i want to WRITE a an automatic backup command using ms dos to backup a database i DEVELOPED using microsoft access.How do i do that? |
|
| 6057. |
Solve : Task Bar Hangs Coming Out of Screen Saver? |
|
Answer» Task bar seems to hang - turns dark blue with no icons showing - for about 8 SECS after deactivating the screen saver either by TOUCHING a key or moving the mouse. If I wait the 8 sec or so then everything is fine. Task bar has an hour glass if I hover over it. Task bar seems to hang - turns dark blue with no icons showing - for about 8 secs after deactivating the screen saver either by touching a key or moving the mouse. If I wait the 8 sec or so then everything is fine. Task bar has an hour glass if I hover over it.Wrong section.didn't notice it, sorry |
|
| 6058. |
Solve : How to check If...choice.exe else...choice.com? |
|
Answer» Here a QUICK batch file (I know is not working! I just use it for a example of what I want to do) What I need to INPUT in the section? THX for you help |
|
| 6059. |
Solve : Execute the F5 key with a command in Scheduler? |
|
Answer» Hi all, Execute the F5 keyYou can just do it with a screwdriver... Hi ! Thats great !! Thanks Geek-9pm Is this a normal screwdriver? Or Torx or Philips? Please give me the color of the shaft, so I can buy the same as you have. There is one problem: I'm lefthanded, so my F5 key can flip over to the right instead of left. Hope this will not be a big problem... Thanks again, and maybe till next time. Dixi Anyway- why can't you use VBScript? you could use the scheduler to schedule the script to run, and then it would "press f5" for you.Quote Anyway- why can't you use VBScript? {Whisper: Just act dumb and BC will do the script for you.}erm- the script was already written by icepick. |
|
| 6060. |
Solve : SOME1 find error in my code plz? |
|
Answer» Hi! I have problem with my code: |
|
| 6061. |
Solve : Is there a way to make a shared file in DOS?? |
|
Answer» Mainly for metworking reasons. I'm having trouble backing up files on my new laptop, and I can't really start windows on it due to a login error. Under HP's Reocvery Manager, when I try to use the Backup Files option, it demands a USB drive... except it can't detect one. And I assume that networking-wise, it can still be read, but none of my files on the new laptop were opened for file sharing. Is there way to do that via DOS?Easier approach to getting your important data off of this copied to another system may be to use Laplink or another serial or parallel communication setup to transfer files from one system to the next over a native DOS or DOS Shell with the other running windows dos shell. Mainly for metworking reasons. I'm having trouble backing up files on my new laptop, and I can't really start windows on it due to a login error. Under HP's Reocvery Manager, when I try to use the Backup Files option, it demands a USB drive... except it can't detect one. And I assume that networking-wise, it can still be read, but none of my files on the new laptop were opened for file sharing. Is there way to do that via DOS? If, as your profile shows, your using Vista, there is no DOS built in. the closest thing would be recovery console. What kind of Login errors are you experiencing? Perhaps we can help?I'm using a DOS Prompt, of course. Not running DOS DIRECT or anything. And I've tried something like what Dave suggested. A friend gave me an external hard drive, and I can actually find it via DOS, and even copy files to it. I even learned xcopy for mass file copying, but a problem I keep running into is that sometimes it'll... have problems and be unable to copy a file. Is there a limit to how large of a file DOS can copy?have you tried the /C switch to continue copying even when errors occur? your OS state confuses me... by "DOS prompt" do you mean the one provided with windows? DOS itself cannot use USB drives (reliably)What's /c supposed to do? ^^ And... I imagine it's provided by Windows... I can't see how else... But you can start up the laptop in such a way that it boots up to Windows, but only directly to some system tools, by-passing the login of course, but nonetheless, it is a small part of Windows. Just some system tools. And one of those is a command prompt that I've been using to try and copy files via DOS.Quote from: Kisai on January 15, 2009, 12:14:23 AM What's /c supposed to do? ^^ And... I imagine it's provided by Windows... I can't see how else... But you can start up the laptop in such a way that it boots up to Windows, but only directly to some system tools, by-passing the login of course, but nonetheless, it is a small part of Windows. Just some system tools. And one of those is a command prompt that I've been using to try and copy files via DOS. I explain what /c uses in the post. It continues when errors occur. Are you saying you can start the laptop in safe mode?Wow. I Googled what /c does too... Goes to show that I definitely don't think well when multitasking. And no, I can't. That would still require a login screen. I can only go to System Recovery Options. Things like Startup Repair, System Restore, Windows Complete PC Restore, Windows Memory Diagnostic Tool, Command Prompt and Recover Manager. I just copied them from what I saw on the other laptop. ^^; So I'm doing some robocopying from Command Prompt. I just wanna back up my videos and other personal files I've worked on before restoring the laptop to its default factory condition.Consider using the Microsoft "NET SHARE" command. Please see the piece of coding as an example. rem *************** cls @echo. @echo. rem This command stops sharing the available "shares" @echo on net share F /delete net share G /delete @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem This command shares out the USB directory drive with an assigned shared name @echo on net share F=F: net share G=G: @echo off @echo. @echo. pause rem *************** cls @echo. @echo. rem This command displays the available "shares" @echo on net share @echo off @echo. @echo. pause |
|
| 6062. |
Solve : Batch serial system, errors.? |
Answer» QUOTE from: whitekidney on January 16, 2009, 03:00:08 PMStill need help.I agree that this seems kind of pointless because it is so easy to get around. But you should be able to do something like this for the serial part of your code: Code: [Select]@echo off setlocal set ValidSerial=3612-3472-631 SET /P name= Enter your NAME here: if exist cache.txt ( echo Found cached serial code ... findstr.exe /b /e "%ValidSerial%" cache.txt>NUL if not errorlevel 1 goto :LOAD echo Bad cached serial code echo Please enter a valid serial code. ) :EnterSerial SET /P serial= Enter your SERIAL CODE here: if {%serial%}=={%ValidSerial%} goto :CacheSerial echo You entered a bad serial code. Please try again. goto :EnterSerial :CacheSerial echo %serial%>cache.txt goto :load :load echo Serial code is valid. echo Hello, %name%. echo Enter more code here for what you want your program to do. Oh god thanks it works. Is there any way to make more serials out of it ? It seems i can only use 1 serial code, if i do Set Validserial=1234-1234-123 Set Validserial=1111-1111-111 The last one will only workBump!Quote from: whitekidney on January 26, 2009, 10:50:21 PM Bump! Around here, bumping earns you -500 priority points, which means I won't answer for 3 days. Don't bump. It's not a good idea. Quote from: Dias de verano on January 27, 2009, 12:26:16 AM Quote from: whitekidney on January 26, 2009, 10:50:21 PMBump! Not withstanding the fact you weren't going to answer anyway, right?*CENSORED* boob.. o Well.. anyone got a solution ?Quote from: Dias de verano on January 27, 2009, 12:26:16 AM Quote from: whitekidney on January 26, 2009, 10:50:21 PMBump! lol Anyway try to use for loopCome on, i need help. :xQuote from: whitekidney on January 28, 2009, 02:35:35 AM Come on, i need help. :x 6 days now Quote from: Dias de verano on January 28, 2009, 06:46:57 AM Quote from: whitekidney on January 28, 2009, 02:35:35 AMCome on, i need help. :x You're ONTO a winner WhiteKidney, getting Dias to not burn you for 6 days is surely a good thing. Also Devcom has ALREADY pointed you in the right direction... Quote from: devcom on January 27, 2009, 05:52:44 AM Anyway try to use for loop And another thing, just wondering if you're aware of what your name means? FBive tried so many diffrent things anyone got any code for it ? :S9 days ? Quote from: devcom on January 28, 2009, 02:38:33 PM 9 days ? Yup This kid just doesn't learn.Erm, i almost got it, but still errors. Anyone got any example code ? |
|
| 6063. |
Solve : How to see if a string exists in a txt file.? |
|
Answer» Quote from: BatchFileCommand on January 22, 2009, 04:45:33 PM Oh, so now contrexing is some kind of rule. Sure.... Not a rule, more a process. Quote from: BatchFileCommand on January 22, 2009, 04:45:33 PM Oh, so now contrexing is some kind of rule. Sure....Contrexing is not A rule, but it HAS a (almost) unspoken set of rules that you must follow to be successful in Contrexing.Quote Contrexing (proper-verb=must have CAPITAL) is the act of FLAMING another user, in the way that Contrex would have. What HAPPENED to the simple definition.Quote from: BatchFileCommand on January 24, 2009, 07:42:19 PM QuoteContrexing (proper-verb=must have capital) is the act of flaming another user, in the way that Contrex would have. What simple definition?Here's the simple explanation of Contrexing Quote Contrexing (proper-verb=must have capital) is the act of flaming another user, in the way that Contrex would have. But after that it comes out to a process, some kind of proverb. Whatever you people call it.Quote from: BatchFileCommand on January 24, 2009, 07:52:07 PM Here's the simple explanation of Contrexing The definition ADVANCED because you refused to understand the previous EXPLANATIONS. |
|
| 6064. |
Solve : How to convert FreeDOS to MSDOS?? |
|
Answer» I have a working installation of FreeDOS on a BOOTABLE USB flash DRIVE. I WANT to have a working installation of MSDOS on that USB drive. How would I go about switching one out for the other? Is it as simple as overwriting the FreeDOS files with MSDOS files, or do I need to modify the boot record for the USB drive? FreeDos isn't an actual OS , but MSDOS is so that would be piracy! Not sure why you bothered posting that, BFC, since FreeDOS definitely is an actual OS (1), and if you own a licensed (2) copy of MS-DOS it wouldn't be piracy. Don't they have Google on your planet? (1) Quote from: http://www.freedos.org/ FreeDOS is a complete, free, 100% MS-DOS compatible operating system. (2) Quote from: http://support.microsoft.com/kb/79747 The MS-DOS version 5.0 or later upgrades and packaged products are licensed to customers for use on one computer at a time. If you want to use MS-DOS on another computer (such as a laptop computer), you must remove or uninstall MS-DOS before it is used on the other computer. Microsoft Windows version 3.1 and later is licensed the same as MS-DOS. This also applies to network users. Incidentally... Quote from: http://support.microsoft.com/kb/79747 Microsoft programs are licensed differently from Microsoft operating systems. A Microsoft Word for Windows licensee who USES a particular computer 80 percent of the time can load the program onto a computer she or he uses 20 percent of the time, without purchasing another license. This applies to Microsoft products such as Microsoft Excel, Word, and Microsoft PowerPoint. Quote from: Miriax on January 21, 2009, 11:05:24 PM or do I need to modify the boot record for the USB drive? You'd need to use the (MS-DOS) SYS command. Quote Alternatively, how could I install MSDOS onto a non-bootable flash drive? Just copy the files onto it. But why would you want to do this? Have it non-bootable I mean. The DOS COMMANDS on it wouldn't work, and it's just as easy to make a bootable MS-DOS pen drive. Presuming you have a licensed copy of MS-DOS, there are a squillion guides on the web for this. |
|
| 6065. |
Solve : How to make batch file execute as a singleton?? |
|
Answer» Hi, |
|
| 6066. |
Solve : Getting Characters from a Bat file name.? |
|
Answer» I am in TNCAAK1.BAT which has the command I am in TNCAAK1.BAT which has the command Code: [Select]@echo off REM %0 CONTAINS a batch file's OWN NAME REM USE ~n variable modifier to get name part set myname=%~n0 REM use set shortstring=%longstring:~offset,length% string slicing to get chars REM first char is offset 0 set p1=%myname:~0,1% set p2=%myname:~4,2% REM demonstration echo full name + EXTENSION is %0 echo name part only is %myname% echo the 1st character of name %p1% echo 5th and 6th chars of name %p2% REM delete when satisfied REM call other batch file call AAAAAA.BAT %p1% %p2% |
|
| 6067. |
Solve : I have problem with renaming files? |
|
Answer» I have many files have ERROR in their names. I do not KNOW how to rename them using batch script. You're so knowledgeable Mr Google. I'm amazed.... It's not him, it's all those servers he owns... Quote from: fireballs on February 02, 2009, 07:32:06 AM You're so knowledgeable Mr Google. I'm amazed.... Thank you, I try my best. Haha. Many thanks for you all. It is working now.Quote from: Mr. Google on February 02, 2009, 07:28:00 AM http://www.computing.net/answers/programming/batch-script-to-rename-file/16798.htmlwww.letmegooglethatforyou.com would be very usefull to you.Haha, it sure isQuote from: Helpmeh on February 05, 2009, 03:00:03 PM Quote from: Mr. Google on February 02, 2009, 07:28:00 AMhttp://www.computing.net/answers/programming/batch-script-to-rename-file/16798.htmlwww.letmegooglethatforyou.com would be very usefull to you. That's brilliant! why haven't i seen this before?! FBExcept it doesn't work if you have script blocking enabled, like I do by default. Well thats only you hopefully hahaSeriously: we all like a laugh, but take care lest you go over the edge and become a pr*ck.... What do you mean by that? |
|
| 6068. |
Solve : MS DOS Command? |
|
Answer» What is the DIFFERENCE between copy and format command in MS DOS?TRY Code: [Select]copy /? and Code: [Select]format /? |
|
| 6069. |
Solve : Count # Times word in used in multiple word docs? |
|
Answer» How can I count # Times word in used in multiple word docs contained within subfolders? |
|
| 6070. |
Solve : Get ip and set as an input for a batch file.? |
|
Answer» Well i need help im trying to make a batch file that gets the ip address and sets it as an input for a friend because he doesnt have a static ip and he hates changeing the ip address daily of the application he has. i ALREADY KNOW how to get it into the app but for some reason i cant FIND out how to set the ip address as an input here is what i have already done and thats all i need because i can get the rest. |
|
| 6071. |
Solve : Repeatedly run command in windows? |
|
Answer» I am looking for a WAY to repeatedly run a command where the command is run, and then the computer waits for the command to finish before running it again. (That is, SOMETHING similar to the "while true; do ... ; done" in linux.) I have tried creating a batch file like this: |
|
| 6072. |
Solve : go back in BAT? |
|
Answer» I am not sure how to search for this because i don't seem to get what i am looking for. do you mean that the batch file might be on a different drive?Is that directed at my? If so then it could be but the program dose many things and the file that it runs is on the same drive so that you can transport it to any computer and still fined and run the program. It is based of the fact that when moving a flash drive from one pc to another it will have a different drive letter.C:\>type drive.bat Code: [Select]@echo off REM Use command line argument REM drive.bat E %1: start %1:\FolderA\file Output: C:\> drive.bat E E:\>HUH? Is the objective to make this harder that it needs to be? You can always execute a batch file in another directory on the same drive. You can reference another file in another directory, even if the directory is not down in the current tree. Example: ..\folder\file.txt is a sideways reference to a file in a sister folder. \folder\folder\file.txt Is a reference from the root without SAYING which drive. (It has to be the current dive.) .\file.txt means this folder. Somewhere this is documented! Quote from: Geek-9pm on September 24, 2009, 01:42:08 PM
Wikipedia article title "Full stop"... Quote In Unix-like systems and Microsoft Windows, the dot character represents the working directory of the file system. TWO dots (..) represent the parent directory of the working directory. Wikipedia article title "Path (computing)". Quote Two dots ("..") point upwards in the hierarchy, to indicate the parent directory; one dot (".") represents the current directory itself. Both can be components of a complex relative path cd help Code: [Select]C:\>cd /? Displays the name of or CHANGES the current directory. CHDIR [/D] [drive:][path] CHDIR [..] CD [/D] [drive:][path] CD [..] MSDN page titled "File Names, Paths, and Namespaces" http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx I like to keep my projects very organized and not have duplicate files. So this is a pretty big piece to have working. In this small project i simply needed to run "sleep.exe". It worked perfectly. Thank you all for the input! Code: [Select]"..\exes\sleep.exe" 3 -HoFLQuote from: TheHoFL on September 24, 2009, 04:01:16 PM I like to keep my projects very organized and not have duplicate files. So this is a pretty big piece to have working. In this small project i simply needed to run "sleep.exe". It worked perfectly. HoFL, I have no idea what you are talking about. Sleep.exe? .. represents the current directory, up one. So "..\folder\name.bat" goes up one level, then looks in there for "folder" then GETS name.bat .Sleep.exe is a simply program that allows you to "pause" for a specified amount of seconds. It's like pause, but you don't have to hit a key to continue. It just starts after the amount if time specified. There is a sleep.com in this place: http://dslgeek.com/dos/there watch my video on youtube --> http://www.youtube.com/watch?v=mqhemoOVfuU than you know the code |
|
| 6073. |
Solve : How do I incoporate a RUN command in Batch file?? |
|
Answer» I have a menu in batch FILE which I created but I'm stuck on how to launch the run command (Window's shortcut). In the RUN command the text field is automatically entered (from the batch file) then launch the application or whatever (i.e. msconfig, cmd, or notepad, etc). I using XP version. c:\users\public\life.exe (you can enter just the file name for some things, if you're in the directory with the executable in it, or if the executable is in the path environment variable ex. notepad.exe) FBI think he wants to literally show the run dialog. try this command, if that is the case: Code: [Select]rundll32.exe shell32.dll,#61 Quote from: BC_Programmer on January 25, 2009, 09:41:33 AM I think he wants to literally show the run dialog. And, judging by this.... Quote I'm stuck on how to launch the run command (Window's shortcut). In the RUN command the text field is automatically entered (from the batch file) then launch the application or whatever .... following that, automagically type in a command and click OK, which is a long winded way of starting an executable from a batch file. Maybe the OP does not realise that you don't need to do that? I think he means he wants to start the program from run. You know, the thing where you can type in a program name and it starts that program. So if you're going to start it from run you would have to have the extension with it. Like this: batchfile.bat/exeQuote from: BatchFileCommand on January 25, 2009, 01:21:26 PM I think he means he wants to start the program from run. You know, the thing where you can type in a program name and it starts that program. So if you're going to start it from run you would have to have the extension with it. Like this: Not quite sure what you're trying to say there, old boy. I have what I NEEDED. Thank you.Quote from: locbtran on January 25, 2009, 01:46:59 PM I have what I needed. Thank you. And what was it? |
|
| 6074. |
Solve : xcopy certain dates or certain folders help.? |
|
Answer» Hi I'm pretty new to batch files so here goes, Thank for your response helpmeh,Well, the set command should be fairly obvious to you. But here's how the for loop works. for /f The command with the /f switch. See FOR /? for more information on other switches. "tokens=1,2 Part one of the options. Specifies that the first 2 tokens are used. By default is 1. delims=." Part 2 of the options. It tells the command where to divide the output (see later) by for each token. Must be used last. By default is a space and/or a tab. %%a Specifies the first for variable (or the only one in some cases). in (self-explanitory) ('dir /b *.log') Collects the output from that command (see DIR /? for more INFO on that command). do (self-explanitory) If not "%%a" LSS "%mindate%" If the value of %%a is not less than the value of %mindate% do: If not "%%a" gtr "%maxdate%" If the value of %%a is not greater than the value of %maxdate% do: Copy %%a.%%b TARGETLOCATION Copy the value of %%a.%%b (which is the file's name .log ex 20090801.log) to the target LOCATION (TARGETLOCATION), which you had to specify. If you need any more help, feel FREE to ask. |
|
| 6075. |
Solve : Set Wallpaper.? |
|
Answer» How can I set an image as my wallpaper using a batch?Directly? I doubt it. There is a .cpl file and there may be a place to find the required syntax. Quote from: Boozu on SEPTEMBER 24, 2009, 04:05:45 PM How can I set an image as my wallpaper using a batch?If this is for your own amusement you can do this: 1. ind a web site with a nice image and set it as you wallpaper 2. Look for it in the folder c:\windows\web\wallpaper\ 3. if you overwrite that image it will become the new wallpaper when the system is reset. I never knew that! Lol, nice TRICK!I have a more efficient way involving the registry. I will post tomorrow.Why would someone use the registry just to change their wallpaper. They would probably do something they're not SUPPOSED to and screw their computer. It is meant as a joke but not to Quote screw their computer.Quote from: Boozu on September 25, 2009, 05:06:37 AM It is meant as a joke but not toI meant doing stuff in the registry can be potentially bad. I deleted some registry keys, but it was to see all the extensions. Code: [Select]@echo off REM Configure Wallpaper Echo Registry: Wallpaper (1 of 3) REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%\energybliss.bmp" Echo Registry: WallpaperStyle (2 of 3) REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 0 Echo Registry: TileWallPaper (3 of 3) REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 2 REM Make the changes effective immediately Echo Updating system %SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters Centred Tiled Stretched WallpaperStyle 0 0 2 TileWallpaper 0 1 0 If you change the PATH/filename of the bmp to "%1" you can then put the script into your Send To folder & thereafter right click on a bmp and set it as your wallpaper. You could have 3 different scripts called stretch, tile, and centre -wallpaper.bat maybe? Quote from: Helpmeh on September 25, 2009, 03:14:50 PM I meant doing stuff in the registry can be potentially bad. I deleted some registry keys, but it was to see all the extensions. you have no idea what your talking about. if it's done through a batch command it's not going to "mutate" and suddenly change a totally different key.Doing stuff with a kitchen knife can be "potentially bad", if that includes plunging it into your mother-in-law, and carelessness can result in bleeding fingers, but that does not make the practice of cookery a bad thing. exactly, same thing with gophers... they make great garden tools if you staple them to a stick, but they make crummy eating utensils. But that doesn't make them.... hey WAIT a second what was my point? anyway, the value: HKEY_CURRENT_USER\Control Panel\Desktop\WallPaper contains the full path to the desktop wallpaper. |
|
| 6076. |
Solve : XCOPY ---- Progress Display ... ?? |
|
Answer» Input: Code: [Select]<nul Output: Code: [Select]>nul Quote Ok ... now that I've said this I will read the code and let you know what I think. I gotta talk to Nathan about that raise. PS. The code will not work if you insist on using XCOPY. You're not using any switches that are unique to XCOPY, so COPY is actually a better choice. Quote from: Sidewinder on January 23, 2009, 03:48:28 PM
Didn't think copy worked correctly over network drives? Maybe it would work by using Pushd, this is a new command I found, from what i have read creates a temporary drive until you popd it off ... Completed product with COPY for now ... going to play with xcopy later ... Why do you say xcopy won't work? Thank you very much for all your effort put forth into this, a raise would be a wonderful thing. Code: [Select] @echo off set wkdir=%cd%\workdir set dest=%cd%\dest set perc=0 setlocal enabledelayedexpansion if not exist "%wkdir%" md "%wkdir%" pushd %wkdir% :: Get Number of Files in Dir for /f "tokens=1*" %%i in ('dir /a:-d ^| find /i "file(s)"') do set count=%%i set storcount=%count% Title 0%% Done echo Start Copy Operation Echo. Echo The numbers printed to screen represent the number of files left to copy Echo. :: Copy Files; Show Progress For /f "delims=" %%a in ('dir /b /a:-d /o:-d') do ( <nul call set/p z= !count! copy "%wkdir%\%%a" "%dest%\%%a" > nul rem >nul ping localhost -n 2 set /a count-=1 set /a perc+=1 set /a p=(!perc!*100^)/%storcount% >>log.log title !p!%% Done ) popd echo. echo End Copy Operation & pause >nulQuote Why do you say xcopy won't work? I may have misspoke. There goes my raise! You're only feeding one file at a time to XCOPY so I'm guessing COPY and XCOPY will work same. Quote Didn't think copy worked correctly over network drives? Where did you here this? I've never had any problems with copy over a network using either UNC notation or mapping the drive. My only experience with PUSHD and the flipside POPD as been to put directory names on the stack for future retrieval. Learn something new everyday. Sidewinder, I was hoping I could pick your brain one more time. I added some code and seem to have broken what I had, thought I found my mistake, but the batch file is still crashing. Here is the code .... Part of what I added ... I like the output to the screen, but as I get to double/single digits the display starts to look look off. I wanted to count the number of CHAR in the Count VAR to determine if it was 1, 2, or 3 char long then output accordingly by adding a leading zero to the number when it outputted to the console. I used this code before to do a count, but never in a For loop ... maybe that is my problem. I found a couple mistakes so maybe there is something I am missing. Thanks again for your help. At this rate I might have to pay your raise. Code: [Select] :LOOP_0 IF "!counter!"=="" GOTO :RESULT SET /a strgCount+=1 SET counter=%counter:~1% GOTO :LOOP_0 :RESULT The whole thing Code: [Select]ECHO on set wkdir=%cd%\workdir set dest=%cd%\dest set perc=0 set counter=0 SET strgCount=0 setlocal enabledelayedexpansion if not exist "%wkdir%" md "%wkdir%" Rem Get Number of Files in Dir pushd %wkdir% for /f "tokens=1*" %%i in ('dir /a:-d ^| find /i "file(s)"') do set count=%%i Rem Store number of files for Percentage completion tracking set storcount=%count% Title 0%% Done ECHO Start Copy Operation ECHO. ECHO The numbers printed to screen represent the number of files left to copy ECHO. REM Copy Files Show Progress For /f "delims=" %%a in ('dir /b /a:-d /o:-d') do ( set counter=!count! SET strgCount=0 :LOOP_0 IF "!counter!"=="" GOTO :RESULT SET /a strgCount+=1 SET counter=%counter:~1% GOTO :LOOP_0 :RESULT if "!strgcount!"=="3" Goto pass1 Goto check1 :pass1 <nul call set/p z= !count! & goto copypro :Check1 if "!strgcount!"=="2" Goto pass2 Goto check2 :pass2 <nul call set/p z= 0!count! & goto copypro :Check2 if "!strgcount!"=="1" Goto pass3 Goto check3 :pass3 <nul call set/p z= 00!count! & goto copypro :Check3 :copypro copy "%wkdir%\%%a" "%dest%\%%a" > nul set /a count-=1 set /a perc+=1 Rem Changes title to ^%Percentage set /a p=(!perc!*100^)/%storcount% title !p!%% Done ) popd ECHO. ECHO End Copy Operation & pause >nulQuote At this rate I might have to pay your raise. You can't afford me. Either can Nathan, but I haven't told him yet. Quote Part of what I added ... I like the output to the screen, but as I get to double/single digits the display starts to look look off. I wanted to count the number of CHAR in the Count VAR to determine if it was 1, 2, or 3 char long then output accordingly by adding a leading zero to the number when it outputted to the console What happens if the last count on the line wraps to the NEXT line? This is some generic code I found. Works for three digits. I'll let you incorporate it into your code. Code: [Select]@echo off setlocal :loop call set chr=%%count:~%len%, 8192%% if "%chr%"=="" goto exit set /a len+=1 goto loop :exit if %len% EQU 1 set count=00%count% if %len% EQU 2 set count=0%count% echo %count% Good luck. You can remove the setlocal statement. I used it for testing purposes. The 8192 is the max size of the environment on a XP machine. You can reduce this in keeping with your needs. Five would be a good choice for future expansion.Question ... does doing a loop without the call procedure throw yourself out of the normal for loop operation ... is that what I was doing wrong? This is pretty good. Just a thought - How can this be made to work for recursive copying. What if wkdir has subdirectories in it? I am sorry to put in a question of my own within this conversation. If you want me to open a new topic, would be glad to do that too. However I thought since this is an active topic, I will just post my question here. Notice I didn't try to incorporate the snippet into your code. I was afraid the whole thing would fall apart. Why not USE the call instruction to transfer control to an internal subroutine? You can format the count immediately prior to writing on the console? Quote Question ... does doing a loop without the call procedure throw yourself out of the normal for loop operation I think the fact of a :label within the for loop is creating unpredictable results. I'm not certain how the interpreter keeps track of the return addresses. How did a seemingly simple copy operation turn into such a Rube Goldberg contraption? Batch code is NOT a programming language. If the KISS recruiter needs applicants, he should LURK in the DOS alley. @hiteshsavla Quote Just a thought - How can this be made to work for recursive copying. What if wkdir has subdirectories in it?If this refers to your other post, don't even think it. Quote from: Sidewinder on January 26, 2009, 03:12:29 PM Notice I didn't try to incorporate the snippet into your code. I was afraid the whole thing would fall apart. Your right, it fell apart ... I guess I have never run into trying to do something in a FOR loop before. ... I guess I confused how to continue then. I guess the whole effort is just make the display on the screen more in line, as the numbers get small they start to get out of line and I no longer have pretty columns ... Love the bit of code Code: [Select]<nul call set /p z= !count! much better then echo My problem is by calling a routine I end up getting it to work again, but get a message that echos 'The system cannot find the batch label specified -' This bit of code was purely to make the display nicer ... Code: [Select] if %len% EQU 1 set count=00%count% if %len% EQU 2 set count=0%count% Quote
Your right it isn't a batch language, but i'm amazed everyday I learn something new that it can do , thanks for all your help. |
|
| 6077. |
Solve : Batch file to copy only files that do not exist OR answer no to overwrite? |
|
Answer» Hi, |
|
| 6078. |
Solve : rename a file from a table?? |
|
Answer» I have a file that gets output every week. I want to append the week number to the END of the file, but it's not the calendar week number using the system clock settings, it would be the retail calendar week. it would be the retail calendar week. Do you mean the 4-5-4 Merchandising Calendar? If so, on what day of the week will the file be output? We are using the 4-4-5 merchandising calendar. In most cases, the file will be output on TUESDAY each week, but it could be Wednesday sometimes. It was be triggered by a user to start the process, but I was trying to avoid them having to rename the file after it was generated. Let me know if you could help! Thanks much.Just to clarify what you want: Quote from: luvsun27 I want to append the week number to the end of the fileDo you mean that you want to append the week number as the last record (line) of the file or that you want to append the week number to the filename? Quote from: luvsun27 Can I set up a table of some sort to look so that I can use the name of the weekWhat do you mean by "name of the week"? You already said you want to use the week number. Do you want to give each week a unique name? Quote from: luvsun27 It was be triggered by a user to start the process, but I was trying to avoid them having to rename the file after it was generatedAgain you mention renaming the file which is somewhat different to appending the week number to the end of the file. Sorry about my confusion.Let me clarify...the name that is output for the file each week is called sales_file_output. I want to save a copy of this file with the week number, so sales_file_output_week1, sales_file_output_week2, etc,etc. Just the name of the file NEEDS to change, not the contents of the file. The file sale_file_output is being loaded into another system, but I want to keep a copy of the file for reference in a backup folder. Thanks again for trying to help!It might be possible to set arrays to suit your purpose but the number of arrays is considerable. Each year, month (Merchandising calendar) and week would need its own array and separate coding to return the week number, then the six week month would also have to be considered in the long term (next six-week-month is in 2012{?}). Also the week number OCCURS in each year (Week1 would show in 2009 and 2010 etc) so renaming files would fail due to DUPLICATION unless the script is changed. As an easy alternative I suggest that you append the date of writing of the file to the filename, it would then be fairly simple to look up a hard copy of the Merchandising Calendar to determine in which week that date falls. Filenames would show as sales_file_output_20090127 etc. Thank you very much for your help...I think I will do just that, put the date at the end of the filename. Thanks agan. |
|
| 6079. |
Solve : MS-DOS trouble with changing to different drive...? |
|
Answer» Running: Vista 64-bit |
|
| 6080. |
Solve : how to switch my drive in command? |
|
Answer» need to SWITCH my c:\ to my d:\ for this checkup IM curious bout (my D:\ is my recovory)you want to change the drive letter or just change the working directory? to change working directory it's just Code: [Select]D: |
|
| 6081. |
Solve : XP: how to have one batch file create another with FOR Variables? |
|
Answer» I WANT to have a batch file create a series of batch files , each of which use a variable. the final output should read: Then why is the %%Q present here? for /L %%Q in (0,1,3) do echo for %%V in (*%%Q.vnc) do fixit %%V > %%Q_Fix.bat Quote How can I 'protect' the double percentage sign in the echo output to the file? The escape char for a percent sign is... a percent sign. That is, to echo one percent sign from a batch, you use two in the code. Code: [Select]@echo off for /L %%Q in (0,1,3) do echo for %%%%V in (*%%Q.vnc) do fixit %%%%V > %%Q_Fix.bat for /L %%Q in (0,1,3) do ( echo %%Q_Fix.bat: echo. type %%Q_Fix.bat echo. ) Code: [Select]0_Fix.bat: for %%V in (*0.vnc) do fixit %%V 1_Fix.bat: for %%V in (*1.vnc) do fixit %%V 2_Fix.bat: for %%V in (*2.vnc) do fixit %%V 3_Fix.bat: for %%V in (*3.vnc) do fixit %%VQuote from: Dias de verano on January 26, 2009, 03:45:06 PM Quote from: crp on January 26, 2009, 02:01:00 PMI do not UNDERSTAND the question.the final output should read: Quote QuoteHow can I 'protect' the double percentage sign in the echo output to the file? yes Code: [Select]for /L %%Q in (0,1,3) do echo for %%%%V in (*%%Q.vnc) do fixit %%%%V > %%Q_Fix.bat worked perfectly, as wanted. Where is that NUGGET of information about the ESCape character for '%' being '%' ? I searched quite a few places for 'dos percentage escape' THANK YOU! Quote from: crp on January 26, 2009, 04:14:40 PM Quote from: Dias de verano on January 26, 2009, 03:45:06 PMQuote from: crp on January 26, 2009, 02:01:00 PMI do not understand the question.the final output should read: You stated that the output should be: for %%V in (*.vnc) do fixit %%V (There is no number between the asterisk and 'vnc') Yet in your code you show echo for %%V in (*%%Q.vnc) Which means you want to see *0.vnc, *1.vnc, *3.vnc. Which is different. That's all. Quote Where is that nugget of information about the ESCape character for '%' being '%' ? Well, perhaps if you tried "percent sign" you would have found something, and we're not in DOS land... Here for example http://www.google.com/search?source=ig&hl=en&rlz=&=&q=escape+percent+sign&btnG=Google+Search&meta=lr%3D the 2nd result leads to http://www.robvanderwoude.com/escapechars.html |
|
| 6082. |
Solve : Browser options form DOS?? |
|
Answer» Browser options form DOS? Browser options form DOS? Not sure, if there's a way to get IE to do this automatically. Another way, might be to use a program to download the file... and then simply get that set as a background (probably possible via REG commands)Quote Another way, might be to use a program to download the file... and then simply get that set as a background (probably possible via REG commands)I was hoping a small BATCH file would do it. I want to send it as an e-mai attachment to my family and friends. I don't think they will go for a REG edit script! Quote from: Geek-9pm on September 25, 2009, 10:13:02 PM I was hoping a small batch file would do it. I want to send it as an e-mai attachment to my family and friends. well, the "REG" command can be used, is what I mean- would be unnoticable. But, I'm not sure if the background would change right away or after the next REBOOT... or semi-randomly when another program decides to broadcast a "system change" message...I'm confused. Are we talking about background of a program or the wallpaper. Desktop background, which is also called wallpaper Why not follow your own advice you gave to another member in the "Set Wallpaper." thread. (still on the first page in the MS-DOS section. |
|
| 6083. |
Solve : Area of Adventure release [local] [beta]? |
|
Answer» i know its impossible but it would SEEM quite lousy if there were able to put Halo 3 on Nintendo 64(choppy graphics, HORRIBLE details)Does anyone still have a COPY of this? The download link is broken and I could really learn from this...or I did before I deleted it.Not SURE, Jacob has been GONE for a while...Last active on the 6th this month. Oh, well still not an update on it for a while.I'd suggest sending him a PM and waiting for a response... |
|
| 6084. |
Solve : Backing Up Program using DOS 6.22? |
|
Answer» I have a program called Mpddd on C: that I WOULD like to Backup to FLOPPIES on A: The program requires 8 FORMATTED Floppies (so a simple COPY Command will not work). |
|
| 6085. |
Solve : Is it possible to remove the colon from the drive letter? |
|
Answer» Here's the code that I am working with: |
|
| 6086. |
Solve : Can you submit data in web forms using a batch file?? |
|
Answer» Hello, You cannot do this with a Batch File. Sorry.Thanks for the reply, and sorry, I didn't realise I'd posted in the wrong forum. Is there another way I might be ABLE to do this or am I stuck with the manual ROUTE? |
|
| 6087. |
Solve : Write batch that run application and i need to resize the window? |
|
Answer» Hi , |
|
| 6088. |
Solve : copy a file from source location to backup location with folder named %date%? |
|
Answer» Ran into a subdirectory issue with the \ in the %date% when executing |
|
| 6089. |
Solve : unable to set a variable in a For loop? |
|
Answer» Hi, I am unable to set a varaible in a FOR LOOP. |
|
| 6090. |
Solve : How to minimise the Batch File? |
|
Answer» I KNOW how to minimise the program that is running (I have read some guides), however, I can't seem to find out how to minimise the batch file. |
|
| 6091. |
Solve : Error with bat2exe.com? |
|
Answer» Quote from: BatchFileCommand on January 26, 2009, 06:37:25 PM It's not a wrapper. It turned my batch file code to a bunch of funky symbols LETTERS and stuff. BC, have you ever used this program? I'm afraid it doesn't convert stuff over 35kb. Yes. that is what I describe above.All I want it to do is make my code unreadable and have it still RUN. Here's a chunk of code from my program: Code: [Select]„+€1Ø3 >„߃Mìÿàü'h Pðk]f9;„t That's definatley exeQuote from: BatchFileCommand on January 27, 2009, 06:19:55 AM All I want it to do is make my code unreadable and have it still run. Here's a chunk of code from my program: Sigh. Did you READ the post? do you know what PROCESS explorer is? The batch file is plain text in the memory image.Quote from: BC_Programmer on January 27, 2009, 06:40:10 AM
BC_programmer, can't you see you're talking to an expert? Just look at the technical language he uses... Quote a bunch of funky symbols letters and stuff.Code: [Select]BC_programmer, can't you see you're talking to an expert? Just look at the technical language he uses... I love you sense of humor...Quote from: BatchFileCommand on January 27, 2009, 06:19:55 AM All I want it to do is make my code unreadable and have it still run. Here's a chunk of code from my program: HA HA! I found a hole it that logic too! where's the MZ? |
|
| 6092. |
Solve : Set a command as an input or/and use a command with if???? |
|
Answer» if %INPUT% is a time to CHECK then yesk thanks now i NEED to do just one more THING to it and COMPLETE for the server |
|
| 6093. |
Solve : I Want To Copy Everything(all directories) from "C' Drive to "D" Drive? |
|
Answer» See Here... for my review on Macrium REFLECT and a link to their SITE...http://www.giveawayoftheday.com/ xcopy c:\*.* /a /e /k |
|
| 6094. |
Solve : VBS Date & Time Accessible from a batch? |
|
Answer» Some weeks ago I hacked together a crude batch file which created a VB script & then read back the results to make various VBS date stuff accessible in a batch. I was gratified to see people make use of it and since I am on Xmas break from work I decided to tidy it up a bit and add some features as you can see below Happy holidays to everyone. Except for this guy, who is "Off to Guantanamo!" Do you supply your own orange overall? Have a great time. Thank you for this. results can be open automaticaly when you run the bat file?Quote from: DAan on January 04, 2009, 12:18:15 AM Thank you for this. What do you mean? DAan probably is trying to ask if the BAT file displays the date/time when it is finished running.Quote from: Helpmeh on January 05, 2009, 03:18:15 PM DAan probably is trying to ask if the BAT file displays the date/time when it is finished running. Well, if so, then all I can say is that it should be obvious to the intended users (either from looking at the "output" box above, or by actually saving and running the batch file) what it does. Also people who have some experience of writing & using batch files will be able to see how to modify it for their own purposes. Quote from: Dias de verano on January 05, 2009, 03:35:21 PM Quote from: Helpmeh on January 05, 2009, 03:18:15 PMDAan probably is trying to ask if the BAT file displays the date/time when it is finished running. True....Dias. Is it possible to enter a date and have your script produce the results from that date. If 23-11-2008 was entered can your code be modified to display month, day, year, week#, day# etc using that date as input? I have searched T.Salmi, alt.msdos and others without success. Cheers Yes. It is 8:08 AM here and I am off to work, I will answer after work this afternoon. You should be looking at VBS date functions really. Quote from: Hedonist on January 27, 2009, 01:01:53 AM Dias. Is it possible to enter a date and have your script produce the results from that date. If 23-11-2008 was entered can your code be modified to display month, day, year, week#, day# etc using that date as input? Qdate.bat Code: [Select] @echo off REM Create VBS script set vbsfile=DateInfo.vbs echo Newdate = WScript.Arguments(0)>%vbsfile% echo if IsDate(Newdate) then>>%vbsfile% echo Newdate = CDate(Newdate)>>%vbsfile% echo DateYear = DatePart("YYYY", Newdate)>>%vbsfile% echo DateMonth = DatePart("M" , Newdate)>>%vbsfile% echo DateDay = DatePart("D" , Newdate)>>%vbsfile% echo WeekOfYear = DatePart("WW" , Newdate)>>%vbsfile% echo DayOfYear = DatePart("Y" , Newdate)>>%vbsfile% echo WeekDayNumber = DatePart("W" , Newdate)>>%vbsfile% echo TodayNameShort = WeekdayName(WeekDayNumber,True)>>%vbsfile% echo TodayNameFull = WeekdayName(WeekDayNumber,False)>>%vbsfile% echo MonthNameShort = MonthName(DateMonth,True)>>%vbsfile% echo MonthNameLong = MonthName(DateMonth,False)>>%vbsfile% echo Wscript.Echo DateYear^&" "^&DateMonth^&" "^&DateDay^&" "^&Week^ OfYear^&" "^&DayOfYear^&" "^&WeekDayNumber^&" "^&Today^ NameShort^&" "^&TodayNameFull^&" "^&MonthNameShort^&" "^&MonthNameLong>>%vbsfile% echo else>>%vbsfile% echo Wscript.Echo "ERROR">>%vbsfile% echo end if >>%vbsfile% REM below is example batch code to call the vbs REM Example of use REM 1) get a date string into a variable set /p Querydate=Enter Date: REM 2) pass the string to the VBS script and REM parse the output, which will either be 10 REM items of data, or else the string "ERROR" REM if the string is not a valid date. REM REM Store output of vbs script in variables for /f "tokens=1-10 delims= " %%A in ('cscript //nologo %vbsfile% %querydate%') do ( set Year=%%A set Month=%%B set Day=%%C set WeekNumber=%%D set DAYNUMBER=%%E set DayOfWeekNum=%%F set DayNameShort=%%G set DayNameLong=%%H set MonthNameShort=%%I set MonthNameLong=%%J ) REM 3) Do something with the data if "%Year%"=="ERROR" ( echo Error: invalid date ) else ( Echo Data for Date: %Querydate% echo. echo Date Year : %Year% echo Date Month : %Month% echo Date Day : %Day% echo Week Of Year : %WeekNumber% echo Day Of Year : %DayNumber% echo Day Of Week [Number] : %DayOfWeekNum% echo Day Of Week [Short Name] : %DayNameShort% echo Day Of Week [Full Name] : %DayNameLong% echo Month [Short Name] : %MonthNameShort% echo Month [LONG Name] : %MonthNameLong% echo. Echo %DayNameLong%, %MonthNameLong% %Day%, %Year% is/was/will be in week %WeekNumber% echo. ) Alternatively you could just save the vbs script somewhere on your PATH and call it from batches Code: [Select] Newdate = WScript.Arguments(0) if IsDate(Newdate) then Newdate = CDate(Newdate) DateYear = DatePart("YYYY", Newdate) DateMonth = DatePart("M" , Newdate) DateDay = DatePart("D" , Newdate) WeekOfYear = DatePart("WW" , Newdate) DayOfYear = DatePart("Y" , Newdate) WeekDayNumber = DatePart("W" , Newdate) TodayNameShort = WeekdayName(WeekDayNumber,True) TodayNameFull = WeekdayName(WeekDayNumber,False) MonthNameShort = MonthName(DateMonth,True) MonthNameLong = MonthName(DateMonth,False) Wscript.Echo DateYear&" "&DateMonth&" "&DateDay&" "&WeekOfYear&" "&DayOfYear&" "&WeekDayNumber&" "&TodayNameShort&" "&TodayNameFull&" "&MonthNameShort&" "&MonthNameLong else Wscript.Echo "ERROR" end if Code: [Select] S:\Test\Batch\querydate>qdate.bat Enter Date:23-11-2008 Data for Date: 23-11-2008 Date Year : 2008 Date Month : 11 Date Day : 23 Week Of Year : 48 Day Of Year : 328 Day Of Week [Number] : 1 Day Of Week [Short Name] : Sun Day Of Week [Full Name] : Sunday Month [Short Name] : Nov Month [Long Name] : November Sunday, November 23, 2008 is/was/will be in week 48 S:\Test\Batch\querydate>qdate.bat Enter Date:34-9-1788 Data for Date: 34-9-1788 Error: invalid date |
|
| 6095. |
Solve : DISKPART bat? |
|
Answer» HI to all i just join this wonderful forum. i like computers and stuff like these kind of taste of programming, since i dont study programming my knowledge is bit little. my point is i WANT to make a batch file to run DISKPART i started with still line START C:\Windows\SYSTEM32\DISKPART.EXE now for the PART where i would need to set to choice to SELECT VOLUME 3 how do i add these kind of paremeters??? thanks You would create a text file with the commands you want Diskpart to execute, and then invoke Diskpart with the textfile path and name as one of the parameters. http://blogs.msdn.com/embedded/archive/2005/12/23/506404.aspx http://support.microsoft.com/default.aspx?scid=kb;en-us;300415 I actually wrote a batch file using diskpart and turned it into a USB Pen Drive Letter switching EXECUTABLE. The problem is that you cant hard code the Volume selection or the drive letter to assign it to!! So what i did was take the users input, export it into a text file and then run disk part against the text file using the -s (script)parameter. Here's my code if you'd like to take a look and the executable itself can be downlaoded from here: http://feartechsolutions.proboards.com/index.cgi?board=feartechprograms&action=display&thread=1 Code: [Select]@echo off color 0E mode con lines=22 cols=86 echo>list.txt echo>list.txt list volume @echo on diskpart -s list.txt @echo off set /p DLA=Enter desired volume: echo: set /p LTT=Enter drive letter: echo: echo>move.txt echo>move.txt list volume echo>>move.txt select volume %DLA% echo>>move.txt assign letter=%LTT% @echo off diskpart -s move.txt echo: Del /f "list.txt" Del /f "move.txt" echo: echo: pause exit /b Hope this HELPS Russ |
|
| 6096. |
Solve : Batch file to make backup of a folder based on time and day of week? |
|
Answer» Thank You Dusty, I tried the script at WORK and i do not know exactly was the wording of the error was, so sorry for the confusion but the taskkill wpont work because CHeckInn need to exit by pressing Exit on its menu screen so i found a program called Eventcoder and i recorded the mouse movement to click Exit and I added the path in the script to run where the Taskkill command LINE use to be and it worked perfectly. So i deleted the sleep command lines and the whole script ran perfectly. @echo off and the end of the script to this: Quote echo No>runit.dat Create the file C:\runit.dat containing just the word "Yes" without the quotes. Create the following script and save it as filename.bat: Quote @echo off Task scheduling Suggestions. =================== Schedule the main script to run at the times you want, 3 6 9 and 12 pm (note that according to the specs I extracted from your post, these times to not include any backup in Shift A which I have noted as being 4 am to 2pm daily, please confirm). Also schedule the script to start 5 mins after the above times. This will allow the script to run at the appointed hours and at five mins after those times if backup does not proceed. Schedule filename.bat to run at say 3.20 6.20 9.20 and 12.20 pm Thanks Dusty, The Backup is running good so far except i have not added the last post suggestions yet, I wanted to try it first. I a wondering is there a way to get out of screensaver when the batch file starts or say play a music file in wma format so that to bring attention of the person working? I will add script from your last post tomorrow and let you know how it goes. Thanks Again.Hi i m new to batch file can any one plz tell me the batch file making process from begning. will appericiate for helping me out. regds himHim6182 - Welcome to the CH forums. Please do NOT hijack another member's thread, start your own. Batch scripting info can be found here and there a many many on-line tutorials. Good luck |
|
| 6097. |
Solve : Batch How to handle multiple IF conditions? |
|
Answer» How to handle multiple IF conditions in a batch scripting |
|
| 6098. |
Solve : Beep.com for DOS ?? |
|
Answer» Was there ever a BEEP command for DOS? |
|
| 6099. |
Solve : Copy file in Command Prompt? |
|
Answer» From: c:\testfolder1\testfile1.docx |
|
| 6100. |
Solve : Delete of Copy Max or Min file size from a directory? |
|
Answer» I want to copy maximum size file one directory to another and delete minimum file size one directory using batch file. Can ANYONE help me? yes, let me dash my magic wand and make a script appear! |
|