Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

6051.

Solve : How can one access an archive (.7z specifically) from a batch program??

Answer»

How can one access an archive (.7z specifically) from a batch program.

is there a way to copy files to/from an archive with a batch? i think it could be useful, especially for the program i have in mind. this is its only real hitch. one year later, im STILL looking for this code. apearantly, few/none have tried it before. also, i'd like to be able to remove files from an archive (as in delete them from) without corrupting the whole archive. if this works, i may have a HUGE project in this, and i will be sure to include all that helped in the comments section of the exe (i use a compiler), if they so wish. thanks again.http://dotnetperls.com/Content/7-Zip-Examples.aspx not your average simple batch code... but then i suppose this is not the average batch function. Thank you for the link, and work on my latest project will run MUCH more smoothly now! QUOTE from: TheShredder on February 03, 2009, 12:46:54 PM

not your average simple batch code...

Really? The commands look pretty similar to those for the Winzip and WinRar command line utils.

For example to add all the text files in a folder to an archive called Files.7z...

Code: [Select]7za.exe a -t7z files.7z *.txt
Very simple indeed.



ahhh, brings back memories of PKZIP and PKUNZIP switches... or maybe I should shudder, I don't know.Quote from: BC_Programmer on February 03, 2009, 02:51:11 PM
ahhh, brings back memories of PKZIP and PKUNZIP switches... or maybe I should shudder, I don't know.

I use rar.exe every day, and I have fond memories of LHarc, ARJ, ACE, etc. GUIs are for wimps.
heh. one more problem. for some reason, after downloading the 7za.exe and designating the proper folder that its in, it STILL wont recognize the 7z (command) (switches) (archive name) (file names) command line. I'm working on an xp, but i dont think that should matter. any ideas? What do you mean "won't recognize"? Describe what happens. Give examples of code used and any error messages. If the folder has spaces in the name are you using quotes? Likewise for file names. Did you download the right package? And extract the executable? Are you running a 64 bit OS?

Yes i downloaded that one. i was proud of myself for not just downloading the top one, which is usually standard protocol when downloading. I'm actually using the %* variable so that files can be just clicked and dragged into the program's icon, which is the equivalent of typing the file's full directory and name w/ file extension in quotes. i love that lil variable

the only ERR i'm getting is sayin that "7z is not RECOGNIZED as a comand."

7z a -mx9 TheBox.7z %*

thats the code they give on the web site posted above (someone else's post.)
.........................

Ignore that. solved it. =) the command is 7za.exe, i thought i was mistaken cause i had tried 7z and 7z.exe. forgot the A. but thanks everyone. you all have been huge help, and if anyone ever wants help lemme know
6052.

Solve : Need help for a batch file?

Answer»

Is a little batch to run ip config I make because one of my friend is scare of command prompt! (since I use choice.exe I know is only work in vista or maybe other...). Anyway I think I make some bug an I need a cleanup. Plx can you tell me what to do (or COPY paste the code with modification)? Thx a lots! P.S. 1.Sorry for my bad english since is not my native language 2. You are free to add your credit to the code or make it look better =)

here the code :

:start
@echo off
color 1f
@echo ----------------------------------------------------------------------
@echo.
@echo ______ ____ ___
@echo /\__ _\ /\ _`\ /'___\ __
@echo \/_/\ \/ \ \ \L\ \ ___ ___ ___ /\ \__//\_\ __
@echo \ \ \ \ \ ,__/ /'___\ / __`\ /' _ `\ \ ,__\/\ \ /'_ `\
@echo \_\ \__\ \ \/ /\ \__//\ \L\ \/\ \/\ \ \ \_/\ \ \/\ \L\ \
@echo /\_____\\ \_\ \ \____\ \____/\ \_\ \_\ \_\ \ \_\ \____ \
@echo \/_____/ \/_/ \/____/\/___/ \/_/\/_/\/_/ \/_/\/___L\ \
@echo /\____/
@echo \_/__/
@echo.
@echo.---------------------------------------------------- Make by: Charge50
@echo.
@echo (S)imple (no info) or (P)ro (All info) mode? press (Q) to quit
@echo.
@echo Run this file as administrator
@echo (if you WANT to use Ip release)
@echo.
@echo (S, P or Q)
choice /n /c qsp
if errorlevel 3 goto pro
if errorlevel 2 goto simple
if errorlevel 1 goto quit
:simple
cls
@echo Do you want to run Ip Release (recomended)
@echo.
@echo you need to right click on you ICON
@echo an run as administrator
@echo to run this function
@echo.
@echo (Y or N)
choice /n /c yn
if errorlevel 2 goto cren
if errorlevel 1 goto release
:release
cls
@echo Ip is gona be release in 5 sec
@echo (If operation take more than 45 sec close the windows)
ping localhost -n 6 1>NUL 2>&1
@echo.
ipconfig /release 1>NUL 2>&1
if errorlevel 1 goto norel
@echo.
@echo.----------
@echo Ip Release
@echo.----------
:cren
cls
@echo Do you want to run Ip Renew (The repair)
@echo.
@echo (Y or N)
choice /n /c yn
if errorlevel 2 goto quit
if errorlevel 1 goto renew
:renew
cls
@echo Ip is gona be renew in 5 sec
@echo (If operation take more than 45 sec close the windows)
@echo.
ping localhost -n 6 1>NUL 2>&1
ipconfig /renew 1>NUL 2>&1
if errorlevel 1 goto norel
@echo.
@echo.--------
@echo Ip Renew
@echo.--------
@echo.
@echo you ip is supposed to be ok
@echo.
pause
:quit
cls
@echo press any key to exit
pause 1>NUL 2>&1
exit
:norel
cls
@echo ------------------------------
@echo Ip release fail!
@echo ------------------------------
@echo Did you run as administrator?
@echo The option release is optional
@echo.
@echo Do you want to run Ip Renew instead? (the repair)
@echo or press R to retry Ip release
@echo.
@echo (Y, N or R)
choice /n /c ryn
if errorlevel 3 goto exit
if errorlevel 2 goto renew
if errorlevel 1 goto release
:noren
cls
@echo ------------------------------
@echo Ip renew fail!
@echo ------------------------------
@ For some reason Ip renew fail!
@echo.
@echo Do you want to try again? (Y or N)
@echo or press R to restart the program
@echo.
@echo (Y, N or R)
choice /n /c ryn
if errorlevel 3 goto quit
if errorlevel 2 goto renew
if errorlevel 1 goto start
:startpro
@echo ----------------
@echo Ip Repair Batch
@echo.----------------
:pro
@echo.
@echo Do you want to run Ip Release
@echo You may need to run as administrator
@echo.
@echo (Y or N)
@choice /n /c yn
if errorlevel 2 goto crenpro
if errorlevel 1 goto releasepro
:releasepro
@echo.
ipconfig /release
if errorlevel 1 goto norelpro
pause
@echo.
@echo.----------
@echo Ip Release
@echo.----------
:crenpro
@echo.
@echo Do you want to run Ip Renew
@echo.
@echo (Y or N)
choice /n /c yn
if errorlevel 2 goto quitpro
if errorlevel 1 goto renewpro
:renewpro
@echo.
ipconfig /renew
if errorlevel 1 goto norelpro
pause
@echo.
@echo.--------
@echo Ip Renew
@echo.--------
@echo.
@echo you ip is supposed to be ok
goto quitpro
:norelpro
@echo.
@echo ------------------------------
@echo Ip release fail!
@echo ------------------------------
@echo Did you run as administrator?
@echo.
@echo Do you want to run Ip Renew instead?
@echo or press R to retry Ip release
@echo.
@echo (Y, N or R)
choice /n /c ryn
if errorlevel 3 goto quitpro
if errorlevel 2 goto renewpro
if errorlevel 1 goto releasepro
:norenpro
@echo.
@echo ------------------------------
@echo Ip renew fail!
@echo ------------------------------
@ For some reason Ip renew fail!
@echo.
@echo Do you want to try again?
@echo or press R to restart the program
@echo.
@echo (Y, N or R)
choice /n /c ryn
if errorlevel 3 goto quitpro
if errorlevel 2 goto renewpro
if errorlevel 1 goto start
:quitpro
@echo.
ipconfig /?
@echo ----------------------
@echo type exit to quit cmd
@echo ----------------------
cmdThe choice commands are using invalid switch syntax:

Wrong:
Code: [Select]choice /n /c qsp

Right:
Code: [Select]choice /n /c:qsp

This too is right; your choice!
Code: [Select]choice /n /cqsp


Check all your choice commands. You were very consistent.
If you put @echo off at the beginning. You don't need all those @'s .Quote from: Sidewinder on February 02, 2009, 06:16:45 PM

The choice commands are using invalid switch syntax:

Wrong:
Code: [Select]choice /n /c qsp

Right:
Code: [Select]choice /n /c:qsp

This too is right; your choice!
Code: [Select]choice /n /cqsp


Check all your choice commands. You were very consistent.


Thx for the tip so i guess choice /n /c qsp can work with choice.exe but not .com an /n /c:qsp work with both.

anyway I'm currently trying to remove some an repost it after I add windsock repair...but actually I don't know where to put it in the code (after ip renew? after...). Also I guest by copy choice.com in the same folder of the batch will make it work in windows xp an vista (since I think choice.exe don't work in xp...)Quote from: BatchFileCommand on February 02, 2009, 06:19:57 PM
If you put @echo off at the beginning. You don't need all those @'s .

Also thx for the tips! Is my second batch file (First 1 was hello world XD) so is a little If backward compatibility is not a concern, then use the Vista choice options as /c qsp. Both choice.exe (NT prior to Vista) and choice.com (DOS) will break with a space between the /c switch and the choices.

Repeating the last suggestion, use @echo off at the top of your file and remove the @ from the other echo statements.

To prevent writing duplicate code, put the ipconfig /renew and ipconfig /release statements in subroutines where you can call them at the appropriate times.

Quote
anyway I'm currently trying to remove some <junk> an repost it after I add windsock repair...but actually I don't know where to put it in the code (after ip renew? after...)

Repairing the winsock catalog is done with the netsh utility. Not sure you should put it here or design a batch application for netsh separately.

Good luck.
6053.

Solve : Can I use md to link to a network computer to determine the OS?

Answer»

I have code to CREATE the directory I WANT on a networked computer, but I need to determine the OS in order to write to the correct drive (C for XP or D for 2000). Is it POSSIBLE or do I have to use net use.

Thank you

Code: [Select]IF NOT EXIST \\DATABASE_WORKSPACE\D$\TESTFOLDER\ md \\DATABASE_WORKSPACE\D$\TESTFOLDER
IF EXIST \\DATABASE_WORKSPACE\D$\TESTFOLDER\
VER | FIND "2000" > NUL
IF %ERRORLEVEL% == 0 GOTO VER_2000Try this http://malektips.com/xp_dos_0025.htmlThanks that worked.

6054.

Solve : need a command that tests for a drive letter?

Answer»

im trying to write a batch file that writes a file to a usb pen drive

im looking for a dos command that will identify the first existing drive letter after the D Drive (CDROM)

I am aware that you can set the drive letter of the usb STICK in Disk Management but in my experience i have seen drive letter change from E to F for unknown reasons

There maybe no files on the usb stick so i cannot use the IF EXIST command

is there a dos command for this or a way to code it in a batch file?

TIA

SethHere are the steps you will NEED to assign a permanent drive letter to a thumb drive.
http://mintywhite.com/tech/vista/assign-a-permanent-letter-to-a-usb-thumb-drive-2/
Hope this is what you really wanted
mm, thats kind of what i mentioned in my original post abouting using Disk management.
The thing is, my CUSTOMER is going to be using multiple USB sticks (its for a daily backup routine)
ive seen them put in one stick and it comes up E then a few weeks later the same stick will come up as F drive
also if they buy a new stick i dont want them to have to go down the route of assigning drive letters etc as they are not that technical.I also know of a backup program that detects when a usb drive is inserted and performs an automatic backup. I bought it for a friend a while back. Forget the name off hand but it's out there. Why reinvent the wheel. I BELIEVE this is it.
http://www.backupusb.com/
Quote

There maybe no files on the usb stick so i cannot use the IF EXIST command

IF exist will find the root folder.
Consider changing your way of thinking on how to resolve your problem and use the MS DOS command "MOUNTVOL" as follows. In this example certain commands have been "remmed" out for safety.

rem By using the "MOUNTVOL" command USB drives used as backup-to-disk targets
rem can be either removed or PLUGGED back in.
rem By using the "NET SHARE" command USB drives may be shared out to users.

c:
cd C:\windows\system32\

cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem These commands removes the "volume mount point" from the "specified directory"
@echo on
rem This commands removes the drive letter F: from the USB device name
rem mountvol.exe F: /D
rem This commands removes the drive letter G: from the USB device name
rem mountvol.exe G: /D
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem These commands assign the "volume mount point" to the "individual directory"
rem Should you be required to use the "volume mount point" for different USB Drives
rem You can mountvol different "individual directory" so long as there is only 1
rem USB drive plugged in at once.
@echo on
rem mountvol.exe F: \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
rem mountvol.exe F: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
rem
rem mountvol.exe G: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
@echo off

rem F:\ = \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
rem G:\ = \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays the available "shares"
@echo on
net share
@echo off

@echo.
@echo.
pause


rem ***************
cls
@echo.
@echo.

rem This command stops sharing the available "shares"
@echo on
net share F /delete
net share G /delete
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command shares out the USB directory drive with an assigned shared name
@echo on
net share F=F:
net share G=G:
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays the available "shares"
@echo on
net share
@echo off

@echo.
@echo.
6055.

Solve : How to get physical drive's device id using DOS command?

Answer»

There are 24 physical drives attached to a system.
How can i get all 24 physical drive's device id number using DOS command?
Also please let me know which commad to be used.

Any help is greatly appreciated.

Thanks in ADVANCE,
pinksTry using the MS DOS command "MOUNTVOL" as follows. In this demonstration example certain commands have been "remmed" out for safety.

rem By using the "MOUNTVOL" command USB drives used as backup-to-disk targets
rem can be either removed or plugged back in.
rem By using the "NET SHARE" command USB drives MAY be shared out to users.

c:
cd C:\windows\system32\

cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem These commands removes the "volume mount POINT" from the "specified directory"
@echo on
rem This commands removes the drive letter F: from the USB device name
rem mountvol.exe F: /D
rem This commands removes the drive letter G: from the USB device name
rem mountvol.exe G: /D
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem These commands assign the "volume mount point" to the "individual directory"
rem Should you be REQUIRED to use the "volume mount point" for different USB Drives
rem You can mountvol different "individual directory" so long as there is only 1
rem USB drive plugged in at once.
@echo on
rem mountvol.exe F: \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
rem mountvol.exe F: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
rem
rem mountvol.exe G: \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\
@echo off

rem F:\ = \\?\Volume{f90aec0d-a238-11dd-8bd4-001c23d69c2e}\
rem G:\ = \\?\Volume{10badd33-a9b2-11dd-a3fc-001c23d69c2e}\

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays both the details of the corresponding Volume Names and Paths
@echo on
call mountvol.exe
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays the available "shares"
@echo on
net share
@echo off

@echo.
@echo.
pause


rem ***************
cls
@echo.
@echo.

rem This command stops sharing the available "shares"
@echo on
net share F /delete
net share G /delete
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command shares out the USB directory drive with an assigned shared name
@echo on
net share F=F:
net share G=G:
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays the available "shares"
@echo on
net share
@echo off

@echo.
@echo.

Report to moderator 81.144.157.73

6056.

Solve : AUTOMATIC BACKUP COMMAND?

Answer»

I am USING windows xp pack 2 and i want to WRITE a an automatic backup command using ms dos to backup a database i DEVELOPED using microsoft access.How do i do that?
TRY using the Microsoft Windows NTbackup command.
You will also have to Stop and Start the Database to avoid corruption. You can use NET STOP ( service name ) to stop the database then COPY the MDB to a location either local, remote, or to some other media, then NET START ( service name ) to start the database back up.

I use a silimar batch for backing up my MSSQL database...with MSSQL you may also have to stop and start the SQL Agent Service.

6057.

Solve : Task Bar Hangs Coming Out of Screen Saver?

Answer»

Task bar seems to hang - turns dark blue with no icons showing - for about 8 SECS after deactivating the screen saver either by TOUCHING a key or moving the mouse. If I wait the 8 sec or so then everything is fine. Task bar has an hour glass if I hover over it.
I have a default screen saver. I've started noticing that all PCs EXPERIENCE so some sort of DELAY - some more than others. But mine is excessive. No errors in event viewer. Tried a few solutions found through my searches, but no LUCK. Small problem but It bothers me. Any one experience this issue.
Thanks

XP SP3
No hibernation, no power saving mode, no upsQuote from: mayers57 on February 05, 2009, 05:03:29 AM

Task bar seems to hang - turns dark blue with no icons showing - for about 8 secs after deactivating the screen saver either by touching a key or moving the mouse. If I wait the 8 sec or so then everything is fine. Task bar has an hour glass if I hover over it.
I have a default screen saver. I've started noticing that all PCs experience so some sort of delay - some more than others. But mine is excessive. No errors in event viewer. Tried a few solutions found through my searches, but no luck. Small problem but It bothers me. Any one experience this issue.
Thanks

XP SP3
No hibernation, no power saving mode, no ups
Wrong section.didn't notice it, sorry
6058.

Solve : How to check If...choice.exe else...choice.com?

Answer»

Here a QUICK batch file (I know is not working! I just use it for a example of what I want to do) What I need to INPUT in the section? THX for you help


rem since 64 BIT don`t support choice.com

