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.
| 7701. |
Solve : Batch file to Copy certian lines in a txt file only? |
|
Answer» Hello Haven't been on in a while been doing lots of stuff and learning What do you mean it doesn't do exactly what you want. That is exactly what you asked for!Well I wanted one batch file to do all the work but your solution wasnt spot on because my lack of explanation Probably But I figured it out Thanks to you and made these two batch files That completely solve the Problem This One Prepares The file for Reading (Basically): Code: [Select]@echo off Echo.Catagories echo.ARMO=Armor MISC=misc ALCH=AID NOTE=notes WEAP=Weapons AMMO=ammo WeaponMods=IMOD set /p A=Ammout: set /p C=Catagories: set /p filename=Filename: set /p B=OutputFilename: for /F "tokens=1 delims= " %%I in ('type %filename% ^|findstr "%C%"') do ( >>%B% echo %%I ) call SortIDs.bat pause And this one finished it Up: Code: [Select]for /F "tokens=1" %%G in (%B%) do ( >>%B% echo player.additem %%G %A% ) Quote from: millergram on July 04, 2012, 09:52:10 PM Well I wanted one batch file to do all the work but your solution wasnt spot on because my lack of explanation ProbablyMy solution was spot on given the information you gave me. You never said anything about that extra code you have for you 2nd batch file. |
|
| 7702. |
Solve : Arrange Windows when opened? |
|
Answer» Is there a way to arrange the windows started using a batch file? so instead of opening them all on top of each other in a big heap, have them spread out to cover the screen (or make a square) with no overlaying. If so how would you do that? |
|
| 7703. |
Solve : Archiving by Last modified date? |
|
Answer» So I need to move all the contents of a network drive onto an external drive so that when we go to move the network drive to a new server we are not bringing old, outdated files with it and we can put them to DVD for later if we FIND files are indeed missing. |
|
| 7704. |
Solve : Get a batch script to detect the drive letter it is running from?? |
|
Answer» I am working on a batch script that I will be using to keep a folder updated across four computers. This script will be located on a memory stick, and it's function will be to copy modified files from the memory stick to the computer, and to copy modified files from the computer to the memory stick, and that is where I run into issues - At the moment, I have to go and modify the TARGET letter for the USB memory stick each time I move it to a different computer. |
|
| 7705. |
Solve : How to prevent variable substitution in SET command? |
|
Answer» I am trying to do the following: you have to use the escape the %, otherwise it thinks you are referring to a veritable That's correct. Quote from: or surround it with %'s That BIT is wrong. Just double the percent signs. Code: [Select]SET I=http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.htmlinteresting, triple % has ALWAYS worked for me, but maybe only in certain instances.Quote from: Lemonilla on September 05, 2012, 02:32:04 PM interesting, triple % has always worked for me, but maybe only in certain instances. What CIRCUMSTANCES? Quote from: Salmon Trout on September 06, 2012, 01:43:23 PM What circumstances?Everything I've ever WRITTEN, would you LIKE me to post some examples? I'll have to go digging.Quote from: Lemonilla on September 07, 2012, 01:51:18 PM would you like me to post some examples? Yes please. Here, I'll do it for you. Code: [Select]@echo off echo Passed parameters: echo Parameter 1 %1 echo Parameter 2 %2 echo. echo Attempting to escape percent signs in string: echo. echo 1. No escaping SET I=http://www.someURL.com/My%20Webpage%28Version%20B%29.html echo %I% echo. echo 2. Replace one percent sign with two SET I=http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.html echo %I% echo. echo 3. Replace one percent sign with three SET I=http://www.someURL.com/My%%%20Webpage%%%28Version%%%20B%%%29.html echo %I% echo. echo 4. Replace one percent sign with four SET I=http://www.someURL.com/My%%%%20Webpage%%%%28Version%%%%20B%%%%29.html echo %I% echo. 1. With parameters passed Code: [Select]Passed parameters: Parameter 1 cat Parameter 2 dog Attempting to escape percent signs in string: 1. No escaping http://www.someURL.com/Mydog0Webpagedog8Versiondog0Bdog9.html 2. Replace one percent sign with two http://www.someURL.com/My%20Webpage%28Version%20B%29.html 3. Replace one percent sign with three http://www.someURL.com/My%dog0Webpage%dog8Version%dog0B%dog9.html 4. Replace one percent sign with four http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.html With no parameters passed Code: [Select]Passed parameters: Parameter 1 Parameter 2 Attempting to escape percent signs in string: 1. No escaping http://www.someURL.com/My0Webpage8Version0B9.html 2. Replace one percent sign with two http://www.someURL.com/My%20Webpage%28Version%20B%29.html 3. Replace one percent sign with three http://www.someURL.com/My%0Webpage%8Version%0B%9.html 4. Replace one percent sign with four http://www.someURL.com/My%%20Webpage%%28Version%%20B%%29.html If you study the above you will see that to get ONE percent sign in the URL string using SET, you need exactly TWO percent signs in the code. Put simply, 2N percents in the code are replaced by N percents in the displayed result, and 2N+1 percents are replaced by N+1 percents. |
|
| 7706. |
Solve : %%G help? |
|
Answer» So The PROGRAM is SUPPOSE to ping each computer on the network and then display the name and the average ping in this format: Need to use Delayed Expansion. Your inside a FOR LOOP.Still getting the same error. It's suppose to be Code: [Select]setlocal EnableDelayedExpansioncorrect?Quote from: Lemonilla on July 03, 2012, 07:13:40 AM Still getting the same error.You are getting an error now. You didn't say anything about getting an error in your previous posts. Quote from: Squashman on July 03, 2012, 07:19:17 AM You are getting an error now. You didn't say anything about getting an error in your previous posts.My bad, was referring to the BUG as an error. I found the problem though. I was trying to write to net%c%.1, when I changed that to net!1!.1 it worked, so I believe that %c% was not UPDATING with my set /a c+=1. Final code: Code: [Select]@echo off set c=0 if exist *.1 del /f *.1 title Network Pinger setlocal EnableDelayedExpansion net view | find "\\" >>network.1 for /f %%G IN (network.1) DO ( set /a c+=1 echo %%G >>net!c!.1 ) set m=%c% set c=0 :loop.rename set /a c+=1 set y=\\ set /p y=<net!c!.1 set y=%y:~2,100% ping %y% | find "Min" >>ping%c%.1 if %c% EQU %m% goto break.rename goto loop.rename :break.rename set c=0 :loop.view set /a c+=1 type net%c%.1 set /p a=<ping%c%.1 FOR /F "tokens=4 delims==" %%G IN ("%a%") DO ( echo %%G ) if %c% EQU %m% goto break.view goto loop.view :break.view del /f *.1 pause >nul Quick question, when pinging a computer name, will it be effected by internet usage? (i.e. If I have 120 pictures loading on the internet and ping myself, will the loading of the pictures slow down the packets?)Quote I believe that %c% was not updating with my set /a c+=1. For delayed-expansion to work you need two things 1. Setlocal enabledelayedexpansion 2. The variable name to be expanded is preceded and followed by exclamation marks NOT percent signs. |
|
| 7707. |
Solve : net view | ____? |
|
Answer» Is there a pipe I can use on net view to show how much bandwidth each computer is PULLING? Or a diffrent (non-installed) command to do this?You want to KNOW how much bandwidth is being pulled by each computer on your network from your computer? At our house, we have ~150-200mbpsec download speed split amoungst whoever is on the internet, I was wondering if there was a way to find out which computers in the house (on the network) were taking from that and how much.Why didn't you just say that in your first post.I figured I was, just with different words. Sorry for misleading you.Haven't tested this on a network YET (no one's home), but this (may) work. Code: [Select]@echo off net view | find "\\" >>network.1 set c=0 for /f %%G IN (network.1) DO ( echo %%G >>net%c%.1 set /a c+=1 ) set m=%c% set c=0 :loop.rename set /p y=<net%c%.1 set y=%y:~2,100% ping %y% | find "Min" >>ping%c%.1 set /a c+=1 if %c% EQU %m% goto break.rename goto loop.rename :break.rename set c=0 :loop.view type net%c%.1 set /p a=<ping%c%.1 FOR /F "tokens=4 delims==" %%G IN ("%a%") DO ( echo %%G ) set /a c+=1 if %c% EQU %m% goto break.view goto loop.view :break.view del /f *.1 pause >nul |
|
| 7708. |
Solve : Load a dll? |
|
Answer» Load a LIBRARY or function with a bat file |
|
| 7709. |
Solve : Moving many files up one directory level? |
|
Answer» Hi, Now that we have all confused him, No. he can't. you might want to read a bit closer. He wants to move the files in all the DIFFERENT level3 folders beneath the level 2 folders into the respective level 2 folders. THIS CANNOT be done quickly with explorer.Quote from: BC_Programmer on January 11, 2010, 07:50:24 PM Ahh, OK, guess I misunderstood Hey, I am pretty sure this will work, except I may not have given you all the required info. "Level 1" is always called "music" but the "Level 2" and "Level 3" directories always have different names. In that BAT file you gave me I noticed that you you have a couple of commands which point specifically to folders called "Level 3": is there a way to just point to directories at this level in the tree rather than folders actually named "Level 3"? Thanks so much!Quote from: BillRichardson on January 11, 2010, 07:28:18 PM Code: [Select]@echo off Quote from: Salmon Trout on January 12, 2010, 12:16:29 AM SORRY you haven't read my post properly. BC_Programmer could you please check my reply? Thanks heaps.Quote from: cameronyoung on January 12, 2010, 12:18:14 AM Sorry you haven't read my post properly. BC_Programmer could you please check my reply? Thanks heaps. I have, somebody else hasn't. Original code: Code: [Select]@echo off for /f %%P in ('dir /b /od') do ( PUSHD %%P for /f %%I in ('dir /b /od') do ( copy "%%P\%%I\*.*" ".\%%P\" REM rmdir /s /q "%%P\%%I" ) popd ) new code: Code: [Select]SETLOCAL ENABLEDELAYEDEXPANSION for /f "usebackq delims=" %%P in (`dir /b /ad`) do ( pushd %%P for /f "usebackq delims=" %%I in (`dir /b /ad`) do ( copy "%%I\*.*" .\ REM rd /s /q "%%I" ) popd ) changed the dir command to what I originally intended; I had /od, but /o and -o are for sorting. changed it to /ad so they would both only enumerate directories. Given the new requirements, added a nested loop within the original, to account for "level3" folders having different names. In this case, it iterates on ALL folders within each folder; Again, I have the rd command remmed out here; unrem it after you test it for it to delete the folders as you wanted. It worked for my tests (it moved all data in third level folders to their respective second level folders) however, with multiple folders we have the problem of duplicate filenames in these folders; copy will prompt to overwrite in this scenario.Hey BC_Programmer, I added the below code to a .BAT file but it didn't work. Quote from: BC_Programmer on January 12, 2010, 01:57:14 AM Code: [Select]SETLOCAL ENABLEDELAYEDEXPANSION When I added the code as is, it didn't move any files or delete anything. When I removed the REM it just deleted everything except the parent directories. Am I doing something wrong? I ran the .BAT file from "S:\MUSIC\test.bat" and these are the exact files I had in the directory: S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\01 jhevevevj.mp3 S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\02 83fjh3v3v.mp3 S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\03 jeje vv urvfrv.mp3 S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\dalek vs faust v0\folder.jpg S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\01 whh whh whaaamp3 S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\02 bleeef dikee aa.mp3 S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\03 !.mp3 S:\MUSIC\mazzy star\1991 - she hangs brightly\she hangs brightly\playlist.m3u I had HOPED that it would produce the following: S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\01 jhevevevj.mp3 S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\02 83fjh3v3v.mp3 S:\MUSIC\dalek vs faust\2004 - derbe respect, alder\03 jeje vv urvfrv.mp3 S:\MUSIC\mazzy star\1991 - she hangs brightly\01 whh whh whaaamp3 S:\MUSIC\mazzy star\1991 - she hangs brightly\02 bleeef dikee aa.mp3 S:\MUSIC\mazzy star\1991 - she hangs brightly\03 !.mp3 Ideally I would have liked it to move only the .MP3 files and then for it to remove the directories the MP3s were moved from and any non-MP3 files they contain. It needs to be something GENERIC though, as there are about 2000 more "dalek vs faust" and "mazzy star" level directories with the exact same structure. Please let me know if this isn't clear. Thank you.Sorry to jump in, but shouldn't this copy "%%I\*.*" .\ be this copy "%%I\*.*" ..\ ? (i.e. two dots refer to the next folder up) |
|
| 7710. |
Solve : matrix in batch stop in 3 second? |
|
Answer» Quote from: tendude on July 01, 2012, 03:05:34 AM actually i want and like to LEARN how batch COMMAND really works...Great that you want to learn batch but you may want to spend more of your time learning Powershell if you are planning on doing a lot of scripting in the future. |
|
| 7711. |
Solve : replace characters in the file name? |
|
Answer» HI! I created a batch file that loops through a LIST of files in a folder, strips a part of each one and renames it (see example below) Batch file: for %%i in (*.pdf) do (set fName=%%i) REN %fName% %fName:~-10% Original list: John Smith_12_123456.pdf Brian Smith_10_456789.pdf Joshua Smith_17_765436.pdf Kate Noname_09_786526.pdf Output: 123456.pdf 456789.pdf 765436.pdf 786526.pdf However, if there is a file with brackets in the folder (ex.: John_(Paul)_Smith_12_123456.pdf , the batch file does not work and throws an error message. How can I fix it? Is there a way to replace brackets for a different character (UNDERSCORE would be ideal)? Thank you.This should work (untested): Code: [Select]@echo off setlocal EnableDelayedExpansion for /f "delims=" %%i in (' dir *.pdf /b ') do ( set "fName=%%i" ren "!fName!" "!fName:~-10!" ) Quote from: foxidrive on September 06, 2012, 11:17:52 PM This should work (untested): Thank you so much mate! This script does exactly what I wanted it to do. |
|
| 7712. |
Solve : new hard drive - d drive not recognised in ms-dos? |
|
Answer» Hi everyone, the info in the ms-dos window following the ipconfig/all command That's not "ms-dos". Are you sure your cd drive letter is D ? I went to Start...Run...command - and a black window appeared with white writing- I entered ipconfig/all - and the info I posted appeared. Is that not ms-dos?Quote from: ward58 on August 25, 2012, 04:22:15 AM I went to Start...Run...command - and a black window appeared with white writing- I entered ipconfig/all - and the info I posted appeared. Is that not ms-dos? No. It is Windows Command Prompt. MS-DOS was a standalone, single user text-only operating system for PCs first released in the 1980s and used until the 1990s when Windows came along. You did not answer the question about your CD drive letter. The fellows problem is that he can't get connection in Windows. I'll just repeat my suggestion that the router is not supplying DHCP information or the cable is fubar. EDIT: It occurs to me that you may not have ethernet card drivers loaded. If not (check device manager) then download the drivers on the good machine and transfer them by USB stick. Or check the cdrom for the drivers. ...Or is that the problem - you don't have access to your CDROM? Your IPCONFIG information shows that you aren't getting a DHCP configuration from the modem/router If the modem is normal then Windows seems upset - at the very least you should have an IP address that Windows gives the adapter even when there is no DHCP and you don't even have that. What version of Windows is this? This thread will be moved probably.I seem to have inadvertently caused some confusion. The reason I thought I was in ms-dos is that the title bar of the black box says "MS-DOS Prompt". That aside, I have tried another cable without success. Access to the CD-Rom drive is fine (and it is definitely designated as D). I loaded the ethernet card driver from the cd that came with it. Device manager shows the following info for the driver :- C:\WINDOWS\SYSTEM\NDIS.VXD - C:\WINDOWS\SYSTEM\vmm32.vxd(ntkern.vxd) C:\WINDOWS\SYSTEM\DLKRTL.SYS The OS is Windows 98se. I noticed that sometimes Device Manager did not display the card details on startup/restart, so I physically removed and re-installed the card, and reloaded the driver. On restart, a message displayed along the lines of "the device installed in port 2 shares IRQ with IDE controller. Ensure the device supports IRQ sharing". I assumed this was ok, as the card was in the machine with the old hard drive and worked perfectly well then. I read something about checking the DHCP, but did not understand how to get into it. There was also mention of checking the Registry and possibly changing that, but I know that the combination of ham-fist and ignorance can do much damage, so I left that well alone! Any thoughts? P.S. I don't know what "fubar" means ( or should I not ask?!)Quote from: ward58 on August 25, 2012, 08:44:00 AM I seem to have inadvertently caused some confusion. The reason I thought I was in ms-dos is that the title bar of the black box says "MS-DOS Prompt". OK you finally told it was Windows 98. This very old operating system did use a version of MS-DOS as its command prompt. Hi again, I think I may have solved the problem (more by luck than skill or judgement!). I found an article on the Netgear website that advised altering the TCP/IP settings. This seems to have worked and I have been able to get ONLINE. Hopefully, it won't all go wrong and reverse itself when I shut down and restart. Thanks to you both for your attempts to help. As you can tell, I am not very computer savvy and tend to "make it up as I go along"! Cheers, Peter. Peter, it's good to know that you fixed it yourself. Well done! Greetings Peter, FUBAR=Fouled Up Beyond All Recognition. I've heard that some folks don't use the word 'Fouled' when defining this acronym. Best wishes! |
|
| 7713. |
Solve : i want to give command in DOS regard to do reading a dat file and copy line 9 c? |
|
Answer» please help me...not sure how a .dat file is set up, but try this: |
|
| 7714. |
Solve : DOS with USB driver on CD? |
|
Answer» I've ALWAYS had problems with BIOS update utilities that require DOS because most comps don't have floppy drives anymore, so I end up having to burn a one-time use CD. I put DOS on the CD along with the BIOS firmware, update the BIOS, then throw away the CD. A better option would be to boot it from USB flash drive, but I often find BIOSs that don't support it. Can ANYONE help me make a preconfigured DOS CD that automatically mounts a flash drive so I can run the utilities? I know I could probably make it work after getting a driver and editing a BILLION times, but I don't want to use that many CDs. Any ideas?You could also use a CD-RW...xboot is a tool available for Windows to create a bootable USB stick. |
|
| 7715. |
Solve : Remove Windows running in background? |
|
Answer» I want to run an OLD program that requires windows Dos. I was ABLE to install but was informed that windows running in the background must be closed. How do I REMOVE windows and still have the C:\ prompt?Try DLoading and installing DosBox.He closed his account and LEFT his email address for SPAMMERS to harvest... |
|
| 7716. |
Solve : How to access PORTABLE MEDIA PLAYER with DOS command lines? |
|
Answer» Hello, |
|
| 7717. |
Solve : How to get the free space available in Disk and mount volumes using a command? |
|
Answer» Hi There, Hey foxidrive & sidewinder, Impressive piece of work. This work around now tops Letterman's Top Ten Reasons To Switch To Powershell. This version has TRIVIAL changes but it handles drive arrays up to 99 TB. Code: [Select]strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk where drivetype <> 5") WScript.Echo "Name Capacity Free Free %" For each objDisk in colDisks percentfree = (objdisk.Freespace / objdisk.Size) * 100 With objDisk WScript.Echo .DeviceId & " " & pad(FormatNumber(.Size/1073741824, 2)) & " " & pad(FormatNumber(.Freespace/1073741824, 2)) & " " & FormatNumber(percentfree, 2) End With Next function pad(strText) strText = Space(10) + strText strText = Right(strText, 9) pad = strText end functionthanks All for the answers. With wmic Volume i can get free space available on mount point's as well. But the issue now is ITERATING through a list of servers across my company's servers from my laptop. I am trying to combine DOS command and SQL to achieve the result. That eliminates issues with DOS command thanks Helen |
|
| 7718. |
Solve : Open then close new sites with time intervals?? |
|
Answer» I want to have a CODE where it Opens a message box you SELECT yes or no then after selecting yes |
|
| 7719. |
Solve : Command to create an empty txt file? |
|
Answer» I would like to know the command line to create an empty txt file : "Nuevo Notepad++ document.txt" What does creating an empty file have to do with the context menus I am trying to create a new entry in the main contextual menu. The entry exist previosly in the secondary "new" contextual menu. Under windows xp pro + sp3 , spanish version. The sreenshots : I would like a .REG to add the new entry in the contextual menu. I need to vary the windows registry Best Regards And I don't know how There is already a context menu for creating a new text file. Why do you need another?Quote from: Squashman on June 24, 2012, 08:20:17 PM There is already a context menu for creating a new text file. Why do you need another? I need in the main contextual menu. The left menu..... Speed Get Context Menu Editor...still Free i believe. |
|
| 7720. |
Solve : help curing run-time error 200? |
|
Answer» Hi all, |
|
| 7721. |
Solve : Help with rearranging digits? |
|
Answer» I read about a math FORMULA and I'm making a batch file to work through it. |
|
| 7722. |
Solve : Shutdown remote computer if uptime is over a period of time? |
|
Answer» I need to SHUTDOWN workstations with windows 7 operating system if uptime is over a some period of time. I got uptime remotely with: Code: [Select]systeminfo /s "somecomputer" | find "System Boot Time:". Shutdown computer with: Code: [Select]shutdown /m \\"somecomputer" /s. Idea is to make a batch FILE that will compare the CURRENT time and uptime, calculated the difference and if the difference is more than some time period, turn off workstation. Batch file will be executed from Task Scheduler. Dunno if this can help you at all. There's a routine to calculate time difference though. Working like charm on local machine. With some customisations shutdown local machine after 7 days look like: Code: [Select]@echo off for /f "delims=" %%a in ('wmic OS Get LastBootUpTime ^| find "."') do set up=%%a for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a set beg=%up:~0,4%-%up:~4,2%-%up:~6,2%T%up:~8,2%-%up:~10,2%-%up:~12,2%-%up:~15,3% set end=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%T%dt:~8,2%-%dt:~10,2%-%dt:~12,2%-%dt:~15,3% call :TimeDifference uptime %end% %beg% if %uptime% gtr 7 shutdown /s /f goto :eof :TimeDifference Return_Variable Start_Date_Time Stop_Date_Time :: Version -0 2009-12-25 Frank P. Westlake :: Calculate the difference in time between parameter 2 and parameter 3 :: and return the values in the variable named by parameter 1. :: :: Parameters 2 and 3 are ISO8601 DATE/TIMEs of the format :: :: YYYY-MM-DDThh-mm-ss :: :: where '-' may be any of '/:-., '. :: :: RETURN: :: The variable named by %1 will be set with a string containing each of :: the following values seperated by spaces: :: :: DAYS HOURS MINUTES SECONDS MILLISECONDS :: :: EXAMPLE: Call :TimeDifference diff "2009-12-01T 1:00:00.00" "2009-11-30T13:00:00.01" :: Sets variable "DIFF=0 12 0 0 10" SetLocal EnableExtensions EnableDelayedExpansion For /F "tokens=1-14 delims=T/:-., " %%a in ("%~2 %~3") Do ( Set "h2=0%%d" & Set "h3=0%%k" & Set "n2=%%g00" & Set "n3=%%n00" Set /A "y2=%%a, m2=1%%b-100, d2=1%%c-100, h2=1!h2:~-2!-100, i2=1%%e-100, s2=1%%f-100, n2=1!n2:~0,3!-1000" Set /A "y3=%%h, m3=1%%i-100, d3=1%%j-100, h3=1!h3:~-2!-100, i3=1%%l-100, s3=1%%m-100, n3=1!n3:~0,3!-1000" ) Set /A "t2=((h2*60+i2)*60+s2)*1000+n2, t3=((h3*60+i3)*60+s3)*1000+n3" Set /A "a=(14-m2)/12, b=y2-a, j2=(153*(12*a+m2-3)+2)/5+d2+365*b+b/4-b/100+b/400" Set /A "a=(14-m3)/12, b=y3-a, j3=(153*(12*a+m3-3)+2)/5+d3+365*b+b/4-b/100+b/400" Set /A "d=j3-j2, t=t3-t2" If %d% LEQ 0 (If %d% LSS 0 (Set /A "d=j2-j3, t=t2-t3") Else If %t% LSS 0 (Set /A "t=t2-t3")) If %t% LSS 0 (Set /A "t+=(1000*60*60*24), d-=1") Set /A "n=t %% 1000, t/=1000, s=t %% 60, t/=60, m=t %% 60, t/=60" EndLocal & Set "%~1=%d% " Goto :EOF :: END SCRIPT ::::::::::::::::::::::::::::::::::::::::Batch file need to run like administrator. I'm not tested this on network, but i think only difference is in: Code: [Select]for /f "delims=" %%a in ('wmic/ Node:"computername" OS Get LastBootUpTime ^| find "."') do set up=%%a for /f "delims=" %%a in ('wmic/ Node:"computername" OS Get localdatetime ^| find "."') do set dt=%%a and Code: [Select]if %uptime% gtr 5 shutdown /m \\computername /r /f Thanks, it's very useful |
|
| 7723. |
Solve : Update all drivers on a computer? |
|
Answer» Is there a way to write a batch file or something that will forcefully search for to update all drivers on the system instead of opening device manager and going one by one? I't doesn't necessarily have to be batch as long as it works. |
|
| 7724. |
Solve : help needed for using net time and xcopy command? |
|
Answer» Hi there, please help |
|
| 7725. |
Solve : Processes running under Windows Task Manager?? |
|
Answer» [glb][/glb] how does the DOS command looks like if I were to detect if a particular process is currently RUNNING as shown by the Task Manager? He hasn't been back for 7 Years,,, Patio, I don't like the look of this... Further Posts under Moderation... |
|
| 7726. |
Solve : autorun boot cd - urgent help please!!? |
|
Answer» Hi, I am trying to update my BIOS version from A05 to A07 on my Dell Diemnsion 8300. I have followed the instructions to create a bootable cd From the following Link: Try CD /d YOUR-DRIVE-HERE Don't know if that cd /d thing will work in MS-DOS. I rather think not. The standard MS-DOS way to change drives is to type the letter followed by a colon thus: Z: ... and then use cd (no switches) to get to the actual DIRECTORY. This is one of those boot CDs that use a floppy image, so that when you burn the CD you create 2 parts - one which gets booted as a "fake floppy" with MSCDEX etc for CD support, this has the A: drive letter, and also another part which is the actual CD, which appears at the drive letter shown in the message, so in this case the OP has to switch from the A: prompt to the Z: prompt. By typing Z: as salmon said, use Z: followed by the enter Quote from: Bukhari1986 on December 05, 2009, 08:10:08 AM as salmon said Was that post really necessary? Who's feeding the Parrots again ? ?Quote from: PATIO on December 05, 2009, 09:04:09 AM Who's feeding the Parrots again ? ?I thought it was just me. "Yeah, do what he said" posts drive me up a wall.Quote from: Allan on December 05, 2009, 09:06:22 AM I thought it was just me. "Yeah, do what he said" posts drive me up a wall. They are a WASTE of bandwidth. Not to say that a post not just agreeing with a previous poster, but adding information or relevant experience, is a bad thing at all. Quote from: Salmon Trout on December 05, 2009, 09:08:39 AM They are a waste of bandwidth. Not to say that a post not just agreeing with a previous poster, but adding information or relevant experience, is a bad thing at all. I agree. i was making that post for the purpose to tell him to press enter after typing Z: ONLY If I spent some more time, I will get familiar with the seniors over here. and will stay here in that style which please my seniors or if i can't do that, I will take no time to leave the forum. But I think all over here are soooo much friendly. at least I think so. Quote from: Allan on December 05, 2009, 09:06:22 AM I thought it was just me. "Yeah, do what he said" posts drive me up a wall.they're basically saying: TL;dr Insert-crappy-version-of-information-already-posted-here (tl;dr means too long; didn't read) |
|
| 7727. |
Solve : batch program expire? |
|
Answer» HELLO everone! I need HELP to develop a routine bat. I have a program that accesses FTP with many functions and have to send it to other friends. I WISH he ran for four days and then stop working. I looked over 20 pages of the forum and no found something SIMILAR. The problem is I have no way of knowing if the date format is mmddyyyy or ddmmyyyy or yyyymmdd or language the OS the other computer. Any ideas? Thanks for the help. Luis |
|
| 7728. |
Solve : DOS reverse redirection? |
|
Answer» all, Geek,is that in real time? can I do that from the prompt by typing it in?that can be does as a batch file. Go to start > run (or window key + r) and type in notepad (or open notepad any other way ). For your example enter this code: Code: [Select]dir Save it at the location you want using the .bat extension (I believe you need to have extension visible to do this successfully). Double clicking on the batch file will execute the commands there are in the file. If you want to do it for the command prompt, just write the name of the batch file. Hope this helped Two-Eyes % EDIT: Quote can I do that from the prompt by typing it in?Yes you can.i can type this in:Code: [Select]type finished.txtand what that does it PRINT the contents of the txt in the DOS window, but how do I get it to EXECUTE that content as a command?RENAME it to a .bat or .cmd file and then simply use: Code: [Select]finished.bat all, i have gotten it down, but I think the problem is still present. I have this code for shelling an ftp text file:Code: [Select]Dim fso Dim oFile 'Dim varitem As Variant Dim CurDir As String Dim CurRemoteDir As String Dim vPath As String Dim vFile As String Dim vFTPServ As String Dim fNum As Long Screen.MousePointer = 11 Set fso = CreateObject("Scripting.FileSystemObject") Set oFile = fso.createtextfile("c:\inProgress.txt", True) oFile.writeline "contents" oFile.Close vPath = "C:" vFTPServ = Me.Combo1 CurDir = Me.Text26 CurRemoteDir = Me.Text1 vFile = Me.List27 fNum = FreeFile() Open vPath & "\FtpComm.txt" For Output As #fNum Print #1, "USER " & sFtpUserName ' your login Print #1, sFtpPassword ' your password 'Print #1, "dir > c:\inProgress.txt" If sFtpHostName <> Me.Combo1 Then Print #1, "cd " & Left( _ Right(CurRemoteDir, Len(CurRemoteDir) - InStr(CurRemoteDir, "/")), _ (Len(CurRemoteDir) - 1)) End If Print #1, "put " & """" & CurDir & vFile & """" 'Print #1, "!" 'Print #1, "del c:\inProgress.txt" 'Print #1, "exit" Print #1, "close" ' close connection Print #1, "quit" ' Quit ftp program Close Shell "ftp -n -i -g -s:" & vPath & "\FtpComm.txt " & vFTPServ, vbMaximizedFocus what I am trying to accomplish is to get an indication of when the ftp session is over and the DOS window has been closed, thus telling me that all of the commands have been executed. This is in VBA, so maybe a different forum would be the best now? C:\batch>type reverse.bat Quote @echo off Output: C:\batch> reverse.bat Money = 500 C:\batch>Quote from: ajetrumpet on December 06, 2009, 01:49:41 PM
well, no reason to move it, I don't think. I encountered this problem some time ago, and already have something that should help. I made this module, "modexec" quite recently: Code: [Select]Option Explicit Private Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Private Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwflags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Byte hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Type OVERLAPPED internal As Long internalHigh As Long offset As Long OffsetHigh As Long hEvent As Long End Type Private Const STARTF_USESHOWWINDOW = &H1 Private Const STARTF_USESTDHANDLES = &H100 Private Const SW_HIDE = 0 Private Const SW_SHOWDEFAULT As Long = 10 Private Const EM_SETSEL = &HB1 Private Const EM_REPLACESEL = &HC2 Public Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, _ lpPipeAttributes As SECURITY_ATTRIBUTES, ByVal nSize As Long) As Long Private Declare Sub GetStartupInfo Lib "kernel32" Alias "GetStartupInfoA" (lpStartupInfo As STARTUPINFO) Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, _ ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, _ ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, _ ByVal lpCurrentDriectory As String, lpStartupInfo As _ STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As _ String) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, lpBuffer As Any, ByVal nNumberOfBytesToRead As _ Long, lpNumberOfBytesRead As Long, lpOverlapped As Any) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _ wParam As Long, lParam As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetThreadDesktop Lib "User32.dll" (ByVal dwThread As Long) As Long Private Declare Function WriteFile Lib "kernel32.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, _ ByVal nNumberOfBytesToWrite As Long, ByRef lpNumberOfBytesWritten As Long, ByRef lpOverlapped As Any) As Long Private Declare Function WaitForSingleObject Lib "kernel32.dll" (ByVal hHandle As Long, ByVal _ dwMilliseconds As Long) As Long Private Const WAIT_TIMEOUT As Long = 258& Public Function Redirect(CMDLINE As String) As String Dim i%, t$ Dim pa As SECURITY_ATTRIBUTES Dim pra As SECURITY_ATTRIBUTES Dim tra As SECURITY_ATTRIBUTES Dim pi As PROCESS_INFORMATION Dim sui As STARTUPINFO Dim hRead As Long Dim hWrite As Long Dim bRead As Long Dim hstdInPipeWrite As Long, hStdInPipeRead As Long Dim lpBuffer As String, wholestr As String pa.nLength = Len(pa) pa.lpSecurityDescriptor = 0 pa.bInheritHandle = True pra.nLength = Len(pra) tra.nLength = Len(tra) CreatePipe hStdInPipeRead, hstdInPipeWrite, pa, 0 WriteFile hstdInPipeWrite, ByVal Chr$(0), 1, 0, ByVal 0 If CreatePipe(hRead, hWrite, pa, 0) <> 0 Then sui.cb = Len(sui) GetStartupInfo sui sui.hStdInput = hStdInPipeRead sui.hStdOutput = hWrite sui.hStdError = hWrite sui.dwflags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES sui.wShowWindow = SW_HIDE If CreateProcess(vbNullString, cmdLine, pra, tra, 1, 0, ByVal 0&, vbNullString, sui, pi) <> 0 Then 'SetWindowText objTarget.hwnd, "" 'If Not GetThreadDesktop(pi.hThread) = 0 Then 'insert waitforsingleobject loop here... Dim rtret As Long Do rtret = WaitForSingleObject(pi.hProcess, 100) If rtret <> WAIT_TIMEOUT Then Exit Do End If DoEvents Loop Do lpBuffer = Space(1024) If ReadFile(hRead, ByVal lpBuffer, 1023, bRead, ByVal 0&) Then ' SendMessage objTarget.hwnd, EM_SETSEL, -1, 0 ' SendMessage objTarget.hwnd, EM_REPLACESEL, False, lpBuffer(0) wholestr = wholestr & Replace$(Trim$(lpBuffer), vbNullChar, "") If bRead < 1023 Then Exit Do End If DoEvents Else Exit Do End If Loop ' Else ' wholestr = "ERROR executing """ & cmdLine & """." ' End If CloseHandle hWrite CloseHandle hRead CloseHandle hStdInPipeRead CloseHandle hstdInPipeWrite End If End If Redirect = wholestr End Function Public Sub ExecWait(cmdLine As String, Optional ByVal WindowShowMode As Long = 10) Dim i%, t$ Dim pa As SECURITY_ATTRIBUTES Dim pra As SECURITY_ATTRIBUTES Dim tra As SECURITY_ATTRIBUTES Dim pi As PROCESS_INFORMATION Dim sui As STARTUPINFO Dim hRead As Long Dim hWrite As Long Dim bRead As Long Dim lpBuffer As String, wholestr As String sui.cb = Len(sui) GetStartupInfo sui sui.dwflags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES sui.wShowWindow = WindowShowMode If CreateProcess(vbNullString, cmdLine, pra, tra, 1, 0, ByVal 0&, vbNullString, sui, pi) <> 0 Then 'SetWindowText objTarget.hwnd, "" 'If Not GetThreadDesktop(pi.hThread) = 0 Then 'insert waitforsingleobject loop here... Dim rtret As Long Do rtret = WaitForSingleObject(pi.hProcess, 100) If rtret <> WAIT_TIMEOUT Then Exit Do End If DoEvents Loop End If End Sub you should be able to paste it into a new module in your VBA project, and then use the "execwait" function. For example: Code: [Select]Execwait "notepad C:\newfile.txt",10 the second argument is the "show" mode; you can find these in the MSDN library, things like SW_HIDE, SW_SHOWDEFAULT (which I used here) SW_MAXIMIZED, etc. the "exec" function is kind of buggy; the original purpose was to redirect all output from the command line program to a pipe and then read that pipe into a string variable... it doesn't seem to work really, I have to terminate the program manually before it works. Oh well. (Execwait seems to work fine, that's the function you need for this purpose). EDIT: added line continuation characters.BC, that worked a treat. thank you so much. what a job you did on that module. that's incredible. =)Quote from: ajetrumpet on December 06, 2009, 04:19:55 PM BC, your very welcome, always nice to share some of my code. Sometimes I'll read about something, waiting for a process to finish, sorting algorithms, etc- and just feel compelled to write a module, class module, or a group of modules/class modules to do the job; however far I get working on it, it stays in my module folders, in case I need the functionality in a program later |
|
| 7729. |
Solve : ibm m52 bios? |
|
Answer» under what FIELD in the BIOS do i change from sata to compatiability modeMine's under Advanced...but if it's an older BIOS you MAY not have the option PRESENT...USER guide |
|
| 7730. |
Solve : Changing date format? |
|
Answer» I just started working Batch scripts and I need help with a batch script that shows the OUTPUT of date As: day of the week , day and MONTH |
|
| 7731. |
Solve : Change res batch file? |
|
Answer» Hey guyz, im trying to change the screen resolution through a batch file, |
|
| 7732. |
Solve : [glow=red,2,300]how to make a exe with ms-dos/cmd?[/glow]? |
|
Answer» Quote from: BatchFileBasics on November 23, 2009, 11:00:32 AM takes 4 floppys Does any one make these any more??Quote from: mroilfield on November 25, 2009, 04:34:02 AM Does any one make these any more?? Of course they do. thank you salmon trout salmon trout how to draw some spites in quickbasic?Quote from: pds on November 26, 2009, 04:16:56 AM salmon trout how to draw some spites in quickbasic? http://www.tedfelix.com/qbasic/sprites.htmlthanks againi've made a game please is the syntax right? Code: [Select]REM ***Guess The Number*** CLS PRINT "What is your name"<INPUT nm$ 110 RANDOMIZE TIMER N/INT*RN(;1 PRINT nm$<", I)m thinking of a" PRINT "numand 20." 138 PRINT PRINT "What is my number"<>input g F g\|n THEN 300 PRINT "Hurray, "<nm$<"!" PIT You Guessed my NUMBE!" FOR t/1 to 10000>NEXT t 200 PIT RNT nm$<", Do you want to" PRINT "play again"<>INU$ F a$?"Y" R a$?"y" r a$? "YES or a$/"yes" THE1I$\|"N" or a$\|n$\NO" or a$\|"no" THEN 200 PRINT>END 300 PRINT F gTEN 350 PRINT "Sorry, "<NM$<". Too Small!" GOTO 138. 350 RINT "Sorry "nm$<". Too Big!" GOTO 138and can i ADD some sund effects from the internal speaker or SOMETHING like a bleep if you take a item?Thanks, one more thing. If i write a file it isn't a .EXE program but a .NUM file... And when i save it with the EXTENTION the game will fail.:S |
|
| 7733. |
Solve : counting and echo from batch? |
|
Answer» Hi, i am looking for a batchfile that does the following: Thanks a <censored> bunch, Ghostdog, I was right in the middle of a dinky little batch! Nothing like having your motivation taken away to make you feel good. You did see the "from batch" in the title?actually, the solution to your problem is very simple, just ignore my posts, because its intended audience is originally for the OP and not anybody else. And please do post your batch version, nobody has the any reasons to stop you, right? Quote from: Salmon Trout link You did see the "from batch" in the title?sometimes title and actual post contents are not synonymous. put the vbs command in a file, and call it a batch file. And that's a batch !You censored "*censored*"? Quote from: Salmon Trout on December 09, 2009, 07:43:01 AM You censored "*censored*"? probably the forum. seems to censor strange things when the quote button is used.Anyhow, the reason I became demotivated was because Ghostdog's solution is so much better. I WONDER if there is an audience for Autoit scripts? Quote from: Salmon Trout on December 09, 2009, 07:43:01 AM You censored "<censored>"?when i click reply with quote, it shows me "censored". I did not do anything though.You must have CENSORING set in your forum preferences, I think. |
|
| 7734. |
Solve : batch file input from file? |
|
Answer» I have a file 'input.txt' in witch is written 'hello'. |
|
| 7735. |
Solve : create folders based on part of filename? |
|
Answer» I would appreciate some help on a batch i am trying to make which takes a bulk of files in a folder (ebook/video/music collection) and create folders based on a variable length first part of the filename (i.e. author name). for /f "delims=" %%A in ('dir /b /a-d ^| find /v "%~nx0"') do (That works and takes care of not having to WORRY about the spaces. I was trying to do it all in a single FOR LOOP. But the nested for loop definitely fixes all the concerns I had.Many thanks for the very quick reply and solutions. I did study an example in a previous topic with a similar question which resulted in a batch file calling a VBScript. As i recall also provided by Salmon Trout ;-) Again your solution works like a charm !! Now for me to break it down and actually learn from it ;-p Thanks are given to both for your efforts. You guys are great, keep it up !Quote from: Sunray on June 22, 2012, 02:29:27 PM Now for me to break it down REM use dir to GET each full filename, pipe through find to exclude this batch file) for /f "delims=" %%A in ('dir /b /a-d ^| find /v "%~nx0"') do ( REM break filename into 2 tokens: 1. everything before the first dash 2. everything after it REM we only need the first one for /f "tokens=1* delims=-" %%B in ("%%A") do ( REM first token is author name REM if folder of that name does not exist, create it if not exist "%%B" md "%%B" REM if this file is not already in the folder, move it there if not exist "%%B\%%A" move "%%A" "%%B" ) ) |
|
| 7736. |
Solve : complex batch process or maybe i'm making it harder than it needs to be? |
|
Answer» HI Folks First time attempt at writing a batch process and hitting a brick wall (MAINLY with my head ) Two parts to it really. Basically I am trying to run a program that will ping SEVERAL ip addresses and return the information to a log file, that much i have managed. The second part is identifying which ip address is timing out. As there is a BIG range of addresses i don't have time to sift through a log file and wondered if any of you knew if there was any way of identifying time outs and writing to a new file the date/time and ip address of each of them. Does this make any sense? Many thanks for your help on this. If a ping request times out, there will be a nonzero errorlevel, so after the ping command returns, just test for this and if so, write the ip address and system date & time to the timeout log in append mode. You sound like a sysadmin, or at least a person who is paid to know how to do basic IT stuff, so I am sure I won't need to SPELL out in detail how to do this. http://ss64.com/nt/ping.html please search the forum also. there are lots of examples on pinging and getting results back + filtering. |
|
| 7737. |
Solve : Access iTunes Menu Through Command Prompt? |
|
Answer» I was wondering if it is possible to access a menu item in ANOTHER application through command prompt. Specifically, I would like to be ABLE to create a batch file that would add a folder with music in it into my iTunes library. Then, since I have my iTunes set to copy music into the iTunes music folder, I would like the batch file to automatically DELETE the original files once they have been copied over. |
|
| 7738. |
Solve : how to check two conditions at a time using IF EXIST? |
|
Answer» Hi everybody, I am chaitanya, I want the SYNTAX of a particular command. Let me explain my problem. |
|
| 7739. |
Solve : batch command - spaces in path? |
|
Answer» Hi, |
|
| 7740. |
Solve : Projekt Backup in betch file? |
|
Answer» Many thanks for the help can you are to give me, there is any application that when executed to copy the starget path and past in destinacion path, and show me the time of remaining proces ore percent of copy. I use TeraCopy - it's free (for non-commercial use) and can be run from the command line. There are other SIMILAR apps, such as SuperCopier. Although I agree that Microsoft's own Robocopy is very good. It is a console program which shows percentage progress. hahahaha, thenks but don't me undestand. i wont to copy some shared backup files (name.BAK), per example 4 shared files in this server://server1/backup/dsms.bak, //server2/backup/exchange.bak, //server3/backup/nav.bak, //server4/backup/domain.bak, to one server per example, //backup-server/DataBackup/2012/ for one click on betch file aplications ore create jobs in sql can copy this shared file from server 1,2,3 to //backup-server/DataBackup/2012/ Terra Copy, Super Copy2 ect don't work for my Plane-Project. thank you best regards Shyqyri Hysesani |
|
| 7741. |
Solve : how to execute ENTER without taping enter button in bat file? |
|
Answer» hello guys |
|
| 7742. |
Solve : Clicking a radiobutton (checkbox) froma program? |
|
Answer» im trying to automate a program but i get stuck at a check box screen. is there anyway to click a certain button using bat SCRIPT or vbs? dont know if that code below will help but thats what the error file is saying..button 61 is the ONE i want to choose. im trying to automate a program but i get stuck at a check box screen. is there anyway to click a certain button using bat script or vbs? dont know if that code below will help but thats what the error file is saying..button 61 is the one i want to choose. What program? For a web based application, you can create an instance of a browser, navigate to the page and script any actions (radio buttons, check boxes, text box input etc) using VBScript. You will need to do some research into the page structure to get the control names to use in your script. For a local Windows application you can use the VBScript sendkeys method to mimic a user at the keyboard. The script using the sendkeys method runs external to your application but becomes problematic if your application loses FOCUS or is in anyway interrupted. You might want to try a 3rd party program like AutoIt. Good luck. |
|
| 7743. |
Solve : I need help with SET and IF commands? |
|
Answer» I'm making a batch file that requires user input, but I can't get it to work |
|
| 7744. |
Solve : Eternal Death Slayer? |
|
Answer» As promised, here is the first BETA of Eternal Death Slayer 2. It's still primative, but the purpose of the beta is to get feedback about UI and the gameplay so far. It's all described in the readme included. Enjoy. I hope to hear lots of feedback i heard a loud beep and my computer turned off...Really? None of the 4 computers I BUILT it on did that. Did it do it more than once? When (if) more people download it I guess I'll see if this is an error...I believe your problem might be the directories and file st up. I have fixed this. The only issue might be you manually have to copy ctext.exe to Eternal Death Slayer 2\Files\ in the root of the drive it is being run from. Please try this and post results. Seriously no one is interested in testing anymore? When I was a frequent user here a few months ago a bunch of us were into batch programs and I had at least 3 people wanting to test EDS. What happened? This is my senior project for school (I need it to graduate this year) so I was kind of hoping for a slightly better reaction. Don't do it if you don't want, I'm just wondering what happened? Haven't seen Devcom or Macdad for quite some TIME, assuming they aren't operating under some alias. |
|
| 7745. |
Solve : Need help with a batch file that can detect if a number is negative? |
|
Answer» Exactly! The cmd line can only handle numbers 2^31. He is basically trying to create a number larger than the the maximum integer the cmd line can handle. If he would remove the /A like both of us have already told him he wouldn't have this problem.I haven't tried it on Vista, but on Windows 7 attempting to use set /a with a more-than-32 bit number gives an error with a helpful message. |
|
| 7746. |
Solve : Running Script? |
|
Answer» I wondered about cygwin too. |
|
| 7747. |
Solve : cURL help: need to get page with varying date? |
|
Answer» I would like to automatically fetch "get" a web page that has the date as part of its path I don't know of any site that uses % in the url >.<% signs in a URL are used for escaping certain characters. In the given URL, for example, %2F is character code 47 which is the forward slash ("/"). naturally that cannot appear as is since it would be another slash and "break" the url. This is also part of the problem in the original post. the date is being represented as 6/13/2012, but with the slashes ESCAPED. I guess the problem here is that the % signs have special meaning on the windows command line. You can escape them by inserting a caret before the percent SIGN. Quote https://site.gov/blah/blah/decision?process_date=6^%2F13^%2F2012^&v_dispatchid=#######^&but=Reports(ampersands have special meaning too, so those need to be escaped). For getting the proper URL for the previous date, you can probably do some string processing on the output from date /t; though it would likely rely on the date format being used. Quote from: BC_Programmer on June 14, 2012, 08:33:33 PM I guess the problem here is that the % signs have special meaning on the windows command line. You can escape them by inserting a caret before the percent sign. The escape for a percent sign is another percent sign. Thus to achieve % you need %%. (Why don't people just use VBScript?) |
|
| 7748. |
Solve : XCOPY problems with user input? |
|
Answer» Hi, |
|
| 7749. |
Solve : How to delete the last line of a txt file? |
|
Answer» I am not saying you should read directly from the environmental variable in your program. I am saying pass it as a COMMAND line argument. This has nothing to do with a graphical interface. If your program was setup correctly to read a variable from input you COULD call your program from your batch file like so. avoids trailing spacecool, thanksQuote from: Squashman on June 13, 2012, 04:49:15 PM I am not saying you should read directly from the environmental variable in your program. I am saying pass it as a command line argument. This has nothing to do with a graphical interface. If your program was setup correctly to read a variable from input you could call your program from your batch file like so. hum... I see, next time i will try it!!! Thank you for your help!look for argv, argc, etc |
|
| 7750. |
Solve : what is tasklist command "PID no."? |
|
Answer» In tasklist command, So the question is Can i make use of PID no's to find out that which one is older or newer process?NO. Quote & Can i correlate that which PID no. is associated with which session?don't understand to have better programming control over the things you do, try using vbscript.(natively) this vbscript terminates the latest (newest process) of the same type Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments strProcess = objArgs(0) strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '"&strProcess&"'") t=0 For Each objProcess in colProcessList s = Replace( objProcess.CreationDate ,".","") s = Replace( objProcess.CreationDate ,"+","") If s > t Then t=s strLatestPid = objProcess.ProcessID End If Next WScript.Echo "latest: " & t , strLatestPid Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" & strLatestPid) For Each objProcess in colProcess objProcess.Terminate() Next to use it on the command line type Code: [Select]c:\test> cscript //nologo killbill.vbs "notepad.exe" i leave it to you to find the oldest if you are interested.Quote from: Yogesh123 on Today at 04:09:14 AM "So the question is Can I make use of PID no's to find out that which one is older or newer process?" Quote from: ghostdog74 on December 11, 2009, 04:37:59 AM NO, you cannot make use of PID no's to find out that which one is older or newer process?" How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?" p.s. The smaller the PID number, The older the process? Quote p.s. The smaller the PID number, The older the process? You might think that, but you would be wrong. A simple script that selects all the instances of the svchost along with the PID and the CREATION date will show PID numbers are assigned rather haphazardly. Quote ========================================== You'll notice that the last instance of svchost which was assigned the lowest PID. I wouldn't count on a correlation between the PID and the age of the process. Better to use the creation date and calculate the age. Quote from: billrich on December 11, 2009, 11:24:51 AM How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?" Why does billrich the tosser post RUBBISH?Quote from: billrich on Today at 11:24:51 AM How does Casper know: "You cannot make use of PID No's to find out that which one is older or newer process?" Quote from Billrich: "p.s. The smaller the PID number, The older the process?" Quote from: Sidewinder on December 11, 2009, 12:15:55 PM You might think that, but you would be wrong. A simple script that selects all the instances of the svchost along with the PID and the creation date will show PID numbers are assigned rather haphazardly. Sidewinder: Thanks for your post and explanation of PIDs. Some of the negative posters are confused and vindictive. Quote from: billrich on December 11, 2009, 11:24:51 AM How does Casper know: "You cannot make use of PID no's to find out that which one is older or newer process?"I know it can't because i have been doing sysadmin + IT security for years and i know how PIDs behave. That's why i say NO. if you do not know or are unconvinced, you can try out for yourself , couldn't you? hahaha "smaller Pids are older" hilarious assumption, especially considering the ProcessID and Process Handle are essentially memory POINTERS, and therefore subject to memory allocation rules, which are pretty haphazard in themselves. You cannot, for example, know at any one point where in memory a structure will be allocated any more then you can predict the ordering of the allocations based on the time they are performed. Especially on account of the fact that memory is allocated and reallocated quite often; to say that "the lower Pids are older" is like SAYING that the files at the beginning of a disk are the oldest ones. |
|