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.
| 2801. |
Solve : Please explain me? |
|
Answer» I did write the following C code. I was able to use the TCC complier. I did not write the C code. I was able to use the TCC complier. I did not write the C code in the post above . I was able to use the TCC complier. Output was displayed. |
|
| 2802. |
Solve : Need help making Batch program? |
|
Answer» Hello, |
|
| 2803. |
Solve : path to run a batch script? |
|
Answer» Hi,
One problem might be the use the command "dir" as a folder NAME: d:\NEW\test.bat or c:\>D: D:\>cd new D:\new\> test.bat |
|
| 2804. |
Solve : How to read inputs from a file & process the program? |
|
Answer» i am having file in which list of IP addresses are mentained, |
|
| 2805. |
Solve : How to read username of computer? |
|
Answer» Like reading HOSTNAME, DATE & time of the COMPUTER, How to read the username of the computer?- which user has logged-in?Most versions of Windows HOLD the current user name in an environment variable called... %username%Dear Salmon Trout, |
|
| 2806. |
Solve : One more Batch File ?. Launch Shortcut Key sequence via Command Line?? |
|
Answer» One more Batch File Question: Can I trigger a shortcut key sequence from a batch file (command line), as if a key combination had been pressed (ex. CTRL+ALT+B)? I don't think so. VBScript has a sendkeys method that may be helpful. Is this shortcut key sequence needed to launch a program? Let us know. Basically, I was wanting to use hotkeys that I have set up (w/ my 'HotKeyControl' program) to trigger things. Some for STARTING programs, yes. Where's a good place to learn about VBScript? Is it difficult? And what type of (authoring/?compiling?) programs do you need for that? Thanks.Scratch the questions above about VBS Scripts. I found some info on the net. |
|
| 2807. |
Solve : accessing CD Rom? |
|
Answer» While in command prompt, I can not get in to the CD rom drive, it keeps saying INVALID drive. I need to get in to the cd rom for i can install Windows XP (rebuilding computer).....I'm lost as what the problem is?Actually you will not find the same drive as you found while using CD drive on XP While in command prompt, I can not get in to the CD rom drive, it keeps saying invalid drive. I need to get in to the cd rom for i can install Windows XP (rebuilding computer).....I'm lost as what the problem is? There shouldn't be a prompt. if you are getting a Prompt, you did something wrong. Installing XP is as simple as booting to the CD-ROM. If you are booting instead to a MS-DOS boot disk (which interestingly is what most VERSIONS of windows make when you check "make a system disk" in the format dialog, which makes it absolutely useless), then you won't be able to access either the hard drive or the CD-ROM drive. (you can get CD-ROM access if you install a CD-ROM driver via config.sys, but seriously, that's more trouble then SIMPLY booting to the disc).The hard drive I have installed have a copy of XP on it; however it is corrupted with files missing, so it will not load. It does load to MS-DOS command prompt though. I've changed the BIOS to boot to the CD-Rom instead of the hard drive, however when I do that, it then says system halted & won't do anything else. Quote from: bikerlbf406 on June 17, 2010, 02:16:28 AM It does load to MS-DOS command prompt though. One problem. Windows XP doesn't have a "command prompt" that can run at boot-up. Quote I've changed the BIOS to boot to the CD-Rom instead of the hard drive, however when I do that, it then says system halted & won't do anything else. Sounds like a hardware issue, actually.I cant explain whats happening; however it boots up to MS-DOSBetter suggestion would be purchase a Bootable XP CD. I think you are not using that. Cause bootable dosen't need to be located for the setup file. I have been installing XP for many years. So, I never had problem. I am sure you written it from the computer. And you forgot to copy the boot.ini file. Now, days you can use bootable USB drive to install windows. So, the best would be use bootable CD or USB drive. Else you wil running in loop and never get to an end. Regards VishalThank you for for replies. After the last one & some investigation I realized that I wasn't GOING to get anywhere doing what I wanted, without buying a new cd. I was able to get around it though, by simply finding another old hard drive that I had around, alot smaller though, that had a full version of Windows ME on it. I just put the hard drive i wanted in as a slave & installed XP to it that way. Everythings working smoothly now. Thanks again. |
|
| 2808. |
Solve : Batch File: One Prog won't run (start /d), but all others do.? |
|
Answer» I have a Start Up .bat file I wrote. The first two programs start fine, but the third program (convert.exe) will never start from the batch file (It starts fine, normally). How do you know it never starts from the batch file? Does it throw an error? Does convert.exe run in Windows or the CMD shell? Does convert.exe create a log file you can check for more information? What do you mean by it "starts fine normally"? Define normal. NEED more information, but it does seem curious. By *normally*, I mean that it runs fine if I run it from, say, the Start Menu shortcut link (or by double clicking it from its .exe). So I know it works. I just can't get it to run/start from a .bat file for some reason. It doesn't even show up in Windows Task Manager Processes as RUNNING hidden (when run from a .bat). Does that clarify better? Thanks.Are you sure that convert.exe is actually in that folder (C:\Program Files\Convert) and not some sub folder? Why are you using the /d switch? Is there some special reason you can't do this? Code: [Select]start "C:\Program Files\Convert\Convert.exe"Yes. Convert.exe is located in the right place (C:\Program Files\Convert\Convert.exe). I learned to USE the /d switch For when you start a program (I don't even know what it does exactly). Is it not NECESSARY? I figured out another way to make it work, though... Using a vbs script. [[ The *special reason* to do it?... Yes, I could manually start it myself. But I wanted to start several programs together with the click of one mouse button. Programs that I use for work... to start up my 'work environment'. ]] Thanks for your help.You misunderstood my question. Why don't you start convert.exe from a batch file (not "manually") with a line like this... Code: [Select]start "C:\Program Files\Convert\Convert.exe" That is, start followed by a space then the program drive letter, path, and filename (all in quotes because of the space in 'Program Files') Have you tried this? The /d switch changes to the directory that is named; you would do this if you wanted to actually be in that directory for some reason. If you did not need that specifically, you would use the FORM that I described above. Ok... gotcha. And thanks, also, for correcting me about the /d switch. Don't need it now, but might in the future (now that I know what it's for). |
|
| 2809. |
Solve : hide this one!? |
|
Answer» is it possible to hide this message "Could not found c:\test.xls" |
|
| 2810. |
Solve : Get to Other Bookmarks in Firefox using NirCmd?? |
|
Answer» Hello. I'm not getting assistance with my question here: Is that roast beef at the bottom of the pic ? ?... It's part of some girl's dresses in the bottom left of a painting called 'A Tale from the Decameron' by John William Waterhouse (my wallpaper at the the time). Quote from: patio on January 01, 2018, 07:10:38 AM I knew you were being frivolous, but it's such a nice painting, I thought it would liven up the thread a bit, especially since the OP seems to have lost interest. It is nice...I remember when i had a slideshow of M.C. Esher drawings as my wallpaper....i never got any work done...Salmon, can you try that .BAT file . . . . . . but make sure that neither the Firefox browser, nor a copy of the Library "skin" is open. I think that what you'll see is that it will open the Library "skin" to "All Bookmarks", but NirCmd won't do anything. . . . ie. The sendkeys will not "act on" the Library "skin" From what I'm seeing, NirCmd needs one of the above two "already open" in order for it to be able to workHey, you're right. If you only start one nircmd exec show Firefox, the send key stuff does not work, but if you start two, it does work on the second one. However, if I start two Library windows, then kill the first one, the send keys stuff works on the second one. "C:\utils\nircmdc.exe" exec show "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -chrome "chrome://browser/content/places/places.xul" "C:\utils\nircmdc.exe" exec show "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -chrome "chrome://browser/content/places/places.xul" REM Wait for Firefox to get going REM You could use a SLEEP command here INSTEAD if you have sleep.exe :loop tasklist /v | find "Library" && GOTO next goto loop :next REM On my system I needed at least 5 milliseconds of sleep REM Maybe 10 or 100 would be safer REM Using the sleep.exe with the -m option REM In the Windows 2003 Resource Kit Tools REM https://www.microsoft.com/en-us/download/details.aspx?id=17657 REM sleep -m 10 REM Taskkill will terminate the first window it finds with the title "Library" REM which will be the first one you started then exit, leaving the second one running taskkill /FI "WINDOWTITLE eq Library" "C:\utils\nircmdc.exe" win activate title "Library" "C:\utils\nircmdc.exe" sendkey pagedown down "C:\utils\nircmdc.exe" sendkey enter down "C:\utils\nircmdc.exe" sendkey pagedown up "C:\utils\nircmdc.exe" sendkey enter up Here's what I figured out. There's too much to put here, so, I've put it on a 4-page PDF on my Google Docs: 4 Ways to get to Firefox "Other Bookmarks", from slowest to fastest The following are 4 macros that I have in Excel 2010. The first two just use VBA. The second two use NirCmd. https://drive.google.com/open?id=1eche0L-qHRWVA_yEh0JiL1k5SNK4HpCt |
|
| 2811. |
Solve : Sort a Phone List by Last Name.? |
|
Answer» Quote from: Squashman on January 07, 2018, 03:48:34 PM Can you do a quick TEST with the Powershell code I posted. I think it will be around the same time as Dave's Jsort. 88,800 names input: sorted Z-A output: sorted A-Z GNU sort 0.40 sec Benham jsort 6.13 sec Powershell 8.49 sec Batch method 664.99 sec (11 min 4.99 sec) Technically this is a Powershell one-iner, but I broke it down to 4 physical lines for readability. If you type this at the Powershell command prompt, just keep typing when the line wraps. Code: [Select](Get-Content .\PHONE.txt) -replace '(.*?\d{3})\s(.*?)', '$1-$2' | ConvertFrom-Csv -Delimiter ' ' -Header First,Last,Phone | Sort-Object Last | Format-Table * -AutoSize You can change the path and file name in the first line. Technically this is a Powershell one-liner. I broke it into 4 physical lines for readability. If you do type this in a Powershell window, type all 4 lines as a single line and just keep typing when the line wraps. The interpreter will understand. Code: [Select](Get-Content .\phone.txt) -replace '(.*?\d{3})\s(.*?)', '$1-$2' | ConvertFrom-Csv -Delimiter ' ' -Header First,Last,Phone | Sort-Object Last | Format-Table * -AutoSize The path and file name can be changed as needed. It did it, but it ECHOED the sorted output to the console. Powershell has cmdlets for outputting to a file, however in this case redirection might be the simpler way to go. Code: [Select](Get-Content .\Phone.txt) -replace '(.*?\d{3})\s(.*?)', '$1-$2' | ConvertFrom-Csv -Delimiter ' ' -Header First,Last,Phone | Sort-Object Last | Format-Table * -AutoSize -HideTableHeaders > .\Phone.new If the preference is to have the headers in the output file, remove the -HideTableHeaders parameter from the Format-Table cmdlet. Added a timer: Code: [Select]$t = Measure-Command { (Get-Content .\Notabs_names-rev-sorted.names.txt) -replace '(.*?\d{3})\s(.*?)', '$1-$2' | ConvertFrom-Csv -Delimiter ' ' -Header First,Last,Phone | Sort-Object Last | Format-Table * -AutoSize > out.txt } echo "Time: $t" Result: Code: [Select]Time: 00:00:13.2834694 The script is clearly doing more work than just sorting: for example it is justifying the columns (input file: 2.6 MB output file: 7.8 MB) Python 88,800 names 0.138 seconds! Code: [Select]python sortfile.py > sorted.txt 2018-01-10 21:24:18.494000 2018-01-10 21:24:18.632000 Code: [Select]from __future__ import print_function from datetime import datetime import csv import operator tstart = datetime.now() reader = csv.reader(open("Notabs_names-rev-sorted.names.txt"), delimiter=" ") for line in sorted(reader, key=operator.itemgetter(1)): print(" " . join(line)) tend = datetime.now() print (tstart) print (tend)Better Python (27) Code: [Select]from __future__ import print_function from datetime import datetime import csv import operator tstart = datetime.now() f = open('output.txt', 'w') reader = csv.reader(open("input.txt"), delimiter=" ") for line in sorted(reader, key=operator.itemgetter(1)): print(" " . join(line), file=f) f.close() tend = datetime.now() print ("Elapsed", tend - tstart, "seconds") 88,800 names, 5 runs: Code: [Select]Elapsed 0:00:00.172000 seconds Elapsed 0:00:00.156000 seconds Elapsed 0:00:00.172000 seconds Elapsed 0:00:00.157000 seconds Elapsed 0:00:00.172000 seconds Here are 88,800 names sorted randomly: [attachment deleted by admin to conserve SPACE]Here's the other, 88,800 names sorted alphabetically by column (2) in reverse ORDER. I notice that the sorted file compresses better. [attachment deleted by admin to conserve space]It's quicker to sort the reverse-sorted file than the randomly sorted file. Code: [Select]reverse 0:00:00.156000 seconds random 0:00:00.265000 seconds |
|
| 2812. |
Solve : Remove the part of the multiple files? |
|
Answer» What would the the code to remove the date part of MULTIPLE FILES in a folder and rename in a DOS batch FILE. |
|
| 2813. |
Solve : Batch file to autoselect option after 1 minute? |
|
Answer» Hi all. Many years ago I had a similar question and it was answered. I can't find my old profile or the old post. I have code from another person in the forums and now I want to add a line so that it auto selects "N" after 60 seconds. I remember the command being so easy. The ERRORLEVEL environment variable is set to the index of theQuote if /DI don't recognise the /D switch for IF. Quote from: BC_Programmer on January 16, 2018, 11:32:19 AM from CHOICE /?Reading is FUN!Quote from: Salmon Trout on January 16, 2018, 12:36:32 PM I don't recognise the /D switch for IF.Quote from: Squashman on January 16, 2018, 02:09:02 PM Reading is FUN! thanks guys but I think you missing the point. My first post, the code works fine. I don't really want to use choice.exe but if I have to use it then how do i make my bat file work? Squashman gave me a code using choice.exe and it works. Now where do I go from there? I've even tried taking out the top line of my code and inserting squashman's code and using the /I switch but it doesn't work because obviously it can't find c. There is a way to not use choice.exe and I would prefer that way but if i have to use choice.exe, how do I select a choice so the bat file runs the commands after Y and N?Quote from: BC_Programmer on January 16, 2018, 11:32:19 AM from CHOICE /? Of course I haven't forgotten about you. How do I program the bat file to carry on and select y or n? When I press Y or N the bat file closes. Can you show me the code?I finally found the correct solution on google after a long time of searching. Here is my complete bat file. Please note the Error as proposed by bc_programmer. Code: [Select]@ECHO OFF :choice choice /C YN /D N /T 60 /M "Are you sure you want to continue?" IF errorlevel 2 goto :somewhere_else IF errorlevel 1 goto :somewhere pause goto :choice |
|
| 2814. |
Solve : Batch file to create folder following the name of specific file then move files? |
|
Answer» save below line as myvbs.vbs not even a thankyou for solving this problem after a yearIf you are here for teh th4nxx you are in the wrong place. |
|
| 2815. |
Solve : Date when used as folder name spanning multiple directories? |
|
Answer» Trying to get my batch to not span to multiple directories and scratching my head as to why its doing this. The way you are getting the date is region dependent. So your script may not be portable to other computers.Can slice that up @echo off for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set wmictime=%%a echo wmictime is %wmictime% REM Good ol' column ruler for monospace fonts REM Batch strings start at 0 REM 1 2 REM 0123456789012345678901234 REM wmictime is 20180118091634.523000+000 set yyyy=%wmictime:~0,4% set mm=%wmictime:~4,2% set dd=%wmictime:~6,2% set hh=%wmictime:~8,2% set mn=%wmictime:~10,2% set ss=%wmictime:~12,2% set mss=%wmictime:~15,3% set utcoffset=%wmictime:~21,4% echo yyyy %yyyy% echo mm %mm% echo dd %dd% echo hh %hh% echo mn %mn% echo ss %ss% echo mss %mss% echo utc %utcoffset% echo yyyy-mm-dd-hh-mn-ss.ms_utcoffset: %yyyy%-%mm%-%dd%-%hh%-%mn%-%ss%.%mss%_%utcoffset% Result... wmictime is 20180118093042.091000+000 yyyy 2018 mm 01 dd 18 hh 09 mn 30 ss 42 mss 091 utc +000 yyyy-mm-dd-hh-mn-ss.ms_utcoffset: 2018-01-18-09-30-42.091_+000 |
|
| 2816. |
Solve : Looking for a way to maintain path in this backup method? |
|
Answer» Stepping back even more... [UPDATE] I saw your edit. As I was half awake the light bulb finally came on after some extensive typing and I looked back and saw that you had combined it all into one. Then had a duh moment and quickly corrected via edit to my shorted response ever here at CH Took it initially as to "how does this work?" in which I didnt look at the differences in the script where you combined it all, then the lightbulb moment was I better check back at the script and see if thats my last 3rd batch or something you edited because the question is rather odd in the context that I ran with initially. Then I felt dumb that I didnt see that initially and ran with wrong context haha. Time for more coffee for me Now testing. It looks correct to me. Nothing stands out as incorrect.Works Perfect! Thank You Made a minor change to use same path as destin for logdir pointing logdir to %destin% . I was almost going to replace all the %logdir% with %destin% and remove [ set logdir = ] but decided to leave that be in case I ever wanted the path of the logging to go elsewhere [ set logdir=%destin% ] can easily be changed for an alternate path and its easier to read and follow with the naming convention you have vs reuse of %destin% in an area of the script that would make it look odd. Now to just remove the pause from tail end of it and add it to scheduled task on both computers. @echo off cls setlocal enabledelayedexpansion set datefix=%date% set datefix=%datefix:/=-% set source=z: set destin=c:\archiveshadowcopy\%datefix% set logdir=%destin% if not exist "%logdir%" md "%logdir%" if exist "%logdir%\files2copy.txt" del "%logdir%\files2copy.txt" For /f "delims=" %%F in (' xcopy "z:\*.*" "c:\zcopy\*.*" /s/d/y/h/l ' ) do ( set sfile=%%F REM Do the logging echo !sfile! >> "%logdir%\files2copy.txt" set "dfile=!sfile:%source%=%destin%!" for /f "delims=" %%A in ("!dfile!") do set destdir=%%~dpA if exist "!sfile!" ( if not exist "!destdir!" echo Creating directory "!destdir!" & md "!destdir!" copy "!sfile!" "!destdir!" ) else ( echo Source file "!sfile!" does not exist! ) ) REM Mirror Complete Source to Complete Local Backup xcopy Z:\*.* c:\zcopy\*.* /s/d/y/h pauseOn the second computer I paid more attention to what was happening and saw that it chokes on the last line from files2copy.txt, but continues chugging along and completes, so I guess to remove that error message I could add the removal of last line from files2copy.txt by using the method I have in the second batch file written into this current batch to write to xfiles2copyx.txt , then run with that file which wouldnt have a line that is invalid to the copy instruction of file count. When I put together the initial batches for each group of instructions, I expected the batch to fail on hitting the file count. I never tested leaving it in there. So it was interesting that it didnt crash the batch it simply rejected the file count and moved on. Source file "37 File(s)" does not existI took your lead on where the log should go from this in your batch (3) REM Write Log of what files were backed up to dated folders at isolated partial archive backup location copy c:\testing\files2copy.txt "c:\test2\%datefix%\*.*" ... as c:\test2\%datefix% is the same as %destin%, I hard coded it but that meant it persisted after changes you made. Sorry for the confusion. I have noticed something else... I made it so each time the new all-in-one batch is run, it blanks the log file and starts a new one, so that if you run it more than once on the same date, you will only see the last run's log results, so you might want to remove this line if exist "%logdir%\files2copy.txt" del "%logdir%\files2copy.txt" Quote from: DaveLembke on January 19, 2018, 11:34:00 AM On the second computer I paid more attention to what was happening and saw that it chokes on the last line, but continues chugging along and complete, so I guess to remove that error message I could add the removal of last line and the xfiles2copyx.txt method written, then it runs with that file which wouldnt have a line that is invalid to the copy instruction. That's just the error message I coded in to the IF block surrounding the copy operation. It isn't really necessary to show that in the console. See below. Anyhow, here's an update.... @echo off cls setlocal enabledelayedexpansion set datefix=%date% set datefix=%datefix:/=-% set source=z: set destin=c:\archiveshadowcopy\%datefix% set logdir=%destin% if not exist "%logdir%" md "%logdir%" if exist "%logdir%\files2copy.txt" del "%logdir%\files2copy.txt" For /f "delims=" %%F in (' xcopy "z:\*.*" "c:\zcopy\*.*" /s/d/y/h/l ' ) do ( set sfile=%%F REM Do the logging echo !sfile! >> "%logdir%\files2copy.txt" set "dfile=!sfile:%source%=%destin%!" for /f "delims=" %%A in ("!dfile!") do set destdir=%%~dpA if exist "!sfile!" ( if not exist "!destdir!" echo Creating directory "!destdir!" & md "!destdir!" copy "!sfile!" "!destdir!" REM ) else ( REM echo Source file "!sfile!" does not exist! ) ) REM Mirror Complete Source to Complete Local Backup xcopy Z:\*.* c:\zcopy\*.* /s/d/y/h pause Quote from: DaveLembke on January 19, 2018, 11:34:00 AM When I put together the initial batches for each group of instructions, I expected the batch to fail on hitting the file count. I never tested leaving it in there. So it was interesting that it didnt crash the batch it simply rejected the file count and moved on. That's because if exist "!sfile!" checks if that line corresponds to a real, actual file.(As I mentioned above (U need cofffee!!!) Time for another coffee break. haha Thank You Did you see this? I have noticed something else... I made it so each time the new all-in-one batch is run, it blanks the log file and starts a new one, so that if you run it more than once on the same date, you will only see the last run's log results, so you might want to remove this line if exist "%logdir%\files2copy.txt" del "%logdir%\files2copy.txt" Thanks.. I only run the backup once a day, but just in case it is run more than once I removed that so it will append to the log file. Decided to make it more user friendly for altering paths, so that the 4 paths just need to be set (Source, Full_Local_Backup, Archive, and Logging ) *In bold are changes made. Might even set the log file name and make it dynamic below too. Undecided on that. Quote @echo offHello salmon ... I dont need to see message about file count. ((( Update: Just realized when i pulled up this page and selected ALL it somehow showed the last item on page 1. So I thought this was a recent question as seen in pic. Time for more coffee ))) Some updates to this that dont really affect what was created is that I added another location that isnt in a hidden directory and gave the users the ability to have access to a copy of what is archived in c:\archiveshadowcopy at a location of c:\shadowcopyarchive. No one but me knows about the hidden full local backup at c:\zcopy and the archive by date at c:\archiveshadowcopy . I figured I would trust the 12 users to have access to a copy of the archive data which they have been instructed not to use any files here as active documents to build on from until a copy of whatever file they need is moved away from C:\shadowcopyarchive to their workspace on the NAS. I was going to flag all data as read-only, but decided to hold off on that because the users arent skilled enough to flip it back to read/write permissions. So going to see how it goes with read/write enabled archive space. If they foul up their archive by accidentally deleting something or altering something, I still have the hidden hands off location to get the original data from. The users are very excited that any data saved before 2am is recoverable in the future as for lots of users have lost data before. The setup is just 2 computers SHARING a low cost NAS for our union here. And because of my skills I was asked to make things better. Data integrity was the first importance to make corrections to. There were users not even using the NAS at times and data stored locally etc, it was a big mess. I set everyone up with their own user accounts and mapped space to their private folders and shared folders on the NAS, and set the default save locations to point to the NAS so that they have to intentionally tell it to save elsewhere. So the backup solution I have in place is to use the extra space on the workstations in hidden folders to mirror the NAS data, then implement this batch that you helped greatly with to establish an archive that can be navigated by dated folders to have access to older versions of files if need be. Because everyone who has access to the computers is trusted and everyone is aware that their data can be seen by others who have the computer access, having everyones data accessible in one location in the archive where NORMALLY they only see their W: drive as their space isnt an issue. Each user has a folder in the archive that is named for easy identification. One last final piece to the project will be to set up a google drive and have that mirror to the Z: drive, but it would need to be selective in what if backed up to the cloud as for we have more than 15GB of data. This way if there was ever a fire etc, the most important recent data isnt wiped out. [attachment deleted by admin to conserve space] |
|
| 2817. |
Solve : Batch file - check if program is running and switch to it? |
|
Answer» Are there commands to check if a program is already running, and give an external program focus? Thanks. This seemed to work for me, but what is the command to bring focus or switch to the program?A 3rd PARTY program MIGHT be able to do it, but I doubt it. Batch can't normally do that... appactivate (or something close to that) in a .wsh file may do it...I found it in the MSDN for SendKeys.instead of doing "c:\blah.exe" , you can do "start c:\blah.exe" Launched from cmd or bat, the first waits for blah.exe to finish/terminate. The second SAYS to launch blah in a new window and continue what we're doing.Quote from: uniquegeek on March 31, 2011, 09:42:07 AM instead of doing "c:\blah.exe" , You have revived a two year old thread. i think this can also be a alternative. @echo off tasklist /nh /fi "imagename eq notepad.exe" | find /i "notepad.exe" if errorlevel 0 if not errorlevel 1 goto IsRunning start /b notepad.exe :exit pause exit :IsRunning echo Cannot Have Multiple Interface Process Please Check the... pause exitThis thread was last posted to 3 years ago, and it was created 6 years ago. Just sayin' Hello, I am having a peculiar and specific problem. When I use a batch file to test if, say, "notepad" is working, I use the simple program here: //////// SETLOCAL EnableExtensions set EXE=notepad.exe FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND echo Not running pause goto FIN :FOUND echo Running pause :FIN //////// And it works, of course. But not if I change the second line to: set EXE=dbase.exe This batch file doesn't see that ol' dBase IV is running when it is running. (I still have the program execute notepad because I don't want the trouble of two versions of dBase fighting over files.) Is there something else I should know about this or is there an alternate test out there? Does this have something to do with running a legacy program like Ashton-Tate's dBase IV? (The program works well except when someone tries to run two versions of it at the same time.) I THANK anyone for their time.Once again...the Thread that will not die... |
|
| 2818. |
Solve : Net Stop service ... question? |
|
Answer» I am trying to figure out a service name for a TCI VT100 Service so I can NET STOP and NET START it to allow the USERS reset the service through a batch file SHORTCUT on their desktop. |
|
| 2819. |
Solve : Confused: batch file to kill itself ?!?!? |
|
Answer» What I'm trying to do is, if an old instance of my batch FILE is currently running, then I would like my batch file to kill it and start a new instance. I can do this in Java, but is this possible using a batch file? where's the challenge and fun in that? Yeah. This type of thing requires all sorts of convolutions to get working in an actual programming language- such as C/C++, involving FIRST determining wether a previous instance exists, getting it's processID, grabbing the top level window of that process, and sending an Application message to it with the command line arguments of the new instance, and then the new instance quits. the old instance processes the message and loads the command line- for example file names. Some would say to just use KillProcess on the old instance. Well that would A: destroy everything changed in the original documents in the first process, and B: possibly leave open handles to files and devices. Java has it easy since the VM will do all the real work. |
|
| 2820. |
Solve : ultimate noob question: how do you close dos?? |
|
Answer» I was just playing AROUND on the computer and I typed command in the "run..." THING. If you *MADE* The batch file open Cmd, it'll do that. It's fine, just X it. I really don't want to screw this up, so I'm going to be very careful. Here is what I did: 1. CLICKED start 2. Clicked "run" 3. Typed Command. Pressed Enter 4. Played around (typed stuff in), but didn't amount to anything 5. Now I want to get rid of the dang thing, but if I press X I get the end program window ITS OKAY? I gotta be sure. It isn't my computer.EXIT |
|
| 2821. |
Solve : Copy and start? |
|
Answer» How do i make a file that is copied to a random place start once it is copied. |
|
| 2822. |
Solve : virtual 8086? |
|
Answer» I asked this recently but I'm afraid I may have worded it wrong. I have an ME system. I don't know what my dos version is. I loaded some early dos shareware, then TRIED to run Ultima7, and got the error message that my system was in virtual 8086 mode, and that I should remove the OFFENDING SOFTWARE. I deleted the dos shareware games and still got the error message. I ALSO get that message to remove expanded memory. |
|
| 2823. |
Solve : trouble with a for loop? |
|
Answer» Ok, I'm using for loops now. So, here's what I'm doing |
|
| 2824. |
Solve : Open Sys files with Dos? |
|
Answer» Hello So there's no way to start them? Please explain what you mean by "start".YOU don't start .sys files... YOU don't open system files.... YOU don't edit system files.....that's why they are called "System files". They are started by the system, often thru a program like Config.sys Now, if you put a .sys file, like Himem.sys in a config.sys file, which you can create or edit, then the system will run it when it boots (in DOS). Edit.com in DOS or Notepad in Windows can be used to create or edit a Config.sys file. But even if you create and/or edit a Config.sys file, YOU don't start it......DOS will start it when it boots up the computer. I hope that helps! Shadow Quote from: THESHADOW on February 08, 2009, 08:12:29 AM YOU don't start .sys files... YOU don't open system files.... YOU don't edit system files.....that's why they are called "System files". Thanks for backing up what I SAID before, TheShadow. Maybe he'll believe two of us... Quote from: Dusty on February 07, 2009, 07:16:34 PM In the days of MS-Dos MSDOS.SYS was a plain text file which could be opened/edited using a plain text editor such as Edit.com or Notepad.exe (Win 9x/ME). If your operating system is an NT variant, forget it, .sys files look like binaries. That was true exclusively for the DOS versions provided in Windows 95,98, and ME. DOS VERSION prior to that were binary code... But they are quite right- device drivers are loaded by DOS at boot time. |
|
| 2825. |
Solve : Dos=?? |
|
Answer» guys whats the first thing to do if u wanna be an EXPERT in computers?? learning programming? i was thinking Turbo C. its really hard to understand Dos commands if u aren't familiar with the Terms. Being "an expert in computers" is pretty vague. I think you should start off by picking an area of expertise in computers and CONCENTRATE on that. its really hard to understand Dos commands if u aren't familiar with the Terms.I think it is hard to understand almost anything until you become familiar with it. Turbo C is also really hard to understand if you aren't familiar with the terms (in my opinion much harder than DOS, since there are only about 150 commands (even taking into account the extended set of internal and external commands in CMD), where there are several hundred functions in Turbo C (and learning how to pass pointers to variables between functions in Turbo C usually requires a lot of practice). So pick a topic to start from (maybe Turbo C, or "DOS" commands, or STORAGE, or memory, or computer SECURITY, etc.) and expand from there.Quote its really hard to understand Dos commands if u aren't familiar with the Terms. Huh It's really hard to win (or finish) races when they put the finishing line so *censored* far away from the start! I so agree with GuruGary. Start out small and build from there. You could argue that there is no such thing as an expert in "computers". You can be big in programming, or hardware, or OS, or whatever, or (more likely) some sub topic, maybe, after going to college and putting in lots of effort, but I don't think anybody knows everything about everything. Find out what you like best, what you're good at, most important: find out where to find out what you need to know, and stick at it! Good luck. I know a guy who is an absolute whiz at hardware design, he is a top guy in a particular field in chip layout and has been headhunted by major companies, and he can't write batch files or bash scripts to save his life! He's good at Ruby though. |
|
| 2826. |
Solve : Dos newbie? |
|
Answer» *Smack head* *Smack head* http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=endang thats got a lot of tools and they are all command line?Quote from: macdad- on February 03, 2009, 12:41:22 PM dang thats got a lot of tools Many of them are. awesome, gotta download this. and thanks for the link Quote from: Dusty on February 01, 2009, 11:09:49 PM Flux - Welcome to the CH forums.dude thanks for the link. i really appreciate your HELP. im sure these would do.Quote from: macdad- on February 02, 2009, 06:27:04 AM PING -n 1 -w 1000 1.1.1.1 >nul It is actually a very bad practice to ping an IP address that you don't administer or have control over. Besides not being polite (depending on how it is used and how often it could be considered a denial of service attach which I know is not your intent), it is not reliable. For example, I assume by your example that your are expecting 1.1.1.1 to not respond to your ping (ICMP echo request). If the owner of that IP decides to one day enable ICMP echo for that IP address, then your command above would only pause for a few milliseconds. It is much better to ping something that you have control over, such as localhost, or 127.0.0.1. You can use Code: [Select]ping -n 2 localhost >NULto pause for about 1 second (the number should be n+1 where n is the number of seconds to pause because the 1st reply should be INSTANT, and the others will wait 1 second by default). I hope nobody takes offense to this ... just trying to point out a better way. good point |
|
| 2827. |
Solve : how to use "choice" command in Win XP? |
|
Answer» i have learnt that i cannot use CHOICE COMMAND in batch file in XP COMPUTER. And if i want to use how can i modify ? PLZ, help me.the CHOICE.EXE prog your using, is it the NT version? |
|
| 2828. |
Solve : How to convert short paths to long paths?? |
|
Answer» Does anyone know of a way to convert short PATHS to long paths? There is a function in Windows for that. But if you tack it into java you will have code that can not port across platforms. Which is one reason for musing java. Code: [Select]@echo off @echo set oArgs = Wscript.Arguments>"%TEMP%\LongFileName.vbs" @echo wscript.echo LongName(oArgs(0))>>"%TEMP%\LongFileName.vbs" @echo Function LongName(strFName)>>"%TEMP%\LongFileName.vbs" @echo Const ScFSO = "Scripting.FileSystemObject">>"%TEMP%\LongFileName.vbs" @echo Const WScSh = "WScript.Shell">>"%TEMP%\LongFileName.vbs" @echo. With WScript.CreateObject(WScSh).CreateShortcut("dummy.lnk")>>"%TEMP%\LongFileName.vbs" @echo. .TargetPath = CreateObject(ScFSO).GetFile(strFName)>>"%TEMP%\LongFileName.vbs" @echo. LongName = .TargetPath>>"%TEMP%\LongFileName.vbs" @echo. End With>>"%TEMP%\LongFileName.vbs" @echo End Function>>"%TEMP%\LongFileName.vbs" set sfn=C:\PROGRA~1\MOZILL~2\firefox.exe for /f "Tokens=*" %%a in ( ' cscript //nologo "%TEMP%\LongFileName.vbs" %sfn% ' ) do set LFN=%%a echo %lfn% WOW! This looks really hopeful. I wish I understood it or how to use it. I copied it and put it into a batch file and ran it but it flashed by so fast I could not see any output. Remember I am a new B. N.OK I looked into my \Local Settings\Temp folder and found LongFileName.vbs. Which looks like this: Code: [Select]set oArgs = Wscript.Arguments wscript.echo LongName(oArgs(0)) Function LongName(strFName) Const ScFSO = "Scripting.FileSystemObject" Const WScSh = "WScript.Shell" With WScript.CreateObject(WScSh).CreateShortcut("dummy.lnk") .TargetPath = CreateObject(ScFSO).GetFile(strFName) LongName = .TargetPath End With End Function Then I copied and pasted into a HTML file like this: Code: [Select]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>shortToLong</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <script language="VBScript" type="text/vbscript"> set oArgs = Wscript.Arguments wscript.echo LongName(oArgs(0)) Function LongName(strFName) Const ScFSO = "Scripting.FileSystemObject" Const WScSh = "WScript.Shell" With WScript.CreateObject(WScSh).CreateShortcut("dummy.lnk") .TargetPath = CreateObject(ScFSO).GetFile(strFName) LongName = .TargetPath End With End Function </script> </body> </html>When I try to view in a browser I get an error (No Surprise since I don't really know what I'm doing) I've attached a screen shot of my error. Thanks for your help. [attachment deleted by admin]Well I figured it out. It works!! I'm so happy. Thank You Dias de verano! In the command line I type: Code: [Select]cscript LongFileName.vbs "C:/PROGRA~1/MOZILL~1\firefox.exe>vb.txtAnd sure enough the vb.txt file is written with Code: [Select]Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. C:\Program Files\Mozilla Firefox\firefox.exe If there was some way to suppress the writing of the first TWO lines that would be nice but not necessary. Again Thank You! Quote from: nubia on February 06, 2009, 10:21:36 PM If there was some way to suppress the writing of the first two lines that would be nice but not necessary. Incidentally, you don't need that SINGLE quote mark before the short filename. To run a VBscript with cscript.exe, without those 2 lines, you can add the //Nologo switch after the cscript command thus: cscript //Nologo LongFileName.vbs C:/PROGRA~1/MOZILL~1\firefox.exe>vb.txt Alternatively, you can beforehand get cscript.exe to save the //Nologo option by doing this: cscript //Nologo //S Afterwards, when you run any script with cscript.exe, on the same COMPUTER system, the //Nologo option is default and need not be included in the command. However this has the disadvantage that if the command is used on another system the option may or may not have been thus saved, and therefore the output of the script is unpredictable. So you should always include the //Nologo switch when supplying the script and command to other people (or explain all of the above, whichever seems appropriate!) To restore the default behaviour to cscript.exe: cscript //Logo //S Use either switch to force the desired behaviour when running a script. Although I have used capital letters N and L in the switches, they are not case sensitive. type cscript /? at the prompt to see full details of options. Code: [Select]C:\>cscript //nologo //S Command line options are saved. C:\>cscript //logo //S Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved. Command line options are saved. C:\>cscript //nologo //S Command line options are saved.Again Thank You -You have been more than helpful. I really appreciate the time and effort you have taken to help me. Nubia. |
|
| 2829. |
Solve : Dir command in For loop? |
|
Answer» Win XP Home. Volume in drive C is MASTER Quote Volume in drive E is SLAVE When I run the following script 2811 is returned not, as I expected, 1374. Can someone please explain why the Dir command in the For loop is not picking up drive E: and defaulting to C:? Quote @echo off I don't want a workaround, I can do that USING CD or Pushd, just an explanation of why Dir is not opting for partition E:. Dir/b e:\dates.bat at the Command Prompt works perfectly. Thanks. V. My guess is that you are running the batch file from the directory that the 2811 byte file is in. I think the issue is that DIR /B will probably return just the filename instead of the entire path without the /S. And your parameters are not following the syntax for the DIR command (I don't think that is an issue in this case, but I would clean it up anyway). To verify my theory, try this: Code: [Select]@echo off cls for /f %%A in ('dir e:\dates.bat /b') do ( echo FULLPATH=%%~fA echo Size=%%~zA ) You said you don't need a work-around, which is good - because the only thing I can think of would be to add a /S to the dir command which could add a significant amount of time to the script because it would search your entire E: drive for files named "dates.bat".Thanks for that GuruGary. Quote My guess is that you are running the batch file from the directory that the 2811 byte file is in.You are correct, the batch script is located in C: which is the default directory. Your script returned Quote Fullpath=C:\dates.bat I just don't understand why dir is defaulting to C: when E: is the target partition. I'm just going to throw this out there and see if it sticks. Use the set command to see if a dircmd variable exists. Generally USED for default switches, it may have a value that is interfering with your execution of the dir command. Quote from: ValerieMay on February 09, 2009, 01:26:56 AM I just don't understand why dir is defaulting to C: when E: is the target partition. Because using DIR with /B and without the /S the output is just "dates.bat" (without a path). So if a file with the same name happens to be in the current directory, then it uses that file. To see what I am talking about, make one more modification to your FOR loop: Code: [Select]for /f %%A in ('dir e:\dates.bat /b') do ( echo Full path to file returned by DIR=%%A echo Fullpath=%%~fA echo Size=%%~zA )You can then compare that to using the /S on the DIR command like Code: [Select]for /f %%A in ('dir e:\dates.bat /b /S') do ( echo Full path to file returned by DIR=%%A echo Fullpath=%%~fA echo Size=%%~zA )My guess is that the 2nd script will work the way you expect, but take longer to finish. Code: [Select]for /f %%A in ('dir e:\dates.bat /b') do ( echo Full path to file returned by DIR=%%A echo Fullpath=%%~fA echo Size=%%~zA )Returned Quote Full path to file returned by DIR=dates.bat Code: [Select]for /f %%A in ('dir e:\dates.bat /b /S') do ( echo Full path to file returned by DIR=%%A echo Fullpath=%%~fA echo Size=%%~zA )Returned Quote Full path to file returned by DIR=e:\dates.bat Exactly as you predicted the latter TOOK a while. I'm still at a loss to understand why Dir will not access the targetted drive without the /S switch. Thanks for your interest. Sidewinder - thank you. My Dircmd is set to /OG/ON/P but removing these switches made no difference, my script still defaulted to C:. Quote from: ValerieMay on February 09, 2009, 01:15:13 PM I'm still at a loss to understand why Dir will not access the targetted drive without the /S switch.There are 2 separate tasks involved. 1) The DIR command is returning a file 2) The command interpreter uses the file returned by DIR to give you the size If you look at the 2 outputs from your last run, you can see that the the first one says Quote Full path to file returned by DIR=dates.bat And the second one (that used the /S) says Quote Full path to file returned by DIR=e:\dates.bat So in the first example all the command interpreter has to go by is just a file name without a path. If a file that matches the request is in the current directory then it returns that INFORMATION (file size). It is basically the difference of doing: Code: [Select]for %a in (dates.bat) do echo %~za(which will return the size of dates.bat in whatever the current directory happens to be) and Code: [Select]for %a in (E:\dates.bat) do echo %~zawhich will return the size of dates.bat in the specified path. Does that help?Yes, somewhat, though I must admit the fog has not completely cleared. I now realise that /F and the Dir command were not required at all. Thank you for your time and patience. V.. |
|
| 2830. |
Solve : How to execute batch file in sched time unnoticable/invisibly?? |
|
Answer» Is there a way to Run the batch file with out popping-up the COMMAND PROMPT window? Why? Quote from: BatchFileCommand on February 10, 2009, 06:04:52 AM Why does everybody want there batch files to run in the background? Because my batch file will execute for about a minute. it will be destructive to the user if it runs for about a minute... He/she may CANCEL the batch file. anyway, i have alternative command Start /minWhat is this supposed to do? Quote it will be destructive to the user if it runs for about a minuteYou mean, in a minute, the computer will be....destroyed?Quote from: Carbon Dudeoxide on February 10, 2009, 06:28:42 AM What is this supposed to do? I'm hoping he meant "it will be disruptive to the user" and not "it will be destructive to the user"!Quote from: GuruGary on February 10, 2009, 06:33:47 AM Quote from: Carbon Dudeoxide on February 10, 2009, 06:28:42 AMWhat is this supposed to do? Thanks for correction... Still, what does it do? |
|
| 2831. |
Solve : trim beginning digits,symbols and space off filename? |
|
Answer» Hi there, otherwise, a line to trim the first digit would be fine. Since trimming the 1st character is pretty easy, I'll give you an example on how to do that. The other can be done, but with batch the only ways I can think of to do it would take many more lines of code. Have you considered a file renaming program? My favorite is BRU or Bulk Rename Utility at http://www.bulkrenameutility.co.uk/ Anyway, here is some code. The way it is here, it will work on the current directory and all subdirectories. If you only want only the current directory, take out the /S. If there is already a file with the same name, it will probably give an error for that file and keep going. I have it ECHO the results so you can see what it will do instead of actually renaming. Bulk renaming can be dangerous, so be sure it is doing what you want it to do, and / or have a backup! Code: [Select]@echo off setlocal enabledelayedexpansion for /f "tokens=*" %%a in ('dir *.mp3 /a-d /b') do ( set CurrentFile=%%a echo ren "%%a" "!CurrentFile:~1!" ) If you only want to trim the 1st character if it is a digit, you will have to add some code to check for a digit ... something like replacing your REN line with Code: [Select]set FirstChar=!CurrentFile:~1,1! if !FirstChar! GEQ 0 if !FirstChar! LEQ 9 echo ren "%%a" "!CurrentFile:~1!" You could do something similar to check for files that don't begin with a-z or A-Z (IF NOT statement) Hope that helps. I do not like that bulk rename utility. It's hard to use. It's complicated. A batch file that size could sweep the computer from head to toe. It doesn't have a very well designed interface, but it doesn't take too long to get used to.I was going to use it to rename some of my NES ROMs, but then I realized that there are goodtools for that and NSRT for SNES... so I've yet to find a reason to use it. Not sure what you mean: Quote from: BatchFileCommand on February 09, 2009, 07:14:08 PM A batch file that size could sweep the computer from head to toe. that's why he's got it set to echo the renaming behaviour rather then actually do it.Quote from: BC_Programmer on February 09, 2009, 08:21:10 PM Not sure what you mean: That program is like 500 kb. Not saying that it's to big for the computer. But if you had a batch file that was 500KB it could sweep the whole computer and rename tons of files.Hey, thanks guys for your help and replies. I haven't really got that far yet...As I'm an absolute beginner, I guess it'll take me a great while to figure out and learn from your codes. But great thanks anyways, it makes a good goalpost P.S. yes, I use a RENAMER. I picked that up from a previous FAQ post here. Great forum anyways, keep up the good work here! Quote from: BatchFileCommand on February 10, 2009, 06:14:34 AM Quote from: BC_Programmer on February 09, 2009, 08:21:10 PMNot sure what you mean: The rename function in ExplorerXP is excellent, not too complicated but very powerful. Doesnt work in vista though |
|
| 2832. |
Solve : Problem with variables? |
|
Answer» Okay. I'm making a simple alarm batch file. Then for the TIME, I want to extract the seconds from the %time% variable. Let me show you what I mean It sounds like you want |
|
| 2833. |
Solve : Using command prompt to disable hardware???? |
|
Answer» Is there a way to disable HARDWARE connected through (COM & LPT) port using a batch file?For what purpose are you going to use this for?I am using an application to acquires heartbeat data between two machines. I am trying to start and stop it at a certain time, but it's not working. It would stop the process but not the driver. So I am just curious if it's POSSIBLE to disable the hardware.wow! and i was just asking since it SOUNDED like a viruses for a second. |
|
| 2834. |
Solve : DOS based POS application? |
|
Answer» We have a DOS based application RUNNING under windows 98. The author has long since retired. The program has been running on the same machine for years. In order to upgrade the hardware is it resonable to clone the old drive and instal in a new machine? Could one expect the application to run as before or would new hardware result in errors? |
|
| 2835. |
Solve : Create list of entryes not in file? |
|
Answer» Hi' |
|
| 2836. |
Solve : Navigating a Windows Program via CMD Batch?? |
|
Answer» My first post on your boards, but I've spent the past few days making this site and forum my bible for Batching Batch files are probably not what you want for what you are trying to do in #1 and #2. You can probably use VBS with SENDKEYS to do what you are looking for, but not being familiar with any of the programs you listed, I can't really help. Full path to the file that runs Fraps.. C:\Fraps I just used Code: [Select]cd/ cd fraps START fraps.exe The keystrokes to use to navigate Fraps' menu I haven't tried yet, however, for Ventrilo.. which is C:\Program Files\Ventrilo Code: [Select]cd/ cd "program files\ventrilo" START ventrilo.exe I would need to hit O (For Connect) and then Tab 9 times, Down Arrow once and Return once to join the desired channel. The StuffIt code for Tab, Down Arrow and Enter is listed, but not O.. and I don't know where to find that so I was kinda stuck there. For World of Warcraft it's simple, since I have a "run" shortcut already made for it. I just; Code: [Select]START wow But the path is C:\Users\Public\Games\World of Warcraft\ If I have to use VB and SendKeys I guess I'll do that, I just didn't want to go through all the extra stuff involved there.. compiling, a GUI, etc. I just wanted a quick batch job heh. Thanks a lot.Quote I just wanted a quick batch job heh. Wait! Don't go away mad! Look at this: http://www.download.com/Quick-Macros/3000-2084_4-10254443.html?tag=mncol This is but one of a number of "Keyboard Macro" programs where you define keystrokes, save it in a file, and later can invoke it as a shortcut. After a bit of reading, you can do this faster that writing something with Visual Basic. But not as much fun. Somebody else did all the work! Quote from: Geek-9pm on February 11, 2009, 09:25:51 AM Code: [Select] Syntax First - Visual Basic is NOT VBScript. I tested to make sure sendkeys didn't exist before posting. Secondly - that's .NET, which is even further from the roots of VBScript, which originally branched off Visual Basic 5 (and was updated to include the VB6 Functions InstrRev,Split,Join, and so forth later on). (Some may say that it branched off from VBA, but on the other hand VBA was integrated into Visual Basic at version 4) And Of course... Visual Basic 5 or 6 aren't easy to find OR free. Also sendkeys is busted in the .NET framework. One would need to use the SendInput() APIs instead.Quote from: BC_Programmer on February 11, 2009, 10:31:44 AM First - Visual Basic is NOT VBScript. I tested to make sure sendkeys didn't exist before posting.I am almost certain that I have used SENDKEYS in VBS before. It's possible that it was VB, but I am pretty sure it was VBS. I'll try to get in front of that computer and look through my scripts.SENDKEYS does work in VBS. Try this as a VBS: Code: [Select]set WshShell = CreateObject("WScript.Shell") WshShell.Run "notepad.exe" WScript.Sleep 1000 WshShell.AppActivate "Notepad" WScript.Sleep 200 WshShell.SendKeys "This should put some text in a notepad document" WScript.Sleep 200 WshShell.SendKeys "%F" WScript.Sleep 200 WshShell.SendKeys "A" WScript.Sleep 200 WshShell.SendKeys "C:\VBS_SendkeysTest.txt" WScript.Sleep 200 WshShell.SendKeys "%S" It should start NOTEPAD, enter some text (using SENDKEYS), and then use SENDKEYS to open the File menu -> Save As -> C:\VBS_SendkeysTest.txt and [Alt-S] to save. Quote from: pheNom on February 11, 2009, 10:09:31 AM I would need to hit O (For Connect) and then Tab 9 times, Down Arrow once and Return once to join the desired channel.In VBS, I think you could do something like: Code: [Select]set WshShell = CreateObject("WScript.Shell") WshShell.Run "program files\ventrilo\ventrilo.exe" WScript.Sleep 1000 WshShell.SendKeys "O" WScript.Sleep 200 WshShell.SendKeys "{TAB 9}{DOWN}{ENTER}"technically VBScript doesn't have sendkeys- the windows scripting host does- so Javascript,PERL, etc can all use the same sendkeys Appactivate, etc. in pure VB it's a statement- same with appactivate, as well as a few other statements...- this is what I was referring to. Additionally I was confused as to where Geek9pm found a class called sendkeys, given it's actually a method of the WSH... Quote Additionally I was confused as to where Geek9pm found a class called sendkeys, given it's actually a method of the WSH... Sorry about my confusing post. It is in the .NET framework class library.Thank you all very much. I'm at work right now so I can't test out that macro program you linked, Geek, but I can't wait to get home and mess around with it. Looks like it'll do everything I need it to, AND everything the original batch was already doing. Hah. Easymode ...but since I love code I'm gonna spend the rest of my day at work with SendKeys in VBS. See what I can do with that. God, I love working in IT. Nobody can give you a hard time if your screens are filled with scripts and coding that they don't understand! ...until a printer breaks, or one of their cables gets unplugged. *sigh* -_- Love these boards btw. Fastest replies, with actual relevant information, I've ever seen. Quote from: Geek-9pm on February 11, 2009, 12:02:22 PM QuoteAdditionally I was confused as to where Geek9pm found a class called sendkeys, given it's actually a method of the WSH... No worries An entire class devoted to sending keys... intriguing... Assume whenever I say Visual Basic and forget to say which kind, that I mean 6 |
|
| 2837. |
Solve : Installing Dos 6.22? |
|
Answer» Quote like... like... like...YES? he didnt cause we were installing XP to laptops.Jesus, three pages already? SQUALL, no. Topic CLOSED. |
|
| 2838. |
Solve : Batch file - using AD group membership? |
|
Answer» Guys |
|
| 2839. |
Solve : BATCH saving files to specific locations? |
|
Answer» I am a complete novice with batch files. This is what I want to do: |
|
| 2840. |
Solve : dual boot, dos 6.22 and XP? |
|
Answer» First, can I dual boot between dos 6.22 and XP? How do I switch back and forth? You can use a boot manager. but some can ruin your present system. Geneally, you can learn how you BIOS works in five minuetes or less. How the boot managerwokrs can take days. For me it has taken months and months and finally discovered I don't need it, just do it in the BIOS. Get into your BIOS. Somewhere there is a way to change the boot order. You can boot off the second IDE or the second drive. I have a Intel board mad a few years ago and have no problem getting it to boot off the second drive. Most Dell computers and ASUS mother boards have that feature. In fact, I can not think of a BIOS that does not have that feature. Except a laptop.. I suppose you have the old PATA (IDE) drives. You can not do DOS on a SATA unless it is in emulation mode. For DOS, you can just install it on the other computer. It does not care. Some 20 mega byres is lots for DOS. Win 98 about 500 is good. For endows 98, you would disable the main hard drive in the BIOS settings. For Windows 98 will install on what it sees as the first hard drive. Or whatever drive has a FAT32 partition. Yes what the other post said is true. You can not retro install Windows versions. A Windows 98 or DOS install onto the main drive will mess up the XP MBR, NT boot sector and NTLDR. So you would install on another drive, with the main drive removed or disable or mapped by the BIOS to be the virtual second drive. (Windows allows BIOS remapping, Linux does not. And trying to dual boot with Linux is something I have never liked. Too much HASSLE.) If this is not clear, ask questions. After you put the second drive in, look in the BIOS. It should find it ans somewhere give you the option of making it the boot drive. Or you disable the first IDE channel and it gos for the other channel. If the BIOS can not find a valid boot sector on any HDD, it gives some error message. Unless it boots first from the CD or floppy. |
|
| 2841. |
Solve : Assigning the output of a command to a variable in a batch file? |
|
Answer» Hi, |
|
| 2842. |
Solve : Write to file with echo and use \n? |
|
Answer» Hi i'm wondering if there is way to append text to some file going to the next line. |
|
| 2843. |
Solve : Directory Command? |
|
Answer» Hello |
|
| 2844. |
Solve : Starting all files/exes in a directory?? |
|
Answer» Hi All - FIRST post here. Trying to put together a batch file to make life a little easier. You can also do it without creating a content file (and without waiting) like this: If you are changing drive letters you need the /D switch on the CD (or manually change the drive letter). So try this instead: Code: [Select]cd /D "C:\test" for /f "tokens=*" %%a in ('dir /a-d /b') do start "" "%%a"It works perfectly. +3 internets, and the right to name my firstborn. Thanks!! "Sparky"..... |
|
| 2845. |
Solve : net start basic -- start unattended? |
|
Answer» I am using a netboot CD, and am trying to get it to RUN unattended. |
|
| 2846. |
Solve : Xcopy command Invalid parameter? |
|
Answer» Hi, Hi,In Xcopy, the switches go at the end of the command line, like this: Xcopy "C:\junk\*.*" "D:\junk\" /s /y That line will copy everything in the junk folder in C: to a junk folder in drive D:. You MUST first make the "junk" folder on D: for this to work properly. Does that make sense? Every day, I back up my entire "My Documents" folder (and several others) to a like folder on drive D: The way I have it written, the first time I ran the batch file, it backed up the entire directory, but the next time I ran it, it backed up only new files and files that had been updated or changed. Now I run it in my shutdown batch file and it backs up just a few files and takes only a few SECONDS to run. Here's the text of that shutdown batch file: @ECHO off cls xcopy "C:\Documents and Settings\Alex\My Documents\*.*" "D:\My Documents\" /s /y /H /R /D Rem Back up my WordPerfect files. xcopy "C:\MyFiles\*.*" "D:\MyFiles\" /s /y /H /R /D Rem Back up all the files for My Web Page. xcopy "C:\My web page\*.*" "D:\My web page\" /s /y /H /R /D Rem Back up my email folders and address book. xcopy "C:\Documents and Settings\Alex\Local Settings\Application Data\Identities\{CC1A6FC7-0D07-4169-865D-56EBDD76EB8B}\Microsoft\Outlook Express\*.dbx" "D:\MyEmailFiles-Backup\" /s /y /H /R /D xcopy "C:\Documents and Settings\Alex\My Documents\My Address Books\*.*" "D:\My Address Books" /s /y /H /R /D Rem When the backup is done...Shutdown! %windir%\System32\shutdown.exe -s -t 00 -f In your example, you will be copying all the files in those folders, over and over again. That's pointless and very time consuming. I suggest that you add more switches like I've done, to copy only new or changed files. Just a suggestion, Shadow That's good stuff, Shadow. You might want to make a menu to select what kind of backup you want. All of my documents, only new and changed, or other options. Thanks. |
|
| 2847. |
Solve : Sending Files Using DOS via Internet? |
|
Answer» Is it possible to send files using only DOS to other computers via Internet?Which version of DOS? here's no direct cable connection only internetSimple answer is no. Long answers start here. You can use P2P programs to do this. P2P means Peer to Peer. That requires both users to agree on a service that they will both use. The program runs in Windows and does not require a DOS command. Personally, I do not recommend the use of P2P. You can have other issues. Like more people wanting to get in on your file sharing and sum you have people you never knew wanting to have some of the material. The other way is to get an password protected FTP account you can both share. Ask nice and somebody here will give you a free one. The best alternative is to establish a your own VPN. Never mind. Very long story. If this is new to you, go for the SHARED FTP account. Slow, but it works But If you are sharing just videos and photos, go to Photobucket. No brainier. A free FTP host is hfmwebs.co.cc . It's main page is in another language (LAST time I CHECKED), but its pretty easy to find the register button, and the words you need to know to register are similar to English. |
|
| 2848. |
Solve : copy problem? |
|
Answer» i guys i want MAKE ONE batch file that first find eny kind of file like .txt of .pdf form all computer DIRECTORS and COPY file that find in result in my pen drive........... |
|
| 2849. |
Solve : DOS copy syntax? |
|
Answer» It's ages since I needed to use DOS, and I'm afraid I'm a bit rusty - hope someone can help. @echo off place this is a batch file- and call as follows: batfile.bat Hope this works for you. remember to back up important data before running this, I wouldn't want to be responsible for the loss of anything important. Thanks Guys, I used your solution, Geek-9pm - did just what I wanted. I'm still confused as to why DOS help on the copy command suggests that multiple named files can be copied at once, when this doesn't appear to be the case. Thanks again.I believe when it says "file(s)" it means using wildcard characters- the only other option via multiple files is copying via file1+file2, which concatenates files together. |
|
| 2850. |
Solve : How to: Write Console output to *.txt file? |
|
Answer» Thanks: |
|