ver | find "Microsoft WINDOWS [Version 5.2.3790]"
if %ERRORLEVEL% == 0 ???use choice.exe to current folder??? goto start

ver | find " Windows vista 64 bit??? [Version ]"
if %ERRORLEVEL% == 0 ???use choice.exe to current folder??? goto start

rem maximum compatibility in other os

use choice.com to current folder???
goto start

:start
....
...
...
choice.......:123
if..
..
..

:end
vista is version 6.0.6001 but remember that not all users are from USA / England so they might have different language
better try:
Code: [Select]
if exist %windir%\System32\choice.exe (
//use choice.exe
) else (
if exist %windir%\System32\choice.com (//use choice.com) else (//there is no CHOICE)
)
)
Forget to mention I want my batch to run in most os (Xp/Vista mostly an maybe 7)

but the problem is in windows xp you need the set /p (I think an I want to avoide using 1 batch for xp an 1 batch for 64 bit (vista/xp) an 1 for other) since choice don't exists. But I add choice.exe (to make my batch file run a 64 bit environment since choice.exe is 32 bit) an choice.com (to have more compatibility) in the same folder of my batch. So my batch will run in the folder, use choice.com or choice.exe in the same folder with the batch. Here is my a example (an thx for trying to help me)

Code: [Select] example: (This is not a batch! is more like a guide)

ver | find "Microsoft Windows [Version 5.2.3790] <-- = all windows xp 64 bit (an 2003 but it will support my choice .exe i hope)
set default choice = set currentfolder/choice.exe

ver | find "Windows" [Version x.x.xxxx] <-Vista 64 bit Version?

set default choice = set currentfolder/choice.exe

rem else

set default choice = set currentfolder/choice.com


P.S. This is to show what I try to make an not a batch file

6059.

Solve : Execute the F5 key with a command in Scheduler?

Answer»

Hi all,

My Windows Scheduler has to start some software on my computer, by clicking the Start button.
This Start button is also assigned to the function key F5.
I know how to work with the Scheduler, but is it possible to define a script/command to execute this "F5 press"?

PLEASE help!

Vince
It depends on what you are trying to do. Do you have more information about the task?

I don't know of a way to do it with at pure batch file, but if you can use vbscript or wsh to execute your tasks, you can use this CODE:

Code: [Select]Set objShell = CreateObject("WScript.Shell")
objShell.SendKeys "{F5}"
Just copy this to a file, and rename it to f5key.vbs. When you run it, it will simulate a keyboard press of the F5 key.Hi, thanks for the answer, but I'm sorry, I can't use vbscript...

The situation is this:
I'm using some software for a measuring equipment on a laboratory.
The equipment is very sensitive for VIBRATIONS, so I want to start this device at night, when the cleaners are outside this laboratory...
The fist thought was using Windows Scheduler to give the software a 'cue' to begin the experiment at a certain time, let say 2am.
So, the software is already started up and waiting for this cue to begin.
This can be done with pressing the 'start button' but also with the F5 key on the keyboard.

So, now I'm looking for a method to let give Scheduler this F5 command.

MAYBE this can be done with a small batch file, that will be executed by the Scheduler at 2am ?



Quote

Execute the F5 key
You can just do it with a screwdriver...
Hi !
Thats great !! Thanks Geek-9pm
Is this a normal screwdriver? Or Torx or Philips?
Please give me the color of the shaft, so I can buy the same as you have.
There is one problem: I'm lefthanded, so my F5 key can flip over to the right instead of left.
Hope this will not be a big problem...
Thanks again, and maybe till next time.

Dixi
Anyway- why can't you use VBScript? you could use the scheduler to schedule the script to run, and then it would "press f5" for you.Quote
Anyway- why can't you use VBScript?

{Whisper: Just act dumb and
BC will do the script for you.}
erm- the script was already written by icepick.
6060.

Solve : SOME1 find error in my code plz?

Answer»

Hi! I have problem with my code:
@echo off
for /f "tokens=*" %%I in ('dir /B /s /a-d "C:\bat"') do (
set /p CHOICE="%%~nI"
echo.
echo file %choice%
echo.
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET J=-1
SET T="%%~nI"
:STRLEN_LOOP
SET /A J += 1
IF NOT "!T!" == "" IF NOT "!T!" == "!T:~0,%J%!" (
GOTO :STRLEN_LOOP
)
SET /A J -= 2
ENDLOCAL & SET RESULT=%J%
echo bukv %result%

)
pause

This code FIND files with lenght of file name ==5 in some folder.
But For don't WORK here( Program takes just 1 file( from folder(
I think where are some problem here:
:STRLEN_LOOP
SET /A J += 1
IF NOT "!T!" == "" IF NOT "!T!" == "!T:~0,%J%!" (
GOTO :STRLEN_LOOP
)
because without it all works perfect...
Can SOMEONE help me plz?
And sorry for my bad language cos i'm from RUSSIA...

6061.

Solve : Is there a way to make a shared file in DOS??

Answer»

Mainly for metworking reasons. I'm having trouble backing up files on my new laptop, and I can't really start windows on it due to a login error. Under HP's Reocvery Manager, when I try to use the Backup Files option, it demands a USB drive... except it can't detect one. And I assume that networking-wise, it can still be read, but none of my files on the new laptop were opened for file sharing. Is there way to do that via DOS?Easier approach to getting your important data off of this copied to another system may be to use Laplink or another serial or parallel communication setup to transfer files from one system to the next over a native DOS or DOS Shell with the other running windows dos shell.

There was a free one available on the net, but I cant seem to find it...all you NEEDED was a Serial Null cable and serial ports at each system, and the software installed andrunning to link the systems and then be able to select specific folders or all data.

The maximum transfer rate I ever got with serial was 115k I think, so it took almost 4 hours to copy my data from the unhealthy laptop to the desktop computer over serial but I got all my data. This was also however with a FAT32 partition on the Windows 98 laptop that crashed and I am not sure of this method will work for a NTFS partition.

Maybe someone here knows of the free laplink ( clone to LapLink but DIFFERENT name ) tool that was available that I cant seem to locate and can link it.

Trying to set up a TCP/IP network on this laptop with DOS might be a nightmare tryingt o find a DOS driver for the integrated NIC chipset.Quote from: Kisai on January 14, 2009, 04:57:53 AM

Mainly for metworking reasons. I'm having trouble backing up files on my new laptop, and I can't really start windows on it due to a login error. Under HP's Reocvery Manager, when I try to use the Backup Files option, it demands a USB drive... except it can't detect one. And I assume that networking-wise, it can still be read, but none of my files on the new laptop were opened for file sharing. Is there way to do that via DOS?

If, as your profile shows, your using Vista, there is no DOS built in. the closest thing would be recovery console.


What kind of Login errors are you experiencing? Perhaps we can help?I'm using a DOS Prompt, of course. Not running DOS DIRECT or anything.

And I've tried something like what Dave suggested. A friend gave me an external hard drive, and I can actually find it via DOS, and even copy files to it. I even learned xcopy for mass file copying, but a problem I keep running into is that sometimes it'll... have problems and be unable to copy a file. Is there a limit to how large of a file DOS can copy?have you tried the /C switch to continue copying even when errors occur?


your OS state confuses me... by "DOS prompt" do you mean the one provided with windows? DOS itself cannot use USB drives (reliably)What's /c supposed to do? ^^ And... I imagine it's provided by Windows... I can't see how else... But you can start up the laptop in such a way that it boots up to Windows, but only directly to some system tools, by-passing the login of course, but nonetheless, it is a small part of Windows. Just some system tools. And one of those is a command prompt that I've been using to try and copy files via DOS.Quote from: Kisai on January 15, 2009, 12:14:23 AM
What's /c supposed to do? ^^ And... I imagine it's provided by Windows... I can't see how else... But you can start up the laptop in such a way that it boots up to Windows, but only directly to some system tools, by-passing the login of course, but nonetheless, it is a small part of Windows. Just some system tools. And one of those is a command prompt that I've been using to try and copy files via DOS.

I explain what /c uses in the post. It continues when errors occur.

Are you saying you can start the laptop in safe mode?Wow. I Googled what /c does too... Goes to show that I definitely don't think well when multitasking.

And no, I can't. That would still require a login screen. I can only go to System Recovery Options. Things like Startup Repair, System Restore, Windows Complete PC Restore, Windows Memory Diagnostic Tool, Command Prompt and Recover Manager. I just copied them from what I saw on the other laptop. ^^; So I'm doing some robocopying from Command Prompt. I just wanna back up my videos and other personal files I've worked on before restoring the laptop to its default factory condition.Consider using the Microsoft "NET SHARE" command. Please see the piece of coding as an example.

rem ***************
cls
@echo.
@echo.

rem This command stops sharing the available "shares"
@echo on
net share F /delete
net share G /delete
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command shares out the USB directory drive with an assigned shared name
@echo on
net share F=F:
net share G=G:
@echo off

@echo.
@echo.
pause

rem ***************
cls
@echo.
@echo.

rem This command displays the available "shares"
@echo on
net share
@echo off

@echo.
@echo.
pause
6062.

Solve : Batch serial system, errors.?

Answer» QUOTE from: whitekidney on January 16, 2009, 03:00:08 PM
Still need help.
I agree that this seems kind of pointless because it is so easy to get around. But you should be able to do something like this for the serial part of your code:
Code: [Select]@echo off
setlocal
set ValidSerial=3612-3472-631
SET /P name= Enter your NAME here:

if exist cache.txt (
echo Found cached serial code ...
findstr.exe /b /e "%ValidSerial%" cache.txt>NUL
if not errorlevel 1 goto :LOAD
echo Bad cached serial code
echo Please enter a valid serial code.
)
:EnterSerial
SET /P serial= Enter your SERIAL CODE here:
if {%serial%}=={%ValidSerial%} goto :CacheSerial
echo You entered a bad serial code. Please try again.
goto :EnterSerial

:CacheSerial
echo %serial%>cache.txt
goto :load

:load
echo Serial code is valid.
echo Hello, %name%.
echo Enter more code here for what you want your program to do.
Oh god thanks it works.

Is there any way to make more serials out of it ?
It seems i can only use 1 serial code, if i do
Set Validserial=1234-1234-123
Set Validserial=1111-1111-111


The last one will only workBump!Quote from: whitekidney on January 26, 2009, 10:50:21 PM
Bump!

Around here, bumping earns you -500 priority points, which means I won't answer for 3 days.

Don't bump. It's not a good idea.


Quote from: Dias de verano on January 27, 2009, 12:26:16 AM
Quote from: whitekidney on January 26, 2009, 10:50:21 PM
Bump!

Around here, bumping earns you -500 priority points, which means I won't answer for 3 days.

Not withstanding the fact you weren't going to answer anyway, right?*CENSORED* boob..
o Well.. anyone got a solution ?Quote from: Dias de verano on January 27, 2009, 12:26:16 AM
Quote from: whitekidney on January 26, 2009, 10:50:21 PM
Bump!

Around here, bumping earns you -500 priority points, which means I won't answer for 3 days.

Don't bump. It's not a good idea.

lol

Anyway try to use for loopCome on, i need help. :xQuote from: whitekidney on January 28, 2009, 02:35:35 AM
Come on, i need help. :x

6 days now Quote from: Dias de verano on January 28, 2009, 06:46:57 AM
Quote from: whitekidney on January 28, 2009, 02:35:35 AM
Come on, i need help. :x

6 days now

You're ONTO a winner WhiteKidney, getting Dias to not burn you for 6 days is surely a good thing.

Also Devcom has ALREADY pointed you in the right direction...
Quote from: devcom on January 27, 2009, 05:52:44 AM
Anyway try to use for loop

And another thing, just wondering if you're aware of what your name means?

FBive tried so many diffrent things

anyone got any code for it ? :S9 days ? Quote from: devcom on January 28, 2009, 02:38:33 PM
9 days ?

Yup
This kid just doesn't learn.Erm, i almost got it, but still errors.

Anyone got any example code ?
6063.

Solve : How to see if a string exists in a txt file.?

Answer»

Quote from: BatchFileCommand on January 22, 2009, 04:45:33 PM

Oh, so now contrexing is some kind of rule. Sure....

Not a rule, more a process.
Quote from: BatchFileCommand on January 22, 2009, 04:45:33 PM
Oh, so now contrexing is some kind of rule. Sure....
Contrexing is not A rule, but it HAS a (almost) unspoken set of rules that you must follow to be successful in Contrexing.Quote
Contrexing (proper-verb=must have CAPITAL) is the act of FLAMING another user, in the way that Contrex would have.

What HAPPENED to the simple definition.Quote from: BatchFileCommand on January 24, 2009, 07:42:19 PM
Quote
Contrexing (proper-verb=must have capital) is the act of flaming another user, in the way that Contrex would have.

What happened to the simple definition.

What simple definition?Here's the simple explanation of Contrexing

Quote
Contrexing (proper-verb=must have capital) is the act of flaming another user, in the way that Contrex would have.

But after that it comes out to a process, some kind of proverb. Whatever you people call it.Quote from: BatchFileCommand on January 24, 2009, 07:52:07 PM
Here's the simple explanation of Contrexing

Quote
Contrexing (proper-verb=must have capital) is the act of flaming another user, in the way that Contrex would have.

But after that it comes out to a process, some kind of proverb. Whatever you people call it.

The definition ADVANCED because you refused to understand the previous EXPLANATIONS.
6064.

Solve : How to convert FreeDOS to MSDOS??

Answer»

I have a working installation of FreeDOS on a BOOTABLE USB flash DRIVE. I WANT to have a working installation of MSDOS on that USB drive. How would I go about switching one out for the other? Is it as simple as overwriting the FreeDOS files with MSDOS files, or do I need to modify the boot record for the USB drive?

Alternatively, how could I install MSDOS onto a non-bootable flash drive?
Thanks!
MattFreeDOS is the actual OS, or a DOS shell, like the Command prompt?


If it is an actual OS, then that would be piracy, so you should leave.FreeDos isn't an actual OS , but MSDOS is so that would be piracy!and if you owned it?Quote from: BatchFileCommand on January 24, 2009, 07:47:21 PM

FreeDos isn't an actual OS , but MSDOS is so that would be piracy!

Not sure why you bothered posting that, BFC, since FreeDOS definitely is an actual OS (1), and if you own a licensed (2) copy of MS-DOS it wouldn't be piracy. Don't they have Google on your planet?

(1)
Quote from: http://www.freedos.org/
FreeDOS is a complete, free, 100% MS-DOS compatible operating system.

(2)
Quote from: http://support.microsoft.com/kb/79747
The MS-DOS version 5.0 or later upgrades and packaged products are licensed to customers for use on one computer at a time. If you want to use MS-DOS on another computer (such as a laptop computer), you must remove or uninstall MS-DOS before it is used on the other computer. Microsoft Windows version 3.1 and later is licensed the same as MS-DOS. This also applies to network users.

Incidentally...

Quote from: http://support.microsoft.com/kb/79747
Microsoft programs are licensed differently from Microsoft operating systems. A Microsoft Word for Windows licensee who USES a particular computer 80 percent of the time can load the program onto a computer she or he uses 20 percent of the time, without purchasing another license. This applies to Microsoft products such as Microsoft Excel, Word, and Microsoft PowerPoint.


Quote from: Miriax on January 21, 2009, 11:05:24 PM
or do I need to modify the boot record for the USB drive?

You'd need to use the (MS-DOS) SYS command.

Quote
Alternatively, how could I install MSDOS onto a non-bootable flash drive?

Just copy the files onto it. But why would you want to do this? Have it non-bootable I mean. The DOS COMMANDS on it wouldn't work, and it's just as easy to make a bootable MS-DOS pen drive. Presuming you have a licensed copy of MS-DOS, there are a squillion guides on the web for this.



6065.

Solve : How to make batch file execute as a singleton??

Answer»

Hi,

I have a Talend (ETL software) job that is launched using a BAT FILE every day at 01:00 a.m. This batch should be able to be run manually. But on manual run, if it is already running, I have to display an error message to the Administrator and prevent him from running it. Typical singleton requirement.
Can someone please help me out with how to do this on DOS ?if you set the window TITLE in the batch e.g.

Code: [Select]title MyTitle
you can use tasklist with the /v (VERBOSE) switch to FIND if a window with that title is already running

Code: [Select]title NotMyTitle
tasklist /v | find "MyTitle">nul && goto skip
title MyTitle

[i]your code[/i]

goto end

:skip
echo Batch file is already running!
PAUSE
:end
exit

6066.

Solve : Getting Characters from a Bat file name.?

Answer»

I am in TNCAAK1.BAT which has the command

call AAAAAA.BAT T AK


The first arguement to AAAAAA is the same as the first char of the BAT file TNCAAK1' s name while the second argument is is the 5th &AMP; 6th character of the name.

Does anyone know how to GET those arguments from the name?

Thank you







Quote from: zscipio on January 25, 2009, 07:04:52 PM

I am in TNCAAK1.BAT which has the command
call AAAAAA.BAT T AK
The first arguement to AAAAAA is the same as the first char of the BAT file TNCAAK1' s name while the second argument is is the 5th & 6th character of the name.
Does anyone know how to get those arguments from the name?

Code: [Select]@echo off

REM %0 CONTAINS a batch file's OWN NAME
REM USE ~n variable modifier to get name part
set myname=%~n0

REM use set shortstring=%longstring:~offset,length% string slicing to get chars
REM first char is offset 0
set p1=%myname:~0,1%
set p2=%myname:~4,2%

REM demonstration
echo full name + EXTENSION is %0
echo name part only is %myname%
echo the 1st character of name %p1%
echo 5th and 6th chars of name %p2%
REM delete when satisfied

REM call other batch file
call AAAAAA.BAT %p1% %p2%
6067.

Solve : I have problem with renaming files?

Answer»

I have many files have ERROR in their names. I do not KNOW how to rename them using batch script.

For example, a file NAME is

afiABCDE.dat

I would LIKE to rename it as

afiEDCBA.dat

Note that the change is in the middle five digits.

Could you help me?http://www.computing.net/answers/programming/batch-script-to-rename-file/16798.html


Use Google You're so knowledgeable MR Google. I'm amazed....

FBQuote from: fireballs on February 02, 2009, 07:32:06 AM

You're so knowledgeable Mr Google. I'm amazed....

FB

It's not him, it's all those servers he owns...
Quote from: fireballs on February 02, 2009, 07:32:06 AM
You're so knowledgeable Mr Google. I'm amazed....

FB

Thank you, I try my best. Haha. Many thanks for you all. It is working now.Quote from: Mr. Google on February 02, 2009, 07:28:00 AM
http://www.computing.net/answers/programming/batch-script-to-rename-file/16798.html


Use Google
www.letmegooglethatforyou.com would be very usefull to you.Haha, it sure isQuote from: Helpmeh on February 05, 2009, 03:00:03 PM
Quote from: Mr. Google on February 02, 2009, 07:28:00 AM
http://www.computing.net/answers/programming/batch-script-to-rename-file/16798.html


Use Google
www.letmegooglethatforyou.com would be very usefull to you.

That's brilliant! why haven't i seen this before?!

FBExcept it doesn't work if you have script blocking enabled, like I do by default.
Well thats only you hopefully hahaSeriously: we all like a laugh, but take care lest you go over the edge and become a pr*ck.... What do you mean by that?
6068.

Solve : MS DOS Command?

Answer»

What is the DIFFERENCE between copy and format command in MS DOS?TRY Code: [Select]copy /? and Code: [Select]format /?
In short they do completely different jobs, one copied files and one 'deletes' them all.

FBIf you look up to the top-right of the page there is a SEARCH bar.
Type the terms in the search box and you'll get the answer you're LOOKING for.

6069.

Solve : Count # Times word in used in multiple word docs?

Answer»

How can I count # Times word in used in multiple word docs contained within subfolders?

For example, I want to count the how many times apples is used in word docs contained within subfolders of a main folderI came up with this so far, but it loops and does display the count

find /c "apples"*.doc C:\Documents and Settings\jbloggs\Desktop\FIND

How can I have a figure displayed?I think I may have a solution

@echo off
findstr /m "apples" *doc "C:\Documents and Settings\jbloggs\Desktop\FIND" >
Results.txt
if %errorlevel%==0 (
echo Found! logged files into Results.txt
) else (
echo No MATCHES found
)

If anyone has anything to add I would appreciate itI couldn't even get this to run. There seems to be too many parameters on the findstr command.

Code: [Select]@echo off
findstr /m "apples" *doc "C:\Documents and Settings\jbloggs\Desktop\FIND" >
Results.txt
if %errorlevel%==0 (
echo Found! logged files into Results.txt
) else (
echo No matches found
)

You mentioned Word documents which have a proprietary file organization and cannot be read by BATCH code. For that you will need a Windows script that can create a instance of the Word application and can do recursion for the sub-folders.

This will work for text documents:

Code: [Select]@echo off
for /f "tokens=*" %%i in ('dir /s /b drive:\path\*.doc') do (
find /i /c "apples" %%i >> results.txt
)

Let us know if you need a script specific for Word documents. Instead of a batch file, you may want
to do this inside of word using a script.
Look at this:
http://word.tips.net/Pages/T001833_Generating_a_Count_of_Word_Occurrences.html
Hi Sidewinder

I need a script specific for word

and to find the the specific word in word doc contained in word .docMany NT batch commands and even POWERSHELL have parameters to indicate recursion. VBScript takes a more do-it-yourself approach:

Code: [Select]wdSearch = "apple" 'Word To Search For
topLevel = "c:\documents" 'Change Directory As Required

Set fso = CreateObject("Scripting.FileSystemObject")
Set wdApp = CreateObject("Word.Application")

Set objFolder = fso.GetFolder(topLevel)
Set colFiles = objFolder.Files
For Each objFile in colFiles
Wscript.Echo objFile.Path, CountTheWord(objFile.Path)
Next

ShowSubfolders fso.GetFolder(topLevel)
wdApp.Quit

Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Set objFolder = fso.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
If UCase(fso.GetExtensionName(objFile)) = "DOC" Then
Wscript.Echo objFile.Path, CountTheWord(objFile.Path)
End If
Next
ShowSubFolders Subfolder
Next
End Sub

Function CountTheWord(objDocument)
wdCount = 0
Set wdDocument = wdApp.Documents.Open(objDocument)
Set objSelection = wdApp.Selection
objSelection.WholeStory
wdTotal = wdApp.Selection.Range.Words.Count
For ctr = 1 To wdTotal
With objSelection.Words(ctr)
If Trim(.Text) = wdSearch Then
wdCount = wdCount + 1
End If
End With
Next
wdDocument.Close
CountTheWord = wdCount
End Function

Save the script with a vbs extension an run from the command prompt as cscript //nologo scriptname.vbs > results.txt

Be sure to change the first two lines in the script to match your specs.

Good luck.

Note: Recursing the directory tree will go to the ends of the earth if necessary. Bottom line: this script will not set any speed records

6070.

Solve : Get ip and set as an input for a batch file.?

Answer»

Well i need help im trying to make a batch file that gets the ip address and sets it as an input for a friend because he doesnt have a static ip and he hates changeing the ip address daily of the application he has. i ALREADY KNOW how to get it into the app but for some reason i cant FIND out how to set the ip address as an input here is what i have already done and thats all i need because i can get the rest.

@echo off
ping.exe -n 1 -i 1 -w 1 www.microsoft.com
arp.exe -a | find "Interface"
pause

this doesnt seem like much but that is all i have for this PART off it i accually have a lot more than this
please help o and the pause was because i needed it to test ito and for some reason i can get the harder stuff but not the SIMLE lol I'm confused what is the use of this ... ?

I understand needing the IP address, but what do you need it for? What program ...

The way you word this seems fishy. Maybe i'm wrong. my friend needs it i think for a garrys mod serverheres the rest of the code and yah its a gmod server

@echo off
color 04
title ECHO SRDS PROTECTOR
set tempfile=servercheck.txt

echo What time would you like ECHO to restart your server?
echo please put in this format if pm 19:05:29.92 if am 3:26:28.02!!!
set input=
set /p input=TIME?:
cls
:run
echo ECHO is protecting srcds from crashes... You have the auto restart time set to %input%.
echo at (%time%) on (%date%) srcds has started.
start srcds.exe -console -game garrysmod +map gm_flatgrass +maxplayers 16 +hostport 27015 +tv_port 27020 +ip "%ip%"
goto time

:time
if %time% equ %input% goto restart

:serverchecker
tasklist > %tempfile%
type %tempfile% | find /i "srcds.exe"
if errorlevel 0 if not errorlevel 1 goto time

:crash
taskkill /im srcds.exe
echo SRCDS has crashed or has been closed on %date% at %time%!
echo RESTART.
goto run

:restart
echo srcds has restarted on %date% at %time%.
taskkill /im srcds.exe
goto run

6071.

Solve : Repeatedly run command in windows?

Answer»

I am looking for a WAY to repeatedly run a command where the command is run, and then the computer waits for the command to finish before running it again. (That is, SOMETHING similar to the "while true; do ... ; done" in linux.) I have tried creating a batch file like this:
Code: [Select]:A
command
@ GOTO A
But when I tried that it wouldn't wait for the first issuance of the command to finish before it ran the command again.

I'm hoping for an easy way to do this, but maybe there isn't one in windows.Try looking at START /? at the command prompt. The /wait part you may be interested in. Nope, putting START /WAIT in there doesn't work? do you have any other IDEAS?What command are you trying to execute? What is the full syntax?Code: [Select]@echo off

set /a c=0
:here
echo Sleep 3 seconds and repeat
echo when COUNT is 10 quit
echo count = %c%
C:\batextra\sleep.exe 3

set /a c+=1

if %c% EQU 10 exit /b

goto here
Output:

C:\>reploop.bat
Sleep 3 seconds and repeat
when count is 10 quit
count = 0
Sleep 3 seconds and repeat
when count is 10 quit
count = 1
Sleep 3 seconds and repeat
when count is 10 quit
count = 2
Sleep 3 seconds and repeat
when count is 10 quit
count = 3
Sleep 3 seconds and repeat
when count is 10 quit
count = 4
Sleep 3 seconds and repeat
when count is 10 quit
count = 5
Sleep 3 seconds and repeat
when count is 10 quit
count = 6
Sleep 3 seconds and repeat
when count is 10 quit
count = 7
Sleep 3 seconds and repeat
when count is 10 quit
count = 8
Sleep 3 seconds and repeat
when count is 10 quit
count = 9

C:\>

6072.

Solve : go back in BAT?

Answer»

I am not sure how to search for this because i don't seem to get what i am looking for.

Let's say you run a BAT file in "FolderA\FolderB\FolderC\". In the BAT file i was to have it run a file in "FolderA". The issue is the drive letter can change or be a UNC path. Is there a way to specify "FolderA" without having a static drive letter?

Thanks for the help!I don't know if there is a way to do it. The way I have done it in the past is to first; think how many drive letters are possible, then make a line in the program for that letter.

Hope you can alter this to your needs.

Code: [Select]rem check whether file 'F:\FolderA\file' exist
If exist F:\FolderA\file goto goodf
If not exist F:\FolderA\file goto checkg

:checkg
rem check whether file 'G:\FolderA\file' exist
If exist G:\FolderA\file goto goodg
If not exist G:\FolderA\file goto checkh

:checkh
rem check whether file 'H:\FolderA\file' exist
If exist H:\FolderA\file goto goodh
If not exist H:\FolderA\file goto checke

:checke
rem check whether file 'E:\FolderA\file' exist
If exist E:\FolderA\file goto goode
If not exist E:\FolderA\file goto fail

:goodF
start F:\FolderA\file
goto END

:goodg
start G:\FolderA\file
goto end

:goodh
start H:\FolderA\file
goto end

:goode
start E:\FolderA\file
goto end

:fail
echo fail

:end

Someone will probably tell you a better way to do this but until then I hope this helps.

EDIT: This was made for a flashdrive. That is why the first drive letter F.do you mean that the batch file might be on a different drive?

Quote

do you mean that the batch file might be on a different drive?
Is that directed at my? If so then it could be but the program dose many things and the file that it runs is on the same drive so that you can transport it to any computer and still fined and run the program. It is based of the fact that when moving a flash drive from one pc to another it will have a different drive letter.C:\>type drive.bat
Code: [Select]@echo off

REM Use command line argument
REM drive.bat E



%1:
start %1:\FolderA\file
Output:

C:\> drive.bat E

E:\>HUH?
Is the objective to make this harder that it needs to be?
You can always execute a batch file in another directory on the same drive.
You can reference another file in another directory, even if the directory is not down in the current tree.
Example:
..\folder\file.txt
is a sideways reference to a file in a sister folder.
\folder\folder\file.txt
Is a reference from the root without SAYING which drive.
(It has to be the current dive.)
.\file.txt
means this folder.
Somewhere this is documented!

Quote from: Geek-9pm on September 24, 2009, 01:42:08 PM

Somewhere this is documented!



Wikipedia article title "Full stop"...

Quote
In Unix-like systems and Microsoft Windows, the dot character represents the working directory of the file system. TWO dots (..) represent the parent directory of the working directory.

Wikipedia article title "Path (computing)".

Quote
Two dots ("..") point upwards in the hierarchy, to indicate the parent directory; one dot (".") represents the current directory itself. Both can be components of a complex relative path

cd help

Code: [Select]C:\>cd /?
Displays the name of or CHANGES the current directory.

CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]
MSDN page titled "File Names, Paths, and Namespaces"

http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx


I like to keep my projects very organized and not have duplicate files. So this is a pretty big piece to have working. In this small project i simply needed to run "sleep.exe". It worked perfectly.

Thank you all for the input!

Code: [Select]"..\exes\sleep.exe" 3

-HoFLQuote from: TheHoFL on September 24, 2009, 04:01:16 PM
I like to keep my projects very organized and not have duplicate files. So this is a pretty big piece to have working. In this small project i simply needed to run "sleep.exe". It worked perfectly.


Code: [Select]"..\exes\sleep.exe" 3

HoFL,

I have no idea what you are talking about. Sleep.exe?

.. represents the current directory, up one. So "..\folder\name.bat" goes up one level, then looks in there for "folder" then GETS name.bat .Sleep.exe is a simply program that allows you to "pause" for a specified amount of seconds. It's like pause, but you don't have to hit a key to continue. It just starts after the amount if time specified. There is a sleep.com in this place:
http://dslgeek.com/dos/there watch my video on youtube --> http://www.youtube.com/watch?v=mqhemoOVfuU
than you know the code
6073.

Solve : How do I incoporate a RUN command in Batch file??

Answer»

I have a menu in batch FILE which I created but I'm stuck on how to launch the run command (Window's shortcut). In the RUN command the text field is automatically entered (from the batch file) then launch the application or whatever (i.e. msconfig, cmd, or notepad, etc). I using XP version.

I saw someone did this a long long time ago.

Any comments or advice would be greatly appreaciated.

thanksAre you SAYING... If some one types a sertant thing that you want a certant thing to start?

If you are I can help...
(Example)
@ECHO off
title Menu
echo 1.)Notepad
echo 2.)Command Prompt
echo 3.)Internet explorer
set /p Pick=
if "%Pick%"=="1" start notepad.exe
if "%Pick%"=="2" start cmd.exe
if "%Pick%"=="3" start Iexplore "google.com"You're either looking for start like Hibby says. Look throught help file Code: [Select]start /?

or as long as you give the path you can just enter the file name:
Quote

c:\users\public\life.exe

(you can enter just the file name for some things, if you're in the directory with the executable in it, or if the executable is in the path environment variable ex. notepad.exe)

FBI think he wants to literally show the run dialog.

try this command, if that is the case:


Code: [Select]rundll32.exe shell32.dll,#61
Quote from: BC_Programmer on January 25, 2009, 09:41:33 AM
I think he wants to literally show the run dialog.

And, judging by this....

Quote
I'm stuck on how to launch the run command (Window's shortcut). In the RUN command the text field is automatically entered (from the batch file) then launch the application or whatever

.... following that, automagically type in a command and click OK, which is a long winded way of starting an executable from a batch file. Maybe the OP does not realise that you don't need to do that?
I think he means he wants to start the program from run. You know, the thing where you can type in a program name and it starts that program. So if you're going to start it from run you would have to have the extension with it. Like this:

batchfile.bat/exeQuote from: BatchFileCommand on January 25, 2009, 01:21:26 PM
I think he means he wants to start the program from run. You know, the thing where you can type in a program name and it starts that program. So if you're going to start it from run you would have to have the extension with it. Like this:

batchfile.bat/exe

Not quite sure what you're trying to say there, old boy.
I have what I NEEDED. Thank you.Quote from: locbtran on January 25, 2009, 01:46:59 PM
I have what I needed. Thank you.

And what was it?
6074.

Solve : xcopy certain dates or certain folders help.?

Answer»

Hi I'm pretty new to batch files so here goes,
I'm looking to xcopy certain log files but exclude others from being copied,
for eg the log files are named by date 200909026 through to 200400101. so i want to xcopy only from 20040101 to 20090901 and leave the rest.
Could some one point me to the correct syntax please.
Thanksyou.

@echo off
Set mindate=20040101
Set maxdate=20090901
For /F "tokens=1,2 delims=." %%a in ('dir /b *.log') do if not "%%a" LSS "%mindate%" if not "%%a" gtr "%maxdate%" copy %%a.%%b TARGETLOCATION

That should do it. It's not tested though. Thank for your response helpmeh,
could you explanin some of the syntax pls so i have a better understanding in the futureI have another question i wrote this simple batch file:

start /d "C:\program Files\test" packer.exe

start /wait/b XCOPY "C:\program files\Archived Logs" "D:\Archived logs" /E /V /C /I /Q /H /K /O /X /Y

basically whats mean to happen is packer.exe program zipps up a log file then creates a folder called and C:\program files\Archived Logs and inserts it in there which works ok but then when this is finished i want to copy the latest zipped file from the archived folder to D:\Archived logs , the xcopy part is not working. But does work if i run the batch file twice,i think the batch file needs to wait until packer.exe completes ,
What am i doing wrong ?
Thanks

sorry should be

tart /d "C:\program Files\test" packer.exe

start /wait/b XCOPY "C:\program files\Archived Logs\"*" "D:\Archived logs" /E /V /C /I /Q /H /K /O /X /Y

Still working though ,
Quote from: jamster69 on September 27, 2009, 10:12:55 AM

Thank for your response helpmeh,
could you explanin some of the syntax pls so i have a better understanding in the future
Well, the set command should be fairly obvious to you. But here's how the for loop works.

for /f
The command with the /f switch. See FOR /? for more information on other switches.

"tokens=1,2
Part one of the options. Specifies that the first 2 tokens are used. By default is 1.

delims=."
Part 2 of the options. It tells the command where to divide the output (see later) by for each token. Must be used last. By default is a space and/or a tab.

%%a
Specifies the first for variable (or the only one in some cases).

in
(self-explanitory)

('dir /b *.log')
Collects the output from that command (see DIR /? for more INFO on that command).

do
(self-explanitory)

If not "%%a" LSS "%mindate%"
If the value of %%a is not less than the value of %mindate% do:

If not "%%a" gtr "%maxdate%"
If the value of %%a is not greater than the value of %maxdate% do:

Copy %%a.%%b TARGETLOCATION
Copy the value of %%a.%%b (which is the file's name .log ex 20090801.log) to the target LOCATION (TARGETLOCATION), which you had to specify.

If you need any more help, feel FREE to ask.
6075.

Solve : Set Wallpaper.?

Answer»

How can I set an image as my wallpaper using a batch?Directly? I doubt it. There is a .cpl file and there may be a place to find the required syntax. Quote from: Boozu on SEPTEMBER 24, 2009, 04:05:45 PM

How can I set an image as my wallpaper using a batch?
If this is for your own amusement you can do this:
1. ind a web site with a nice image and set it as you wallpaper
2. Look for it in the folder c:\windows\web\wallpaper\
3. if you overwrite that image it will become the new wallpaper when the system is reset.
I never knew that! Lol, nice TRICK!I have a more efficient way involving the registry. I will post tomorrow.Why would someone use the registry just to change their wallpaper. They would probably do something they're not SUPPOSED to and screw their computer. It is meant as a joke but not to Quote
screw their computer.
Quote from: Boozu on September 25, 2009, 05:06:37 AM
It is meant as a joke but not to
I meant doing stuff in the registry can be potentially bad. I deleted some registry keys, but it was to see all the extensions. Code: [Select]@echo off
REM Configure Wallpaper
Echo Registry: Wallpaper (1 of 3)
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "%SystemRoot%\energybliss.bmp"
Echo Registry: WallpaperStyle (2 of 3)
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 0
Echo Registry: TileWallPaper (3 of 3)
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 2

REM Make the changes effective immediately
Echo Updating system
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

Centred Tiled Stretched
WallpaperStyle 0 0 2
TileWallpaper 0 1 0


If you change the PATH/filename of the bmp to "%1" you can then put the script into your Send To folder & thereafter right click on a bmp and set it as your wallpaper. You could have 3 different scripts called stretch, tile, and centre -wallpaper.bat maybe?
Quote from: Helpmeh on September 25, 2009, 03:14:50 PM
I meant doing stuff in the registry can be potentially bad. I deleted some registry keys, but it was to see all the extensions.

you have no idea what your talking about.


if it's done through a batch command it's not going to "mutate" and suddenly change a totally different key.Doing stuff with a kitchen knife can be "potentially bad", if that includes plunging it into your mother-in-law, and carelessness can result in bleeding fingers, but that does not make the practice of cookery a bad thing.

exactly, same thing with gophers... they make great garden tools if you staple them to a stick, but they make crummy eating utensils. But that doesn't make them.... hey WAIT a second what was my point?





anyway, the value:

HKEY_CURRENT_USER\Control Panel\Desktop\WallPaper

contains the full path to the desktop wallpaper.
6076.

Solve : XCOPY ---- Progress Display ... ??

Answer» Input:
Code: [Select]<nul

Output:
Code: [Select]>nul

Quote
Ok ... now that I've said this I will read the code and let you know what I think.

I gotta talk to Nathan about that raise.

PS. The code will not work if you insist on using XCOPY. You're not using any switches that are unique to XCOPY, so COPY is actually a better choice.
Quote from: Sidewinder on January 23, 2009, 03:48:28 PM

PS. The code will not work if you insist on using XCOPY. You're not using any switches that are unique to XCOPY, so COPY is actually a better choice.


Didn't think copy worked correctly over network drives? Maybe it would work by using Pushd, this is a new command I found, from what i have read creates a temporary drive until you popd it off ... Completed product with COPY for now ... going to play with xcopy later ... Why do you say xcopy won't work? Thank you very much for all your effort put forth into this, a raise would be a wonderful thing.

Code: [Select] @echo off
set wkdir=%cd%\workdir
set dest=%cd%\dest

set perc=0

setlocal enabledelayedexpansion

if not exist "%wkdir%" md "%wkdir%"

pushd %wkdir%

:: Get Number of Files in Dir

for /f "tokens=1*" %%i in ('dir /a:-d ^| find /i "file(s)"') do set count=%%i

set storcount=%count%


Title 0%% Done

echo Start Copy Operation
Echo.
Echo The numbers printed to screen represent the number of files left to copy
Echo.
:: Copy Files; Show Progress

For /f "delims=" %%a in ('dir /b /a:-d /o:-d') do (

<nul call set/p z= !count!
copy "%wkdir%\%%a" "%dest%\%%a" > nul
rem >nul ping localhost -n 2

set /a count-=1


set /a perc+=1


set /a p=(!perc!*100^)/%storcount% >>log.log


title !p!%% Done
)

popd
echo.
echo End Copy Operation & pause >nulQuote
Why do you say xcopy won't work?

I may have misspoke. There goes my raise! You're only feeding one file at a time to XCOPY so I'm guessing COPY and XCOPY will work same.

Quote
Didn't think copy worked correctly over network drives?

Where did you here this? I've never had any problems with copy over a network using either UNC notation or mapping the drive. My only experience with PUSHD and the flipside POPD as been to put directory names on the stack for future retrieval. Learn something new everyday. Sidewinder, I was hoping I could pick your brain one more time. I added some code and seem to have broken what I had, thought I found my mistake, but the batch file is still crashing. Here is the code ....


Part of what I added ... I like the output to the screen, but as I get to double/single digits the display starts to look look off. I wanted to count the number of CHAR in the Count VAR to determine if it was 1, 2, or 3 char long then output accordingly by adding a leading zero to the number when it outputted to the console.


I used this code before to do a count, but never in a For loop ... maybe that is my problem. I found a couple mistakes so maybe there is something I am missing. Thanks again for your help. At this rate I might have to pay your raise.

Code: [Select] :LOOP_0
IF "!counter!"=="" GOTO :RESULT
SET /a strgCount+=1
SET counter=%counter:~1%
GOTO :LOOP_0

:RESULT
The whole thing

Code: [Select]ECHO on
set wkdir=%cd%\workdir
set dest=%cd%\dest

set perc=0
set counter=0
SET strgCount=0

setlocal enabledelayedexpansion

if not exist "%wkdir%" md "%wkdir%"



Rem Get Number of Files in Dir

pushd %wkdir%
for /f "tokens=1*" %%i in ('dir /a:-d ^| find /i "file(s)"') do set count=%%i

Rem Store number of files for Percentage completion tracking
set storcount=%count%
Title 0%% Done

ECHO Start Copy Operation
ECHO.
ECHO The numbers printed to screen represent the number of files left to copy
ECHO.

REM Copy Files Show Progress


For /f "delims=" %%a in ('dir /b /a:-d /o:-d') do (

set counter=!count!
SET strgCount=0

:LOOP_0
IF "!counter!"=="" GOTO :RESULT
SET /a strgCount+=1
SET counter=%counter:~1%
GOTO :LOOP_0

:RESULT


if "!strgcount!"=="3" Goto pass1
Goto check1
:pass1
<nul call set/p z= !count! & goto copypro
:Check1
if "!strgcount!"=="2" Goto pass2
Goto check2
:pass2
<nul call set/p z= 0!count! & goto copypro
:Check2
if "!strgcount!"=="1" Goto pass3
Goto check3
:pass3
<nul call set/p z= 00!count! & goto copypro

:Check3
:copypro
copy "%wkdir%\%%a" "%dest%\%%a" > nul

set /a count-=1
set /a perc+=1

Rem Changes title to ^%Percentage
set /a p=(!perc!*100^)/%storcount%

title !p!%% Done
)

popd

ECHO.
ECHO End Copy Operation & pause >nulQuote
At this rate I might have to pay your raise.

You can't afford me. Either can Nathan, but I haven't told him yet.

Quote
Part of what I added ... I like the output to the screen, but as I get to double/single digits the display starts to look look off. I wanted to count the number of CHAR in the Count VAR to determine if it was 1, 2, or 3 char long then output accordingly by adding a leading zero to the number when it outputted to the console

What happens if the last count on the line wraps to the NEXT line?

This is some generic code I found. Works for three digits. I'll let you incorporate it into your code.

Code: [Select]@echo off
setlocal
:loop
call set chr=%%count:~%len%, 8192%%
if "%chr%"=="" goto exit
set /a len+=1
goto loop

:exit
if %len% EQU 1 set count=00%count%
if %len% EQU 2 set count=0%count%
echo %count%

Good luck.

You can remove the setlocal statement. I used it for testing purposes. The 8192 is the max size of the environment on a XP machine. You can reduce this in keeping with your needs. Five would be a good choice for future expansion.Question ... does doing a loop without the call procedure throw yourself out of the normal for loop operation ... is that what I was doing wrong? This is pretty good.

Just a thought - How can this be made to work for recursive copying. What if wkdir has subdirectories in it?

I am sorry to put in a question of my own within this conversation. If you want me to open a new topic, would be glad to do that too. However I thought since this is an active topic, I will just post my question here.

Notice I didn't try to incorporate the snippet into your code. I was afraid the whole thing would fall apart.

Why not USE the call instruction to transfer control to an internal subroutine? You can format the count immediately prior to writing on the console?

Quote
Question ... does doing a loop without the call procedure throw yourself out of the normal for loop operation

I think the fact of a :label within the for loop is creating unpredictable results. I'm not certain how the interpreter keeps track of the return addresses.

How did a seemingly simple copy operation turn into such a Rube Goldberg contraption? Batch code is NOT a programming language.



If the KISS recruiter needs applicants, he should LURK in the DOS alley.

@hiteshsavla
Quote
Just a thought - How can this be made to work for recursive copying. What if wkdir has subdirectories in it?
If this refers to your other post, don't even think it. Quote from: Sidewinder on January 26, 2009, 03:12:29 PM
Notice I didn't try to incorporate the snippet into your code. I was afraid the whole thing would fall apart.

Your right, it fell apart ... I guess I have never run into trying to do something in a FOR loop before. ... I guess I confused how to continue then. I guess the whole effort is just make the display on the screen more in line, as the numbers get small they start to get out of line and I no longer have pretty columns ... Love the bit of code Code: [Select]<nul call set /p z= !count! much better then echo

My problem is by calling a routine I end up getting it to work again, but get a message that echos 'The system cannot find the batch label specified -'

This bit of code was purely to make the display nicer ...
Code: [Select] if %len% EQU 1 set count=00%count%
if %len% EQU 2 set count=0%count%
Quote


How did a seemingly simple copy operation turn into such a Rube Goldberg contraption? Batch code is NOT a programming language.


Your right it isn't a batch language, but i'm amazed everyday I learn something new that it can do , thanks for all your help.
6077.

Solve : Batch file to copy only files that do not exist OR answer no to overwrite?

Answer»

Hi,

I have two directories: source and destination. Is there a way I can copy only new files that EXIST in Source, but not in the destination? Basically to MIRROR them up.

OR, is there a way I can have the batch file answer NO when asked to overwrite? I'm thinking just write a basic copy C:\source C:\destination and answer NO when asked to overwrite each file. I can use the /y OPTION but that just overwrites ANYWAY. LOOKING for a way to skip the overwrite.

Thanks!

B

6078.

Solve : rename a file from a table??

Answer»

I have a file that gets output every week. I want to append the week number to the END of the file, but it's not the calendar week number using the system clock settings, it would be the retail calendar week.

Can I set up a table of some sort to look so that I can use the name of the week I need? Quote

it would be the retail calendar week.

Do you mean the 4-5-4 Merchandising Calendar? If so, on what day of the week will the file be output?

We are using the 4-4-5 merchandising calendar. In most cases, the file will be output on TUESDAY each week, but it could be Wednesday sometimes. It was be triggered by a user to start the process, but I was trying to avoid them having to rename the file after it was generated. Let me know if you could help! Thanks much.Just to clarify what you want:

Quote from: luvsun27
I want to append the week number to the end of the file
Do you mean that you want to append the week number as the last record (line) of the file or that you want to append the week number to the filename?

Quote from: luvsun27
Can I set up a table of some sort to look so that I can use the name of the week
What do you mean by "name of the week"? You already said you want to use the week number. Do you want to give each week a unique name?

Quote from: luvsun27
It was be triggered by a user to start the process, but I was trying to avoid them having to rename the file after it was generated
Again you mention renaming the file which is somewhat different to appending the week number to the end of the file.

Sorry about my confusion.Let me clarify...the name that is output for the file each week is called sales_file_output. I want to save a copy of this file with the week number, so sales_file_output_week1, sales_file_output_week2, etc,etc. Just the name of the file NEEDS to change, not the contents of the file. The file sale_file_output is being loaded into another system, but I want to keep a copy of the file for reference in a backup folder. Thanks again for trying to help!It might be possible to set arrays to suit your purpose but the number of arrays is considerable. Each year, month (Merchandising calendar) and week would need its own array and separate coding to return the week number, then the six week month would also have to be considered in the long term (next six-week-month is in 2012{?}). Also the week number OCCURS in each year (Week1 would show in 2009 and 2010 etc) so renaming files would fail due to DUPLICATION unless the script is changed.

As an easy alternative I suggest that you append the date of writing of the file to the filename, it would then be fairly simple to look up a hard copy of the Merchandising Calendar to determine in which week that date falls. Filenames would show as sales_file_output_20090127 etc.

Thank you very much for your help...I think I will do just that, put the date at the end of the filename. Thanks agan.
6079.

Solve : MS-DOS trouble with changing to different drive...?

Answer»

Running: Vista 64-bit

ok, i just made a bootable msdos floppy disk using the format way, and clicking the box, and formatting it and whatnot. typical stuff. Sadly, this is where it goes horribly wrong. I set it to boot before my hard drive, so it goes: Floppy, Hard Drive, Removable disk, Network.

so i boot what im retty sure is DOS, and i get the command prompt that normally pops up.
I try and change the drive from A: to C: but it wont LET me. any solutions?

these are all the combinations ive tried so far to no AVAIL, and yes, i know half wont do much of anything:

cd..
cd C:
cd C:/
cd C:\
cd
cd A: (hehe, this worked :p)

and i think thats all ive done so far..

anyways, anybody know whats up?C: and hit Enter.VISTA 64-Bit .... Your trying to get to a NTFS C: drive that is not accessible through DOS....You cant see C: from DOS unfortunately unless your C: drive is FAT32 any IDEA how i CAN.im looking at a program call NTFSDOS, which looks like it might work, but alas, being the pathetic noob i am T.T i dont EXACTLY know what to do to get it working.

any help out there that could give simple and concise instructions on what to do?

6080.

Solve : how to switch my drive in command?

Answer»

need to SWITCH my c:\ to my d:\ for this checkup IM curious bout (my D:\ is my recovory)you want to change the drive letter or just change the working directory? to change working directory it's just Code: [Select]D:
FBi got into the d drive (witch is my recovory drive) but i can only get into the recovery dir and after i typer dir i see the . and .. nothing else is there a way i can get into my full recovory drive and see the full system?or is there a BATCH file that (i can make one if you give the definition) i can use to get into my recovery system

(i need to check my recovery because i need to check if the viruses got into my d: drive)How do you know the drive isn't EMPTY? I don't know much about the Windows recovery partition, you might want to ask in the windows section. But You should know that CMD a way around windows, if there are files that windows doesn't want you to see then CMD won't LET you either.

FBdamit

will full dos let me?

6081.

Solve : XP: how to have one batch file create another with FOR Variables?

Answer»

I WANT to have a batch file create a series of batch files , each of which use a variable.
the final output should read:

for %%V in (*.vnc) do fixit %%V

I tried a batch file
CODE: [Select]for /L %%Q in (0,1,3) do echo for %%V in (*%%Q.vnc) do fixit %%V > %%Q_Fix.batand
Code: [Select]for /L %%Q in (0,1,3) do echo for ^%%V in (*%%Q.vnc) do fixit ^%%V > %%Q_Fix.bat
but they didn't work, as the resulting batch files (ie: 3_fix.bat) came out:

for %V in (*3.vnc) do fixit %V

How can I 'protect' the double percentage sign in the echo output to the file?
(Preview did not work in my browser, so sorry if this didn't come out formatted correctly)
Quote from: crp on January 26, 2009, 02:01:00 PM

the final output should read:

for %%V in (*.vnc) do fixit %%V

Then why is the %%Q present here?

for /L %%Q in (0,1,3) do echo for %%V in (*%%Q.vnc) do fixit %%V > %%Q_Fix.bat

Quote
How can I 'protect' the double percentage sign in the echo output to the file?

The escape char for a percent sign is... a percent sign. That is, to echo one percent sign from a batch, you use two in the code.

Code: [Select]@echo off

for /L %%Q in (0,1,3) do echo for %%%%V in (*%%Q.vnc) do fixit %%%%V > %%Q_Fix.bat

for /L %%Q in (0,1,3) do (
echo %%Q_Fix.bat:
echo.
type %%Q_Fix.bat
echo.
)


Code: [Select]0_Fix.bat:

for %%V in (*0.vnc) do fixit %%V

1_Fix.bat:

for %%V in (*1.vnc) do fixit %%V

2_Fix.bat:

for %%V in (*2.vnc) do fixit %%V

3_Fix.bat:

for %%V in (*3.vnc) do fixit %%VQuote from: Dias de verano on January 26, 2009, 03:45:06 PM
Quote from: crp on January 26, 2009, 02:01:00 PM
the final output should read:

for %%V in (*.vnc) do fixit %%V

Then why is the %%Q present here?

for /L %%Q in (0,1,3) do echo for %%V in (*%%Q.vnc) do fixit %%V > %%Q_Fix.bat
I do not UNDERSTAND the question.

Quote
Quote
How can I 'protect' the double percentage sign in the echo output to the file?

The escape char for a percent sign is... a percent sign. That is, to echo one percent sign from a batch, you use two in the code.

yes Code: [Select]for /L %%Q in (0,1,3) do echo for %%%%V in (*%%Q.vnc) do fixit %%%%V > %%Q_Fix.bat worked perfectly, as wanted.

Where is that NUGGET of information about the ESCape character for '%' being '%' ?
I searched quite a few places for 'dos percentage escape'
THANK YOU! Quote from: crp on January 26, 2009, 04:14:40 PM
Quote from: Dias de verano on January 26, 2009, 03:45:06 PM
Quote from: crp on January 26, 2009, 02:01:00 PM
the final output should read:

for %%V in (*.vnc) do fixit %%V

Then why is the %%Q present here?

for /L %%Q in (0,1,3) do echo for %%V in (*%%Q.vnc) do fixit %%V > %%Q_Fix.bat
I do not understand the question.

You stated that the output should be:

for %%V in (*.vnc) do fixit %%V

(There is no number between the asterisk and 'vnc')

Yet in your code you show

echo for %%V in (*%%Q.vnc)

Which means you want to see *0.vnc, *1.vnc, *3.vnc. Which is different.

That's all.

Quote
Where is that nugget of information about the ESCape character for '%' being '%' ?
I searched quite a few places for 'dos percentage escape'
THANK YOU!

Well, perhaps if you tried "percent sign" you would have found something, and we're not in DOS land...

Here for example

http://www.google.com/search?source=ig&hl=en&rlz=&=&q=escape+percent+sign&btnG=Google+Search&meta=lr%3D

the 2nd result leads to

http://www.robvanderwoude.com/escapechars.html

6082.

Solve : Browser options form DOS??

Answer»

Browser options form DOS?
How do you make a browser, like IE6, do thins from the COMMAND line.?
Like set a bookmark. Or set wallpaper. Or run minimized. Annd then quit.
So far I this:
Code: [SELECT]start "C:\Program Files\Internet Explorer\iexplore.exe\ " http://help9pm.com/jpg/red-nose0002.JPG
How can I get it to set the image as wallpaper? and Exit?
Any COMMENTS welcome. Just don't say anything bad about my grand baby.Quote from: Geek-9pm on September 25, 2009, 03:55:07 PM

Browser options form DOS?
How do you make a browser, like IE6, do thins from the command line.?
Like set a bookmark. Or set wallpaper. Or run minimized. Annd then quit.
So far I this:
Code: [Select]start "C:\Program Files\Internet Explorer\iexplore.exe\ " http://help9pm.com/jpg/red-nose0002.JPG
How can I get it to set the image as wallpaper? and Exit?
Any comments welcome. Just don't say anything bad about my grand baby.

Not sure, if there's a way to get IE to do this automatically.

Another way, might be to use a program to download the file... and then simply get that set as a background (probably possible via REG commands)Quote
Another way, might be to use a program to download the file... and then simply get that set as a background (probably possible via REG commands)
I was hoping a small BATCH file would do it. I want to send it as an e-mai attachment to my family and friends.
I don't think they will go for a REG edit script!
Quote from: Geek-9pm on September 25, 2009, 10:13:02 PM
I was hoping a small batch file would do it. I want to send it as an e-mai attachment to my family and friends.
I don't think they will go for a REG edit script!


well, the "REG" command can be used, is what I mean- would be unnoticable.

But, I'm not sure if the background would change right away or after the next REBOOT... or semi-randomly when another program decides to broadcast a "system change" message...I'm confused. Are we talking about background of a program or the wallpaper. Desktop background, which is also called wallpaper

Why not follow your own advice you gave to another member in the "Set Wallpaper." thread. (still on the first page in the MS-DOS section.
6083.

Solve : Area of Adventure release [local] [beta]?

Answer»

i know its impossible but it would SEEM quite lousy if there were able to put Halo 3 on Nintendo 64(choppy graphics, HORRIBLE details)Does anyone still have a COPY of this? The download link is broken and I could really learn from this...or I did before I deleted it.Not SURE, Jacob has been GONE for a while...Last active on the 6th this month. Oh, well still not an update on it for a while.I'd suggest sending him a PM and waiting for a response...
But that's just me.

6084.

Solve : Backing Up Program using DOS 6.22?

Answer»

I have a program called Mpddd on C: that I WOULD like to Backup to FLOPPIES on A: The program requires 8 FORMATTED Floppies (so a simple COPY Command will not work).

When I used Dos 5.0 I would type Backup C:\Mpddd A: at the C: prompt to backup the program and it would worked WELL. The backup process would stop when each Floppy became full and another Floppy was inserted. This Command will not work with Dos 6.22. Is it possible to Backup Programs with Dos 6.22? What is the Dos 6.22 Backup Command to Backup program Mpddd to Floppies on A:MS-DOS 6.22 Backup is on the Supplemental Disk

http://download.microsoft.com/download/win31/update/1/dos/en-us/sup622.exeThanx for that Salmon....useful indeed !

6085.

Solve : Is it possible to remove the colon from the drive letter?

Answer»

Here's the code that I am working with:

REM @echo off
setlocal enable delayedexpansion
for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "Removeable"') do (
echo %%i:
if %%i LSS E (
echo SORRY, no USB Flash Drive AVAILABLE.
pause
EXIT
)
)
echo %%i:
echo All is well.

:FINALEND

I'm going a little nuts over this, as I think it should be fairly simple, but DOS is so picky. LOL Thanks in advance. If it isn't possible to remove the colon, then it's time to finagle another angle to make it work. Use

Prompt $P$H$H

You will then see only the drive Letter as for the first $H will remove the \ and the second $H will remove the : ( colon )..... The $H is a BACKSPACE to delete the characters at the tail end of the default $P prompt of C:\ giving you C
Does this help when you see just the drive letter?

To set it back to C:\> simply add PROMPT $P$G at the end of the BATCH to set back to C:\>
Dave, I think you misunderstand the question.
Diskpart doesn't come back with a colon with the drive letter. Though for what you're doing this might be more efficient:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f "tokens=3" %%i in ('echo list volume ^| diskpart ^| find /i "Removeable"') do (
echo USB disks are:
if defined %%i echo %%i
goto here)
echo no USBs
:here
pause
exit
FBFB - That's exactly what I was looking for. I was going the long way and you did it the short and simple way. Thanks.
Thanks to all who posted!

6086.

Solve : Can you submit data in web forms using a batch file??

Answer»

Hello,

Every day when I boot up my computer I have to go into one of our intranet pages and input some stuff. It's getting a bit TEDIOUS. I was wondering if it's possible to automate the process using a batch file that runs on STARTUP. Anyone know how I might go about this or whether it's even possible?

Thanks!You cannot do this with a Batch File. Sorry.It's not directly posible with batch but if you have a logon script you could append code that would open a program to do it for you, something like VB or even Firefox/IE. Though that question would BELONG in the programming section.

FBI only answer the question. You folks can go into more detail.

Quote from: Carbon Dudeoxide on January 28, 2009, 07:06:08 AM

You cannot do this with a Batch File. Sorry.
Thanks for the reply, and sorry, I didn't realise I'd posted in the wrong forum. Is there another way I might be ABLE to do this or am I stuck with the manual ROUTE?
6087.

Solve : Write batch that run application and i need to resize the window?

Answer»

Hi ,

I want to Write batch that RUN one application 4 times (the same application) ,
in DIFFERENT place on the display, one application to the RIGHT up, one to the LEFT up, and one right below,and the last one to left below,
I don't know if i can resize the WINDOW of the application from the batch file ?

6088.

Solve : copy a file from source location to backup location with folder named %date%?

Answer»

Ran into a subdirectory issue with the \ in the %date% when executing

MD "%date%_backup"

Is there a way to substitute the \ with - or _ to be supported as a continuos DIRECTORY name instead of it chopping into subdirectories for 26th day and 2009 year

C:\test123\Mon 01\26\2009_backup

Probably simple, but I'm stumped.

ThanksUse the SET string=%string:a=b% replacement method (replace all 'a's with 'b's)

or set string=%string:a=% (replace all 'a's with nothing, i.e. delete all the 'a's)

US %date% format is

Day mm/dd/yyyy e.g. Tue 01/27/2009 I think?

So

set Mydate=%date:/=-%
set Mydate=%Mydate: =-%

MAKES %Mydate% equal to

Tue-01-27-2009

proof

Code: [Select]Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>set mydate=Tue 27/1/2009

C:\>set Mydate=%Mydate:/=-%

C:\>set Mydate=%Mydate: =-%

C:\>echo %Mydate%
Tue-27-1-2009


Hey DIAS de verano ... Thanks for that solution...

6089.

Solve : unable to set a variable in a For loop?

Answer»

Hi, I am unable to set a varaible in a FOR LOOP.
I know this has something to do with SETLOCAL ENABLEDELAYEDEXPANSION
Here is the code:

Code: [Select]@ECHO OFF
cls
SETLOCAL ENABLEDELAYEDEXPANSION

for /f "tokens=1 delims=" %%S in (filename.txt) do (

echo EXECUTING FILE %%S
set file=%%S
echo file is : !file!
set syntaxterror=0
echo syntaxerror is: %syntaxerror%

type "output.txt" | find /i "Msg" && set syntaxerror=1
echo syntaxerror is: %syntaxerror%
REM if %syntaxerror% EQU 1 CALL :end !file!

)

echo "All Files executed successfully"
PAUSE

ENDLOCAL
exit

:end

echo "There was error executing the file: %1
pause
ENDLOCAL
exit

For now just assume filename.txt has a few lines of code and I execute them one by one.
Also the contents of output.txt could be something like this:
Msg 102, Level 15, State 1:

However what my REAL problem is, I am unable to set the variable syntaxerror

Is there something I am doing wrong?Aneways I found the solution myself. Redirected to a new loop outside the For loop and it worked.

I am POSTING the code, It might help someone else.

Code: [Select]@ECHO OFF
cls
SETLOCAL ENABLEDELAYEDEXPANSION

for /f "tokens=1 delims=" %%S in (sqlfile.txt) do (

echo EXECUTING FILE %%S
set file=%%S
echo file is : !file!
set syntaxterror=0
echo syntaxerror is: %syntaxerror%
CALL :loop !file!

)

echo "All Files executed successfully"
pause
ENDLOCAL
exit


:end

echo "There was error executing the file: %1
pause
ENDLOCAL
exit


:loop
set syntaxerror=0
type "output.txt" | find /i "Msg" && set syntaxerror=1
echo syntaxerror is: %syntaxerror%
if %syntaxerror% EQU 1 CALL :end %1
Still could someone tell me why can't I set a variable in a For loop?

Many thanks!!wich variable? This code look good Code: [Select]set syntaxterror=0
echo syntaxerror is: %syntaxerror%

type "output.txt" | find /i "Msg" && set syntaxerror=1
echo syntaxerror is: %syntaxerror%
REM if %syntaxerror% EQU 1 CALL :end !file!
Change %syntaxerror% to !syntaxerror!

So the delayed expansion will apply.

You did it for the other variables, but you missed that one.

6090.

Solve : How to minimise the Batch File?

Answer»

I KNOW how to minimise the program that is running (I have read some guides), however, I can't seem to find out how to minimise the batch file.

What I do, while running XP, is double CLICK on a batch file, which RUNS a javax file. However, that javax file also needs many additional files, and as a result, needs to be run using a batch file.

Unfortunatly, that means that the batch file is visible, which would often disturb several users of the program. Ideally, I would like the command prompt either invisible, or minimised.

Is this POSSIBLE?

(Ironically, the batch file is only one line long, but that line is very long-winded, and very error PRONE, so it is easier to use it)I'm not sure i follow your whole post but to start a batch file minimised start it with Code: [Select]start /min
FB

6091.

Solve : Error with bat2exe.com?

Answer»

Quote from: BatchFileCommand on January 26, 2009, 06:37:25 PM

It's not a wrapper. It turned my batch file code to a bunch of funky symbols LETTERS and stuff. BC, have you ever used this program? I'm afraid it doesn't convert stuff over 35kb.

Yes. that is what I describe above.All I want it to do is make my code unreadable and have it still RUN. Here's a chunk of code from my program:

Code: [Select]„+€1Ø3
>„߃Mìÿàü'h
Pðk]f9;„t


That's definatley exeQuote from: BatchFileCommand on January 27, 2009, 06:19:55 AM
All I want it to do is make my code unreadable and have it still run. Here's a chunk of code from my program:

Code: [Select]„+€1Ø3
>„߃Mìÿàü'h
Pðk]f9;„t


That's definatley exe


Sigh. Did you READ the post? do you know what PROCESS explorer is?

The batch file is plain text in the memory image.Quote from: BC_Programmer on January 27, 2009, 06:40:10 AM

Sigh. Did you read the post? do you know what process explorer is?

The batch file is plain text in the memory image.

BC_programmer, can't you see you're talking to an expert? Just look at the technical language he uses...

Quote
a bunch of funky symbols letters and stuff.
Code: [Select]BC_programmer, can't you see you're talking to an expert? Just look at the technical language he uses...

I love you sense of humor...Quote from: BatchFileCommand on January 27, 2009, 06:19:55 AM
All I want it to do is make my code unreadable and have it still run. Here's a chunk of code from my program:

Code: [Select]„+€1Ø3
>„߃Mìÿàü'h
Pðk]f9;„t


That's definatley exe

HA HA! I found a hole it that logic too! where's the MZ?
6092.

Solve : Set a command as an input or/and use a command with if????

Answer»

if %INPUT% is a time to CHECK then yesk thanks now i NEED to do just one more THING to it and COMPLETE for the server

6093.

Solve : I Want To Copy Everything(all directories) from "C' Drive to "D" Drive?

Answer»

See Here... for my review on Macrium REFLECT and a link to their SITE...http://www.giveawayoftheday.com/
It is telling me that /K is an invalid SWITCH..? Please help.



Quote from: Allan on September 10, 2009, 11:53:11 AM

xcopy c:\*.* /a /e /k

will copy everything located on c drive to the drive you are currently on

6094.

Solve : VBS Date & Time Accessible from a batch?

Answer»

Some weeks ago I hacked together a crude batch file which created a VB script & then read back the results to make various VBS date stuff accessible in a batch. I was gratified to see people make use of it and since I am on Xmas break from work I decided to tidy it up a bit and add some features as you can see below

CODE: [Select]@echo off
set vbsfile=newdate.vbs
echo Newdate = (Date())>%vbsfile%
echo DateYear = DatePart("YYYY", Newdate)>>%vbsfile%
echo DateMonth = DatePart("M" , Newdate)>>%vbsfile%
echo DateDay = DatePart("D" , Newdate)>>%vbsfile%
echo WeekOfYear = DatePart("WW" , Newdate)>>%vbsfile%
echo DayOfYear = DatePart("Y" , Newdate)>>%vbsfile%
echo WeekDayNumber = DatePart("W" , Newdate)>>%vbsfile%
echo TodayNameShort = WeekdayName(WeekDayNumber,True)>>%vbsfile%
echo TodayNameFull = WeekdayName(WeekDayNumber,False)>>%vbsfile%
echo TimeHour = Hour(Time)>>%vbsfile%
echo TimeMinute = Minute(Time)>>%vbsfile%
echo TimeSecond = Second(Time)>>%vbsfile%
echo If TimeHour^<12 Then>>%vbsfile%
echo AMorPM="AM">>%vbsfile%
echo Else>>%vbsfile%
echo AMorPM="PM">>%vbsfile%
echo End If>>%vbsfile%
echo Wscript.Echo DateYear^&" "^&DateMonth^&" "^&DateDay^&" "^&Week^
OfYear^&" "^&DayOfYear^&" "^&WeekDayNumber^&" "^&Today^
NameShort^&" "^&TodayNameFull^&" "^&TimeHour^&" "^&Time^
Minute^&" "^&TimeSecond^&" "^&AMorPM>>%vbsfile%

echo Date And Time Stuff Demo

for /f "tokens=1-12 delims= " %%A in ('cscript //nologo %vbsfile%') do (
echo A Date Year : %%A
echo B Date Month : %%B
echo C Date Day : %%C
echo D Week Of Year : %%D
echo E Day Of Year : %%E
echo F Day Of Week [Number] : %%F
echo G Day Of Week [Short Name] : %%G
echo H Day Of Week [Full Name] : %%H
echo I Time Hour : %%I
echo J Time Minute : %%J
echo K Time Second : %%K
echo L Is AM or PM : %%L
)




Output

Code: [Select]Date And Time Stuff Demo
A Date Year : 2008
B Date Month : 12
C Date Day : 24
D Week Of Year : 52
E Day Of Year : 359
F Day Of Week [Number] : 4
G Day Of Week [Short Name] : Wed
H Day Of Week [Full Name] : Wednesday
I Time Hour : 18
J Time Minute : 41
K Time Second : 10
L Is AM or PM : PM
Notes:

The time (hour) will be between 0 and 23. (i.e. what Americans call "military time") So AM/PM may be redundant
Minutes & seconds will be from 0 to 59. Values under 10 are single digits.

Comments / suggestions welcome!

Happy holidays to everyone. Except for this guy, who is "Off to Guantanamo!"



Thank you for another gem.

Quote

Happy holidays to everyone. Except for this guy, who is "Off to Guantanamo!"

Do you supply your own orange overall?

Have a great time.



Thank you for this.
results can be open automaticaly when you run the bat file?Quote from: DAan on January 04, 2009, 12:18:15 AM
Thank you for this.
results can be open automaticaly when you run the bat file?

What do you mean?
DAan probably is trying to ask if the BAT file displays the date/time when it is finished running.Quote from: Helpmeh on January 05, 2009, 03:18:15 PM
DAan probably is trying to ask if the BAT file displays the date/time when it is finished running.

Well, if so, then all I can say is that it should be obvious to the intended users (either from looking at the "output" box above, or by actually saving and running the batch file) what it does. Also people who have some experience of writing & using batch files will be able to see how to modify it for their own purposes.
Quote from: Dias de verano on January 05, 2009, 03:35:21 PM
Quote from: Helpmeh on January 05, 2009, 03:18:15 PM
DAan probably is trying to ask if the BAT file displays the date/time when it is finished running.

Well, if so, then all I can say is that it should be obvious to the intended users (either from looking at the "output" box above, or by actually saving and running the batch file) what it does. Also people who have some experience of writing & using batch files will be able to see how to modify it for their own purposes.


True....Dias. Is it possible to enter a date and have your script produce the results from that date. If 23-11-2008 was entered can your code be modified to display month, day, year, week#, day# etc using that date as input?

I have searched T.Salmi, alt.msdos and others without success.

Cheers Yes. It is 8:08 AM here and I am off to work, I will answer after work this afternoon.

You should be looking at VBS date functions really.
Quote from: Hedonist on January 27, 2009, 01:01:53 AM
Dias. Is it possible to enter a date and have your script produce the results from that date. If 23-11-2008 was entered can your code be modified to display month, day, year, week#, day# etc using that date as input?

I have searched T.Salmi, alt.msdos and others without success.

Cheers

Qdate.bat
Code: [Select]
@echo off


REM Create VBS script
set vbsfile=DateInfo.vbs
echo Newdate = WScript.Arguments(0)>%vbsfile%
echo if IsDate(Newdate) then>>%vbsfile%
echo Newdate = CDate(Newdate)>>%vbsfile%
echo DateYear = DatePart("YYYY", Newdate)>>%vbsfile%
echo DateMonth = DatePart("M" , Newdate)>>%vbsfile%
echo DateDay = DatePart("D" , Newdate)>>%vbsfile%
echo WeekOfYear = DatePart("WW" , Newdate)>>%vbsfile%
echo DayOfYear = DatePart("Y" , Newdate)>>%vbsfile%
echo WeekDayNumber = DatePart("W" , Newdate)>>%vbsfile%
echo TodayNameShort = WeekdayName(WeekDayNumber,True)>>%vbsfile%
echo TodayNameFull = WeekdayName(WeekDayNumber,False)>>%vbsfile%
echo MonthNameShort = MonthName(DateMonth,True)>>%vbsfile%
echo MonthNameLong = MonthName(DateMonth,False)>>%vbsfile%
echo Wscript.Echo DateYear^&" "^&DateMonth^&" "^&DateDay^&" "^&Week^
OfYear^&" "^&DayOfYear^&" "^&WeekDayNumber^&" "^&Today^
NameShort^&" "^&TodayNameFull^&" "^&MonthNameShort^&" "^&MonthNameLong>>%vbsfile%
echo else>>%vbsfile%
echo Wscript.Echo "ERROR">>%vbsfile%
echo end if >>%vbsfile%

REM below is example batch code to call the vbs

REM Example of use
REM 1) get a date string into a variable
set /p Querydate=Enter Date:

REM 2) pass the string to the VBS script and
REM parse the output, which will either be 10
REM items of data, or else the string "ERROR"
REM if the string is not a valid date.
REM
REM Store output of vbs script in variables
for /f "tokens=1-10 delims= " %%A in ('cscript //nologo %vbsfile% %querydate%') do (
set Year=%%A
set Month=%%B
set Day=%%C
set WeekNumber=%%D
set DAYNUMBER=%%E
set DayOfWeekNum=%%F
set DayNameShort=%%G
set DayNameLong=%%H
set MonthNameShort=%%I
set MonthNameLong=%%J
)

REM 3) Do something with the data
if "%Year%"=="ERROR" (
echo Error: invalid date
) else (
Echo Data for Date: %Querydate%
echo.
echo Date Year : %Year%
echo Date Month : %Month%
echo Date Day : %Day%
echo Week Of Year : %WeekNumber%
echo Day Of Year : %DayNumber%
echo Day Of Week [Number] : %DayOfWeekNum%
echo Day Of Week [Short Name] : %DayNameShort%
echo Day Of Week [Full Name] : %DayNameLong%
echo Month [Short Name] : %MonthNameShort%
echo Month [LONG Name] : %MonthNameLong%
echo.
Echo %DayNameLong%, %MonthNameLong% %Day%, %Year% is/was/will be in week %WeekNumber%
echo.
)


Alternatively you could just save the vbs script somewhere on your PATH and call it from batches


Code: [Select]
Newdate = WScript.Arguments(0)
if IsDate(Newdate) then
Newdate = CDate(Newdate)
DateYear = DatePart("YYYY", Newdate)
DateMonth = DatePart("M" , Newdate)
DateDay = DatePart("D" , Newdate)
WeekOfYear = DatePart("WW" , Newdate)
DayOfYear = DatePart("Y" , Newdate)
WeekDayNumber = DatePart("W" , Newdate)
TodayNameShort = WeekdayName(WeekDayNumber,True)
TodayNameFull = WeekdayName(WeekDayNumber,False)
MonthNameShort = MonthName(DateMonth,True)
MonthNameLong = MonthName(DateMonth,False)
Wscript.Echo DateYear&" "&DateMonth&" "&DateDay&" "&WeekOfYear&" "&DayOfYear&" "&WeekDayNumber&" "&TodayNameShort&" "&TodayNameFull&" "&MonthNameShort&" "&MonthNameLong
else
Wscript.Echo "ERROR"
end if


Code: [Select]
S:\Test\Batch\querydate>qdate.bat
Enter Date:23-11-2008
Data for Date: 23-11-2008
Date Year : 2008
Date Month : 11
Date Day : 23
Week Of Year : 48
Day Of Year : 328
Day Of Week [Number] : 1
Day Of Week [Short Name] : Sun
Day Of Week [Full Name] : Sunday
Month [Short Name] : Nov
Month [Long Name] : November

Sunday, November 23, 2008 is/was/will be in week 48

S:\Test\Batch\querydate>qdate.bat
Enter Date:34-9-1788
Data for Date: 34-9-1788
Error: invalid date

6095.

Solve : DISKPART bat?

Answer» HI to all i just join this wonderful forum. i like computers and stuff like these kind of taste of programming, since i dont study programming my knowledge is bit little.



my point is i WANT to make a batch file to run DISKPART

i started with still line
START C:\Windows\SYSTEM32\DISKPART.EXE

now for the PART where i would need to set to choice to SELECT VOLUME 3 how do i add these kind of paremeters??? thanks You would create a text file with the commands you want Diskpart to execute, and then invoke Diskpart with the textfile path and name as one of the parameters.

http://blogs.msdn.com/embedded/archive/2005/12/23/506404.aspx

http://support.microsoft.com/default.aspx?scid=kb;en-us;300415

I actually wrote a batch file using diskpart and turned it into a USB Pen Drive Letter switching EXECUTABLE. The problem is that you cant hard code the Volume selection or the drive letter to assign it to!! So what i did was take the users input, export it into a text file and then run disk part against the text file using the -s (script)parameter.

Here's my code if you'd like to take a look and the executable itself can be downlaoded from here:
http://feartechsolutions.proboards.com/index.cgi?board=feartechprograms&action=display&thread=1

Code: [Select]@echo off
color 0E
mode con lines=22 cols=86
echo>list.txt
echo>list.txt list volume
@echo on
diskpart -s list.txt
@echo off
set /p DLA=Enter desired volume:
echo:
set /p LTT=Enter drive letter:
echo:
echo>move.txt
echo>move.txt list volume
echo>>move.txt select volume %DLA%
echo>>move.txt assign letter=%LTT%
@echo off
diskpart -s move.txt
echo:
Del /f "list.txt"
Del /f "move.txt"
echo:
echo:
pause
exit /b

Hope this HELPS

Russ
6096.

Solve : Batch file to make backup of a folder based on time and day of week?

Answer»

Thank You Dusty, I tried the script at WORK and i do not know exactly was the wording of the error was, so sorry for the confusion but the taskkill wpont work because CHeckInn need to exit by pressing Exit on its menu screen so i found a program called Eventcoder and i recorded the mouse movement to click Exit and I added the path in the script to run where the Taskkill command LINE use to be and it worked perfectly. So i deleted the sleep command lines and the whole script ran perfectly.

But I will make sure it works as intended and I will post the result tomorrow for you.

But Thank You again for your kind help.Hello Dusty, The script worked great it did made and copied all files to correct folder also even at3.58am last night which it recorded to MON_C shift folder.

Thanks DUsty again. I wanted to add couple things if possible,

1) If the Batchfile can be run as a startup batch file and if it can repeate doing backup every say 3 hours by itself.

2) If there can be option showup which says If you are ready to Backup Press Y and Hit ENTER to continue doing Backup or Press X to wait for 5 minutes.

In option 2 if the backup need to be delayed by 5 minutes can it go to end and restart after 5 minutes in case the CheckInn program is being used. In this case the next back still RUNS on time e.g. 3pm, 6pm, 9pm, 12pm etc.

Can there be a command added to enlarge fonts and may be color the lines seperately.


Thanks you.

1. Copy the .bat file to "C:\DOCUMENTS AND SETTINGS\USERNAME\START MENU\PROGRAMS\STARTUP\". Username is the name of the account which starts on your system, it could be Administrator or some other name. You may also want to delete the commands you have added to kill Checkinn.exe if it has not already been started. You don't need me to schedule when the .bat file will run, see the XP Task Scheduler here..

2. Will respond later.

The use of the COLOR command is shown here.. or enter COLOR/? at the command PROMPT. The only way I know of increasing/decreasing the font size in Cmd.exe is to R.Click the top bar, select Properties>Font and change the font size in the font size slider. You'd have to make this setting apply to all output in the Cmd.exe window.



Thank you Dusty,

I will schedule with Xp Task Scheduler ANS report the results.

Thank you again.Unfortunately I have been unable to locate a timing feature in batch scripting so all timing must be done using the Task Scheduler in order to do what you want.

Make the start of the Checkinn.bat file look like this:
Quote

@echo off
cls
setlocal enabledelayedexpansion


for /f "delims=*" %%1 in (runit.dat) do (
set runit=%%1
)
if "%runit%"=="No" exit

echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.&echo.
color 1c
set/p run= CAN BACKUP BE RUN NOW? (Y/N)...

cls

if "%run%"=="y" call :start

if "%run%"=="Y" call :start

exit

:start

:: Checkinn.bat

and the end of the script to this:
Quote
echo No>runit.dat
exit

Create the file C:\runit.dat containing just the word "Yes" without the quotes.

Create the following script and save it as filename.bat:
Quote
@echo off
cls
echo Yes>runit.dat

Task scheduling Suggestions.
===================
Schedule the main script to run at the times you want, 3 6 9 and 12 pm (note that according to the specs I extracted from your post, these times to not include any backup in Shift A which I have noted as being 4 am to 2pm daily, please confirm). Also schedule the script to start 5 mins after the above times.

This will allow the script to run at the appointed hours and at five mins after those times if backup does not proceed.

Schedule filename.bat to run at say 3.20 6.20 9.20 and 12.20 pm



Thanks Dusty, The Backup is running good so far except i have not added the last post suggestions yet, I wanted to try it first. I a wondering is there a way to get out of screensaver when the batch file starts or say play a music file in wma format so that to bring attention of the person working?

I will add script from your last post tomorrow and let you know how it goes.

Thanks Again.Hi i m new to batch file can any one plz tell me the batch file making process from begning.
will appericiate for helping me out.
regds
himHim6182 - Welcome to the CH forums.

Please do NOT hijack another member's thread, start your own.

Batch scripting info can be found here and there a many many on-line tutorials.

Good luck
6097.

Solve : Batch How to handle multiple IF conditions?

Answer»

How to handle multiple IF conditions in a batch scripting
Ex:-
IF %Ti% EQU 2 ( first if start
do this
do this
do this
do this
IF "%clc%" GEQ "800" set /a yy=%yy%+1
IF "%Day%" GTR "1" set /a yy=%yy%+1
IF %yy% LEQ 2 (
taskkill /F /IM calc.exe
) ELSE (
taskkill /F /IM notepad.exe
)

) ELSE ( first if end
echo Bye Bye
)


Thanks in advanceWe do not know what your "do this" code does so cannot give detailed help. However, in a multi line IF structure, you need to use delayed expansion to set and read variables to work properly. You can Google for many pages about this.

Code: [Select][quote author=Salmon Trout link=topic=92501.msg625699#msg625699 date=1253810618]
We do not know what your "do this" code does so cannot give detailed help. However, in a multi line IF structure, you need to use delayed expansion to set and read variables to work properly. You can Google for many pages about this.


[/quote]
Dear Salmon Trout,
Pls find the code,
How to handle multiple IF conditions in a batch scripting
Ex:-

For /f "tokens=5" %%i in (6.txt) do set ci=%%i
IF %ci% EQU 2 ( [B] first if start[/b]
For /f "tokens=3" %%i in (6.txt) do set Tl=%%i
set Th=%Tl:~0,2%
set Tm=%Tl:~3,2%
Set TL=%Th%%Tm%
For /f "tokens=2" %%J in (4.txt) do set Tj=%%j
set /A Clc=%Tf%-%TL%
set /A Day=%dt%-%Tj%
:del 4.txt
echo %clc%
echo %Day%
set bool=0
[i]IF "%clc%" GEQ "800" set /a yy=%yy%+1
IF "%Day%" GTR "1" set /a yy=%yy%+1
IF %yy% LEQ 2 (
taskkill /F /IM calc.exe
) ELSE (
taskkill /F /IM notepad.exe
)
)[/i] ELSE ( [b]first if end[/b]
echo Bye Bye
)

Pls ADVICE,
Thanks in ADVANCE 1. Normally, cmd.exe expands variables ONCE only, at parse time.
So with variables set and expanded inside parentheses e.g:

FOR bla bla BA (
set var=abc
echo %var%
)

or

IF bla bla bla (
set var=abc
echo %var%
)

... the variable %var% is unknown at parse time, so is blank.
If it was set before the parentheses start, it retains that value.

Solution:
-- use delayed expansion, enable it at the start of the batch
-- use ! exclamation points instead of % percent signs for those
variables which are both set and expanded inside the parentheses.
(can use % signs to expand those variables after the parentheses end.)

REM Put this line near the start of the batch. Only need it once.
setlocal enabledelayedexpansion
FOR bla bla ba (
set var=abc
echo !var!
)

IF bla bla bla (
set var=abc
echo !var!
)

2. Each IF can have only 1 ELSE. Therefore redesign logic.

e.g. use labels and goto

if "%animal%"=="CAT" goto meow
if "%animal%"=="DOG" goto grrrr
goto other

:meow
echo animal is a cat
goto next

:grrrr
echo animal is a dog
goto next

:other
echo animal is something else
goto next

:next
echo next part of code



6098.

Solve : Beep.com for DOS ??

Answer»

Was there ever a BEEP command for DOS?
I found this on my computer.
Code: [Select]d:\bin>VER

Microsoft Windows XP [VERSION 5.1.2600]

d:\bin>DEBUG BEEP.COM
-U100 10A
0B49:0100 B8070E MOV AX,0E07
0B49:0103 CD10 INT 10
0B49:0105 B8004C MOV AX,4C00
0B49:0108 CD21 INT 21
0B49:010A 90 NOP
-Q

d:\bin>
Anyway, it seems to work. Well I don't have a bin folder...


Microsoft Windows XP [Version 5.1.2600]

Well, I can make a good BEEP replacement.

echo.

Literately copy and paste the following:

Code: [Select]echo. YES there was....http://www.programmersheaven.com/files/2/0/23711-23711.ZIP

contains a NUMBER of DOS programs including BEEP.COM

Code: [Select]BEEP.COM -- Speaker Beep Utility

Will generate an 800hz .25 second tone through the PC speaker.
Frequency and duration is approximate but close.

Syntax: BEEP [count]

count = 1 to 9 (default = 1)

EXAMPLES: BEEP 3 (Beep 3 times.)
BEEP (Beep 1 time.)

System Requirements: 8088 or greater
Dos 1.0 or greater
PC Speaker
Do NOT expect this to work in Windows command prompt!

6099.

Solve : Copy file in Command Prompt?

Answer»

From: c:\testfolder1\testfile1.docx
To: c:\documents and settings\testfolder2\

I've tried every which WAY to COPY this file (testfile1.docx) in Command Prompt but keep getting "the system cannot find the file SPECIFIED."

How should it look in Command Prompt?copy file folder

I actually made the folders and the file to be copied.

Use QUOTES around the path & filename if it has any spaces.

Code: [Select]C:\&GT;copy c:\testfolder1\testfile.docx "c:\Documents and Settings\testfolder2\"
1 file(s) copied.
Thanks Salmon ... the quotes work.

6100.

Solve : Delete of Copy Max or Min file size from a directory?

Answer»

I want to copy maximum size file one directory to another and delete minimum file size one directory using batch file. Can ANYONE help me? yes, let me dash my magic wand and make a script appear!
im sorry, but i have noo idea what you mean by "maximum size file" or to delete "minimum file size one directory"Homework?

In a For loop use dir /os to sort files in ascending size order (smallest first)
and delete the first file.

In a second For loop use dir /o-s to sort files in DESCENDING size order (largest first) and copy the first file.Thanks for your REPLY... let me explain why I need it.. I have a oracle database server and a scheduler creates dumps every 6 hours... and its quite large around 1.2 gb and every time the dmp file is created with a filename like 12-AUG-2009.dmp. As we have a storage server where I have a disk quota of 4 GB only I want to transfer last two BACKUPS to my storage server deleting the older versions using scheduler. Can you help me?