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.

6551.

Solve : Trying to copy C drive but access denied - PLEASE HELP....THANKS?

Answer»
--------------------------------------------------------------------------------
I have look thru the posts but could not find enough info. I am a rookie and it would help if the responses were spelled out in laymans terms. I am running Windows Vista. Thanks.

The problem I am having is that I dropped my computer. I have been with the DELL tech group but no help. So I was in DOS which I learned 20 years ago (forgot most) but have just enough KNOWLEDGE to pull up DOS and try simple copy commands. I tried to copy all of the C drive but no can do due to all the programs on it. SO.... I want to copy just my files that are on the C drive onto a flash drive but I do not know the commands. I have looked on several sites but cannot not find what I need.
DOS is not the answer for this problem......

You will need drivers for that USB drive to work and GETTING DOS drivers for USB storage media would be a nightmare to find is there are any out there.... I'd use a Knoppix Live Linux CD to boot the system and access the C: drive, which would mount as not C: but as the only hard drive in your system. Then use the GUI of Knoppix to grab data off of your Hard Drive and Copy it to the Thumb drive..... Knoppix should be able to see NTFS, and will definately see FAT32 partitions if an old laptop like Windows 98 SE. NTFS should be able to work with Knoppix distro, but I believe it is still in a "beta" state for support.

You will need to go to http://www.knoppix.com/ and download it.... about 700MB to a CD or DVD, and be able to burn it. You will need DSL or Broadband to be able to do this because it would take a week with satelite or dial-up.

Boot the laptop off the burned Knoppix CD or DVD and be sure that the thumb drive is also inserted so Knoppix will SEEIT when it detects hardware and mounts its drivers ( HOPEFULLY )

Other than that, your best bet is getting a IDE to USB kit for about $20 that will allow for you to plug your hard drive (removed from laptop ) into a dongle setup that will plug in via USB to a desktop or another laptop. * You can also use a 2.5" External Drive case, but that may cost more than the IDE to USB dongle that are out there... The better dongle is the one that is double sided for 2.5" and 3.5" laptop and desktop computer IDE drives, and a nicer version EVEN has SATA support with the IDE support. With the dongle the computer interfacing with the drive will see it as an external drive. ((( As long as the drive is not badly damaged you should be able to COPY all important data from that drive to the other computer and burn it to CD or DVD if you wanted or move it to USB thumb drive which is less safe due to the flash memory nature than burning to media like CD or DVD.)))
6552.

Solve : how to hide password?

Answer»

hi experts,
I have created a batchfile which take input from the user such as user name and password. At this time when the user type the user name and password it display on the window i would like to hide the password while the user TYPING it is it possible?Quote from: brough on July 10, 2008, 09:45:02 AM

hi experts,
I have created a batchfile which take input from the user such as user name and password. At this time when the user type the user name and password it display on the window i would like to hide the password while the user typing it is it possible?
LET's get this straight?
So when the user types there password in you want it to come up as ***** for example?Quote from: Jacob on July 10, 2008, 10:42:04 AM
Quote from: brough on July 10, 2008, 09:45:02 AM
hi experts,
I have created a batchfile which take input from the user such as user name and password. At this time when the user type the user name and password it display on the window i would like to hide the password while the user typing it is it possible?
Let's get this straight?
So when the user types there password in you want it to come up as ***** for example?

Yes that is correctQuote from: brough on July 10, 2008, 10:50:13 AM
Quote from: Jacob on July 10, 2008, 10:42:04 AM
Quote from: brough on July 10, 2008, 09:45:02 AM
hi experts,
I have created a batchfile which take input from the user such as user name and password. At this time when the user type the user name and password it display on the window i would like to hide the password while the user typing it is it possible?
Let's get this straight?
So when the user types there password in you want it to come up as ***** for example?

Yes that is correct
Weird things is, i was wondering the exact same thing, shame i cannot help you.
Lets hope somebody canTry this. It was posted online quite some time ago but I can't remember where it is.

Code: [Select]@echo off
SET REAL_PASS=password
SET REAL_LENGTH=********

echo e100 B4 00 CD 16 88 E0 B4 4C CD 21> %temp%.\\\\scan.com
for %%? in (rcx A w q) do echo %%?>> %temp%.\\\\scan.com
type %temp%.\\\\scan.com |DEBUG %temp%.\\\\scan.com > nul

:pre
for %%? in (pass length) do set user_%%?=

:loop
set input=
cls
echo Type password: %user_length%
if \\"%user_pass%\\"==\\"%real_pass%\\" goto granted
if \\"%user_length%\\"==\\"%real_length%\\" goto denied
call %temp%.\\\\scan.com
if errorlevel=2 if not errorlevel=3 set input=1
if errorlevel=3 if not errorlevel=4 set input=2
if errorlevel=4 if not errorlevel=5 set input=3
if errorlevel=5 if not errorlevel=6 set input=4
if errorlevel=6 if not errorlevel=7 set input=5
if errorlevel=7 if not errorlevel=8 set input=6
if errorlevel=8 if not errorlevel=9 set input=7
if errorlevel=9 if not errorlevel=10 set input=8
if errorlevel=10 if not errorlevel=11 set input=9
if errorlevel=11 if not errorlevel=12 set input=0
if errorlevel=30 if not errorlevel=31 set input=a
if errorlevel=48 if not errorlevel=49 set input=b
if errorlevel=46 if not errorlevel=47 set input=c
if errorlevel=32 if not errorlevel=33 set input=d
if errorlevel=18 if not errorlevel=19 set input=e
if errorlevel=33 if not errorlevel=34 set input=f
if errorlevel=34 if not errorlevel=35 set input=g
if errorlevel=35 if not errorlevel=36 set input=h
if errorlevel=23 if not errorlevel=24 set input=i
if errorlevel=36 if not errorlevel=37 set input=j
if errorlevel=37 if not errorlevel=38 set input=k
if errorlevel=38 if not errorlevel=39 set input=l
if errorlevel=50 if not errorlevel=51 set input=m
if errorlevel=49 if not errorlevel=50 set input=n
if errorlevel=24 if not errorlevel=25 set input=o
if errorlevel=25 if not errorlevel=26 set input=p
if errorlevel=16 if not errorlevel=17 set input=q
if errorlevel=19 if not errorlevel=20 set input=r
if errorlevel=31 if not errorlevel=32 set input=s
if errorlevel=20 if not errorlevel=21 set input=t
if errorlevel=22 if not errorlevel=23 set input=u
if errorlevel=47 if not errorlevel=48 set input=v
if errorlevel=17 if not errorlevel=18 set input=w
if errorlevel=45 if not errorlevel=46 set input=x
if errorlevel=21 if not errorlevel=22 set input=y
if errorlevel=44 if not errorlevel=45 set input=z
if errorlevel=71 if not errorlevel=72 set input=7
if errorlevel=72 if not errorlevel=73 set input=8
if errorlevel=73 if not errorlevel=74 set input=9
if errorlevel=75 if not errorlevel=76 set input=4
if errorlevel=76 if not errorlevel=77 set input=5
if errorlevel=77 if not errorlevel=78 set input=6
if errorlevel=79 if not errorlevel=80 set input=1
if errorlevel=80 if not errorlevel=81 set input=2
if errorlevel=81 if not errorlevel=82 set input=3
if errorlevel=82 if not errorlevel=83 set input=0
if \\"%input%\\"==\\"\\" goto loop
set user_length=*%user_length%
set user_pass=%user_pass%%input%
goto loop

:granted
echo Access granted.
goto pass_end

:denied
echo Access denied.
:: Uncomment following line in ORDER to keep asking user the password
:: GOTO PRE
goto pre
goto pass_end

:pass_end
for %%? in (pass length) do set user_%%?=
for %%? in (pass length) do set real_%%?=
del %temp%.\\\\scan.com
pausehalf WORKS, backspace doesn't work.
thanks anyway.You can try this magical batch file:

Code: [Select]@echo off
:retry
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>in.com
set /p password=Enter password:<nul
for /f "tokens=*" %%i in ('in.com') do (
set password=%%i
)
if /i not %password%==password cls && goto retry
del in.com

PS. The password is password, but you can change it.

Quote from: SIDEWINDER on July 10, 2008, 03:56:21 PM
You can try this magical batch file:

Code: [Select]@echo off
:retry
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>in.com
set /p password=Enter password:<nul
for /f "tokens=*" %%i in ('in.com') do (
set password=%%i
)
if /i not %password%==password cls && goto retry
del in.com

PS. The password is password, but you can change it.


Not bad.
6553.

Solve : Change admin password in DOS?

Answer»

I know I've seen this but can't remember where...old age strikes again

How does one go about resetting the admin password in a DOS WINDOW? I'll write the answer down this time

Alan <>< well if you are an admin then you can try the following code in a BATCH file:

Code: [Select]NET USER [ADMIN ACCOUNT] [password]

you will need to CHANGE the account name and the password sections but if you have ACCESS this will do it through batch.

thanks,
Wayne

6554.

Solve : Need help with batch?

Answer»

I'm trying to make the computer mount a mini-image in Daemon tools, run Battlefield 2, and run the WIDESCREEN fix for it. I'm a complete noob with batch files. This is what I have so far:
CODE: [SELECT]@echo off

cd C:\Program Files\DAEMON Tools Lite
daemon.exe -mount 0, "C:\Games\Battlefield 2\Mini-Image\blh-bf2.mds"
cd C:\Games\Battlefield 2
BF2.exe +menu 1 +fullscreen 1 +SZX 1440 +szy 900 +widescreen +restart
cd C:\Program Files\Widescreen Fixer
WidescreenFixer.exeThe problem is, the widescreen fix only launches after I close Battlefield 2. How can I run it right after BF2 launches?
try this
START "" BF2.exe +menu 1 +fullscreen 1 +szx 1440 +szy 900 +widescreen +restart Thanks

6555.

Solve : Stop Active Connections?

Answer»

Hi..
I need stop one Active Connection from a Batch File.

For Eg:
PROTO LOCAL Address Foreign Address State
TCP test-1:1177 10.198.64.13:6533 ESTABLISHED

I need to stop this foreign address with batch file. just help how to create.

Thanks in Advance.
Hemanth Kumar.I cant see batch BLOCKING this... I'd set up a firewall RULE instead or edit hosts file to point to 127.0.0.1 LOOPBACK instead to block.

6556.

Solve : How to run reg file from bat file with answering message alert?

Answer»

ThanksYour WELCOME?

6557.

Solve : dos boot cd?

Answer»

i would like to make a DOS boot CD that will allow me to boot into dos and view/change the CONTENTS of my hdd.

how do i do it?

thanks,
darryl1. TYPE DOS Boot CD into Google.
2. Find a site.
3. Follow the instructions.
Quote from: dworley on September 06, 2007, 12:33:43 PM

i would like to make a DOS boot CD that will allow me to boot into dos and view/change the contents of my hdd.


Only if your file system is not NTFS otherwise you will need NTFS4Dos

Good luckthanks contrex.

way to be a ........dworley, is there a particular REASON you REVIVED this thread after 10 months? Oh and could you moderate your language please? And did you make your boot cd?

6558.

Solve : Echo + Append text to specific line in a txt file..???

Answer»

is there a way to echo + Append TEXT into a specific line in a .txt file..
like say i ALREADY have a txt file wit 10 lines of txt in it.
and i want to echo something in on line 5 but have it echoed in after all the txt on that line..
Ex:
.txt file
Code: [Select]1---:
2---:
3---:
4---:
5---: !!!..Echoed in txt here..!!!
6---:
7---:
8---:
9---:
10---:

can this be done at all with batch code..??You can do it .. sort of, you will need to read through the whole file, writing out what you have read, if the current line is the one you wish to change, then WRITE out the changed value

Grahamhow exactly do i do that..??Anyone KNOW how to do this..??Do you mean you already have a text file like this:

Quote from: Text File

1---:
2---:
3---:
4---:
5---:
6---:
7---:
8---:
9---:
10---:
And you want to add !!!..Echoed in txt here..!!! on the fifth line?yup, u got it, thas wat i wana do..
can it be done..??With the other tools available on modern machines, why did you pick a batch solution?

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%i in (input.txt) do (
call set /a count=%%count%%+1
if !count!==5 (set line=%%i ..Echoed in txt here..) else (set line=%%i)
echo !line!>>output.txt
)

This comes dangerously close to programming and we all know batch coding is not a programming language.

Note: Exclamation marks (!) have special meaning in batch files. If you must absolutely have them, you'll need to work that part of the solution yourself.


thanks for the help..
but this seems to just duplicate the input.txt file into the output.txt then appends then new text into the output.txt..

I need it to append the new text to the 5th line on the original input.txt Quote
I need it to append the new text to the 5th line on the original input.txt

That is not going to happen. Batch code can only process sequential files. Sequential files cannot be updated in place (cannot be opened both input and output at the same time). If the new record were larger than the old record, how would it fit into the old space?

Here is one workaround:
Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
for /f %%i in (input.txt) do (
call set /a count=%%count%%+1
if !count!==5 (set line=%%i ..Echoed in txt here..) else (set line=%%i)
echo !line!>>output.txt
)
ren input.txt input.old
ren output.txt input.txt

I dislike writing destructive code but the first ren command can be replaced by a del command.

6559.

Solve : Symbols in complex passwords?

Answer»

I am USING a simple batch FILE to map a drive but the password to the drive contains a "&" SYMBOL. When the file runs it seperates before and after the symbol and CREATES a message the "&XX" is not a recognized command. Is there a way to group the text string (password)? I have tried to put it in "" but it fails telling me the password is wrong.

Thanks for any comments. Honestly, I would avoid the & character, known as the "poison character", or else I would use something other than batch language.

6560.

Solve : minimize windows screen?

Answer»

Anybody know of a way to shrink, minimize or hide a SCREEN of a windows program I have just opened?

I use a batch FILE that, when done, plays a wav with the mediaplayer. I do not want to see the player, only to hear the sound.

Thanks in advance.

DramklukkelStart /Min

Please POST your code..
I think he wants sound effects for his batch files, the same way windows makes sounds without opening a Media Player. (e.g. IE Clicking, Error messages, ect..)@Carbon Dudeoxide:
PRECISELY. Even with the same familiar warning wave that Windows uses. But I've decided to leave the sound out and use a message popup instead. It can stay onscreen until user input, just in case user left for coffee. Could SHOW the log as well if needed.

Greetings,
Dramklukkel
I remember users asking that question before but leaving disappointed.

If you have any more questions, feel free to come back to CH.

6561.

Solve : How can I sort a text file eliminating duplicates? i.e sort unique?

Answer»

Hi,
Never did dos batch programming.
I have a text file. I want to sort from column 10 thru 15 and I want to eliminate duplicates. How can i do this?

Thanks for your HELP,
akondetiduplicates of what? give us an example of the text fileThanks for responding.

Here is my file layout (comma delimited)

Raja,[emailprotected],732-567-0987
Sam,[emailprotected],654-654-8970
Joda,[emailprotected],765-987-0987
Raja1,[emailprotected],743-546-0987
Som,[emailprotected],876-657-9087

(a)I want to sort the file on field 2 which is the e-mail address
(b)I want to eliminate duplicates on field 2 i.e e-mail address
(c)I want to write the output(unique e-mail ids) to a DIFFERENT text file.

How can i accomplish the above. Thanks in advance for your help.
no easy way to do that in DOS ( you can try meddling with sort that comes with Windows though). However, here's a simpler way, if you can download GNU sort for windows here

this is all you need.
Code: [SELECT]sort -t"@" -k2,2 file
Hi,
Thanks for your help. I will try downloading.

Regards,
akondetiHi,
i have downloaded the coreutils from GNUWin32 and installed them
But when i type the following command, it is giving error


C:\Users\Chola>sort -t "@" -k2,2 email-list.txt
Input file specified two TIMES.

(a)After downloading and installing the core utils, do i have to do anything else?

The GNUWin32 is installed at
C:\Program Files\GnuWin32

Please advise.

The input file has the following records
Raja,[emailprotected],732-567-0987
Sam,[emailprotected],654-654-8970
Joda,[emailprotected],765-987-0987
Raja1,[emailprotected],743-546-0987
Som,[emailprotected],876-657-9087

and
(a)I want to sort the file on field 2 which is the e-mail address
(b)I want to eliminate duplicates on field 2 i.e e-mail address
(c)I want to write the output(unique e-mail ids) to a different text file.

Thanks,
akondetiyou have downloaded to C:\Program Files\GnuWin32, however, you are running sort in c:\users\chola without specifying the full path to GNU sort. therefore, the OS is using the sort provided by M$.
Either provide the full path, or configure your $PATH to include C:\Program Files\GnuWin32. Make sure you put it in front of C:\windows\system32I have the core utils, and I have copied the GNU echo.exe to a folder on my PATH and renamed it gnuecho.exe to avoid precisely this problem.
O.K
I have made changes to my PATH and it is working.

Thanks a lot for all your help.

Got a quick question though. The gnu core utils does not include grep, the very popular and useful unix command.
Is this not a core util? Any way to have grep on windows/dos?


Quote from: akondeti on July 10, 2008, 10:19:50 PM

Any way to have grep on windows/dos?

The GNU core utils is not the only collection of unix utilities ported to Win32. There are others, INCLUDING a small set called Unxutils which does have grep.exe

http://unxutils.sourceforge.net/ Quote from: akondeti on July 10, 2008, 10:19:50 PM

Got a quick question though. The gnu core utils does not include grep, the very popular and useful unix command.
Is this not a core util? Any way to have grep on windows/dos?

its' here
go to the root URL to see more.
6562.

Solve : how to make a batch file fail???

Answer»

hi

i have created a batch file which checks for a file.
if the file is present it renames the file.

however if the file is not present it says file not present through echo command.

but i need the batch file to fail and return error or failure.

can SOMEONE help me out

abhinav Please post the code you are usingIF EXIST "c:\TRY\a.txt". (
copy "c:\try\a.txt" "c:\try\b.txt"
del "c:\try\a.txt"
echo deleted.

) ELSE (
echo "c:\try\a.txt" missing.
echo try again.

)

If the file is missing then the script should fail but it runs successfully irrespective of the file being present or not What do you mean by "fail"? Why don't you just exit silently if the file to be renamed does not exist?

Did you write the script yourself?
no i want it to return an error... an APPLICATION will use this batch file and will succed or fail in the first step depending on the result of this scriptJust my 2¢:

Is this a TYPO or a stray dot: IF EXIST "c:\try\a.txt". (

If you're trying to test the else condition, rename a.txt before running your code.

Why copy a.txt to b.txt, then delete a.txt? Faster to rename a.txt to b.txt and eliminate the middleman.

Gotta love this post title: how to make a batch file fail??. There are countless examples scattered about the CH DOS board.



not a typo ...this script runs on my comp
yes renaming would be easier but i require to do it this way.

could you just tell me how to make the else part of the script such that if there is no file the script should not run successfully...Try this:

Quote

IF EXIST "c:\try\a.txt". (
copy "c:\try\a.txt" "c:\try\b.txt"
del "c:\try\a.txt"
echo deleted.

) ELSE CRASH

Your script will SURELY fail...thanks ...
6563.

Solve : cant get my batch file running?

Answer»

hey guys I'm new to making .bat files, i have a problem with with making them its easy en ought make them but GETTING it to work isn't as easy as i thought.

the problem is:

i have Made this for a test but it doesn't work right when i have saved the DOCUMENT and i click the test.bat file it just blinks on my screen with the command window and that's it ? can ANYONE help me maybe I'm not doing it 100% here is my batch test.txt:

@echo off
:echo
cls
title echo
echo.
echo.
echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo
echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo
echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo
echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo
echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo echo
echo.
echo.
echo THIS IS A TEST PROGRAM
echo.
echo.are you SERIOUS?
why would anyone do that?? Lol maybe add pause command after last line huh?Quote from: devcom on July 14, 2008, 03:20:16 AM

Lol maybe add pause command after last line huh?

Quote
i have Made this for a test but it doesn't work right when i have saved the document and i click the test.bat file it just blinks on my screen with the command window and that's it ?

Technically, there is nothing wrong with your batch file. The first echo on each line is seen as a command, all the others are text for the echo to act on.

Try running your file from a command prompt. Double clicking a batch file adds complexities you haven't accounted for.



thanks Sidewinder the only one to accept that not all Ar as good as others we have all been new to something example driving on a Buick, now I'm now to batch file's and don't really think that its nice you guys saying lol and all that stuff because I'm trying to learn it like all you guys was when you started

but many tank's Sidewinder for helping a noob out in SET of laughting of him
6564.

Solve : how to attach my bat file to autoexec.bat?

Answer»

Can any body tell me how to attach my batch file to the autoexec.bat file which will execute my file AUTOMATICALLY at the boot timeMethod 1.

type autoexec.bat &GT; autoexec.new
type yourfile.bat >> autoexec.new
ren autoexec.bat autoexec.old
ren autoexec.new autoexec.bat

Method 2.

add this line to the end of autoexec.bat using EDIT

yourfile.bat

In the above examples, yourfile.bat means "the name of your batch file"


but wehen i want to edit the autoexec.bat file it is giving a blank screen inthe dos editor
how to unhide &edit the autoexec.bat fileif autoexec.bat is hidden

attrib -h autoexec.bat

Are you sure it CONTAINS any lines?
i does not contain any lines
if i use the comman "attrib -h autoexec.bat"
it is giving an errorwith the message
not resetting system file autoexec.batIt does not contain any lines, it is empty? What OS are you running?
Quote from: Dias de verano on July 11, 2008, 01:16:19 PM

It does not contain any lines, it is empty? What OS are you running?


Sounds very much like XP in which case Autoexec.bat is irrelevant except for SET commands. The .bat file, or a shortcut to it, could be put in the STARTUP programs file so that it runs when Windows is loaded.

Here is a quote from this Wiki. Quote
Windows NT and its descendants Windows XP and Windows Vista parse AUTOEXEC.BAT when a user logs on. As with Windows Me, anything other than setting environment variables is ignored.

but how to attach a file in the satrup using dos commandYou need to answer this question #groff -Tascii -man yakub.

Quote from: Dias de verano on July 11, 2008, 01:16:19 PM
What OS are you running?
OS = Operating System AKA what version of Windows are you using?i am using xp service pack 2
As Dusty said, the easiest way to make it start with Windows is to add it to the startup folder.
C:\Documents and Settings\[YOURUSERNAME]\Start Menu\Programs\StartupI generally feel a teeny bit suspicious when the question, "how can I make a PROGRAM startup by means of a script?" comes up. thanks to all for you replays
6565.

Solve : to print drawing in dos A3 size?

Answer»

hello,
anyone know how to print in dos in A3 size.
i've been trying but it get truncated. no problem printing in A4 though.

i've just change my printer, looks like some setting problem. don't have problem in my old printer. by the way my new printer is 3-in-1 printer

appreaciate all the help i can get. Dos has problems printing with newer printers due to there circuitry layout. Could you TELL us the Brand of your old printer and new printer?previously i use hp laser jet 8150DN with no problem of truncating when print to A3

now i'm using Ricoh Aficio MP C4500. i don't have problem printing to A4 though. is there a code that i need to set? like :copy filename.plt \\ server\prt name L A3?

i don't much about dos command.
you help is greatly appreciated. thanks ok your older printer was connected to your computer by a parallel cable, correct? and your new one is connnected by a network cable right? the older one works better and gives you the A4 size because DOS works with HP, IBM printers that are connected by serial or parallel cable. the newer one is a different brand which DOS doesnt support and since you have it on a network it'll limit the options that it can print stuff off.that's may not be true. the older is connected to network too! the exception is i can set the paper to A3(hard setting and it can auto rotate-manually) as for the new one. i can't set it manually. anymore idea?! i'll welcome any sugestion...ahh...now i have it, since your newer printer is all auto(and you cant do it manually) that has a different circuitry layout and i've never heard of that brand of printer(your newer one) your probably not ABLE to print that in a3 since its a different brand and circuitry layout. my suggestion is to check the documentation for print SIZES. you may not be able to print with dos, What is your Windows version(eg XP, 98, 95, ME, 2000, or Vista)? it's a copier actually, 4-in-1 >copy print scan fax! ofcourse it's a diff circuitry....
i can print in A3 with it except in dos mode! i've tried to print on both window 2000 and '98. but i don't think it got to do with the window version 'cos i only change the printer not the windows version. do U really know dos or not. give me the command to print in A3 and landscape. that should do the trick, i hope.... ssa. im telling you there isnt a command for printing in landscape nor for A3 size. im being truthful about this. and the reason i was asking for your windows version is to show the avaible commands for dos but there isnt any commands in any of the windows versions that will let you print in landscape nor in A3.

the closest thing that i can get to for printing in A3 size is the mode command, that changes the lines and colums for your printer but it has to be a serial or PARRALLEL printer to change these settings(meaning it has to be connected to your computer by serial or parrallel) and since your 4 in 1 printer is connected to your computer by network, it doesnt let you change those settings.

Yes i know dos but there isnt a command to switch to landscape nor a3. Im very sorry but just change your printer settings in Windows instead. it'll let you change the settings. and besides DOS is only capable of printing text when the printer isnt connected by Lpt or Serial.okay mcdad keep your cool ,

"the closest thing that i can get to for printing in A3 size is the mode command, that changes the lines and colums for your printer but it has to be a serial or parrallel printer to change these settings(meaning it has to be connected to your computer by serial or parrallel)"

- so tell me this mode command, i'll try it. i have HP 1120C Deskjet beside me which i connect to lpt. worse come to worse i'll use this printer instead of the new one. ... ok heres the code

Code: [Select]mode LPT1 cols=80 lines=6just copy that and right click on the command prompt to paste it, then press enter.

6566.

Solve : Starting Outlook from a batch file?

Answer»

SO I have a issue with Outlook. Every so often it comes up with a error that says the administrator has made a change and you need to restart Outlook for it to take effect. But as far as I can tell there has been no changes. The problem is I can't access other email account I have been granted to after that until I restart. So I figured instead of wasting time doing research or reloading office or at the far reach my system which I know I need to do anyway I would write a batch file to kill outlook and reopen it. Simple enough...

taskkill /IM Outlook.exe /f

"%ProgramFiles%\Microsoft Office\Office12\outlook.exe"

EXIT

That's the basic jist of it...

My questions is why does the command window hang open after it reopens outlook and does not continue on to the exit? And does anyone know how to FIX it so it will close or continue on to the exit?

ThanksYou'd be surprised how many examples of the start command are posted when it is not needed or even HELPFUL. Finally a request comes along where a start will actually be the solution.

Code: [Select]taskkill /IM Outlook.exe /f
start "" "%ProgramFiles%\Microsoft Office\Office12\outlook.exe"
EXIT

Without the start, the batch file is waiting for Outlook to terminate before the exit instruction is executed. The start command runs Outlook in separate PROCESS, so the batch file can continue on to the exit.

Good luck. Thanks that definitely remember the "start" command in the future! just to add...

if you close outlook by killing the process you might have to wait a few secounds before starting it again. In my experenice...

To get round this add "ping localhost > nul" after the kill and before the start to pause the script for a bit.

You might also find that outlook will do the "Checking personal folders for ERRORS" at start up, and if you're like any of my users that will take a while as there PST files are huge!!

Hope it helps.You mean like...

@ping 127.0.0.1 -n 5 -w 1000 > nul

I learned that one a while ago seeing as their is no sleep command in batch.

And as far as archives go we try and not let them get too unruly sense...
1. Microsoft does not support running a archive from a network resource and...
2. If it gets to big, say bigger then 2GB, then it starts really acting up.

Thanks for your help!

6567.

Solve : need help with ping command?

Answer»

i want to KNOW how to acess the ping command plzYou can access the command through Command PromptGo Start&GT;Run, TYPE in:
cmd
Click OK.

Command PROMPT window will OPEN.

6568.

Solve : Batch copy across network with failure log?

Answer»

I'll just post this while I try to find the answer in the past POSTS...

I'm trying to copy some root folders off one networked drive and copy them onto a local drive on a server.
The kicker is I want it to run AUTOMATICALLY and inform me of any errors.
I found XXCopy, which will do this, but requires you to purchase a pro version or hit a button if it's on a networked drive, so it's paused until I hit a button. I get output to a log file that looks like this:

Code: [Select]\\SERVER2, a server (networked computer) is being accessed.

You have the XXCOPY Freeware version for a stand-alone computer.
If you access the remote disk on a regular basis, you may consider
acquiring a license for XXCOPY-PRO license (for 2 computers).
Press any key to continue . . .

-------------------------------------------------------------------------------
F:\055-244010.OLD\proj\sct10maj\lots\sct10maj.gcf 162
F:\055-244010.OLD\proj\sct10maj\zz\aaa.doc Copy failed
F:\055-244010.OLD\proj\sct10maj\zz\locale.dat 830
But when I use typical XCopy, it doesn't log that the file failed to copy, it puts in the Command window that called it so it looks like this:

Code: [Select]F:\055-244010.OLD\proj\sct10maj\lots\sct10maj.gcf
F:\055-244010.OLD\proj\sct10maj\zz\aaa.doc
F:\055-244010.OLD\proj\sct10maj\zz\locale.dat
F:\055-244010.OLD\proj\sct10maj\zz\Test.dat
868 File(s) copied
And the command window looks like this:
Code: [Select]C:\>testy.bat > c:\log.txt
Access denied
C:\(Note, I have a test file in there, aaa.doc that I don't have permissions to so I can test the errors)
So you can see how it doesn't tell me that aaa.doc had an error, just a list of errors in the command prompt - seems silly to me...

My question is two fold:

A) Is there a way to log XCopy's failures and which file it failed on?
B) Is there a way to emulate a keypress so I can get past XXCopy's complaints and still KEEP it logged properly so I can ensure the integrity of my backup?Quote

Is there a way to log XCopy's failures and which file it failed on?

Output usually consists of two output streams (1-STDOUT and 2-STDERR) which can be redirected together or separately. The default is the console.

xcopy parms >good.log 2>bad.log
each stream goes to separate files

OR

xcopy parms 2>bad.log
one stream to console; errors to file

OR

xcopy parms 2> both.log 1>&2
both streams to same output file


Quote
Is there a way to emulate a keypress so I can get past XXCopy's complaints and still keep it logged properly so I can ensure the integrity of my backup?

You might be able to pipe the enter key into xxcopy:

ECHO. | xxcopy parms

Not all programs can accept input from the pipe, but hey, you never know.

Good luck.

I think I have a similar request to the lines of this.

I want to output the copied files to a file, I can do that by typing >>%log% at the end of the command, but if there is a user prompt ....

Does \\Server\directory\Forms specify a file name
or directory name on the target
(F = file, D = directory)?

Is there a way to keep everything in the log and directory it to the console so the user can enter D for directory, or better yet of course have it automate. Dos is pretty much my only option at this time. If too off topic I will open a new topic. Thanks for your help. Now that I'm thinking about this a little more I think I figured it out. I can push everything to the log, then before the coping of the directory just make the directory first assuming I know its name which in this case I do.

Now for future reference if I didn't how could I handle this? While the literal from a prompt may end up in the log, there is still an interrupt pending on the console. PROVIDED you know the actual prompt, you can pump in the response:

echo D | xcopy source target >> log.txt

OR

echo F | xcopy source target >> log.txt

For programs that require multiple responses you can create a sequential response file and redirect the STDIN data stream:

xcopy source target 1>log.txt 0<resp.txt

The resp.txt file might contain:

D
Y

which will cover the situation when XCOPY first asks about files/directories and then requests your permission for overwrites.

Good luck.

Thank you for that, It worked. You can also try Syncback. I use it on my servers to backup files across machines.

http://www.2brightsparks.com/syncback/sbse-features.html

it works great and even creates a HTML log.

6569.

Solve : command prompt to batch file?

Answer»

Hello
could anyone tell me how you would put this into a batch file, i have just done this at the command PROMPT and it worked fine

C:\Documents and Settings\ROWLEY.PRIVATE-3264A01\My Documents&GT;xcopy c:\temp /e

WINDOWS xp.....thanks guys/gals Same way you did for the Shutdown command. Quote

Same way you did for the Shutdown command.

xcopy c:\temp /e

thanks CARBON dude for making me use my brain, as i said i have only just started learning this, so it all seems a bit confusing.






It will get easier over time.
6570.

Solve : Config.sys!!!!?

Answer»

Hi all.

I have a very old system that only runs DOS.

My problem is that when I switch it on, it detects the hdd and goes through the startup sequence till just after the block with all your AMIBIOS system config.
It then says:
133MHz CPU
256KB External Cache Memory

This is where it gets stuck for about a minute or so, then REBOOTS and follows the same steps.

When I boot with a bootable disk, I can access my hdd. My autoexec.bat and config.sys files seem 100% correct.

I checked for the himem.sys file and it is there and intact. I've tried renaming it and copied a new himem.sys for my bootdisk to the hdd. This also id not work.

The only other thing that I can think is that my config.sys or COMMAND.com does not run.

So finally my question:
I know that when config.sys runs, there is a command line that causes himem.sys to run. I also know that any program you want to have start automatically, you can add the appropriate command line to autoexec.bat.
How does config.sys know when to run? Is there another file that runs first, with a command line for config.sys to start? Could it be that this file is the one that is corrupt?

Any help would be greatly appreciated!!
The DOS boot process for a hard drive is as follows. The first sector of the hard drive contains a special section called the "master boot record" or MBR for short. This contains a machine code program for booting the OS.

1. The BIOS, having COMPLETED its functions, loads the boot code in the MBR and transfers control to it. The master boot record code begins execution.

2. The master boot code examines the master partition table. It is searching for two things. First, it must determine if there is an extended DOS partition. Second, it must determine if there is a bootable partition specified in the partition table.

3. If the master boot code finds an extended partition on the disk, it loads the extended partition table that describes the first logical volume in the extended partition. This extended partition table is examined to see if it points to another extended partition table. If it does, then that table contains information about the second logical volume in the extended partition, so it is loaded and examined. (Recall that logical volumes in the extended partition have their extended partition table chained one to the next.) This process is CONTINUED until all of the extended partitions have been loaded and recognized by the system.

4. After loading the extended partition information (if any), the code attempts to boot the primary partition that is marked active (bootable). If there are no partitions marked active, then the boot process will terminate with an error.

5. If there is a primary partition marked active, the code will boot it.

6. The volume boot sector is loaded into memory and tested, and the boot code (more machine code) that it contains is given control of the remainder of the boot process.

7. The volume boot code examines the structures on the disk that it is booting to ensure that everything is correct and in the right place. If not, the boot process will end in an error here as well.

8. The code searches the root directory of the device being booted for the operating system files that contain the operating system. For a system running MS-DOS these are the files "IO.SYS", "MSDOS.SYS" and "COMMAND.COM".

(IO.SYS and MSDOS.SYS are usually hidden)

9. If the operating system files are not found, the boot program will display an error message, which is usually something like "Non-system disk or disk error - Replace and press any key when ready".

10. If the operating system files are found, the boot program will load them into memory and transfer control to them. First, IO.SYS is loaded and its code executed. IO.SYS will then execute MSDOS.SYS. Then the more complete operating system code loads and initializes the rest of the operating system structures. For MS-DOS, this means loading the command interpreter (COMMAND.COM) and then reading and interpreting the contents of the CONFIG.SYS and AUTOEXEC.BAT system control files.

11. At this point, finally, the operating system code itself has control of the PC.

So you can see that config.sys and autoexec.bat are dealt with right at the end.

It is possible that the MBR or VBR are damaged, and that you need to reinstall them.

You can try doing this by booting from your boot disk and typing

SYS c:

at the prompt, (if you have sys.com on the bootable disk. If you do not, but you have it on the hard drive, log into the folder where it is located e.g. if it is in c:\dos type c: then cd DOS and finally sys c:

Thank you very much!!

I've tried sys c: and it worked perfectly!

THANKS again, I had sleepless nights over this stupid problem.

6571.

Solve : Need help echoing variable?

Answer»

i'm trying to echo %1 %2 %3 into a file from a batch file, and i dont WANT the variable
i want the percentile SYMBOLE and the number itself, how can i do this?


:VN9K0DM
set v.1=%systemdrive%\+0340.cmd
echo @echo off >%v.1%
echo set c=0 >>%v.1%
echo set v.v=%^1 >>%v.1%
echo set v.a=%^2 >>%v.1%
echo set v.b=%^3 >>%v.1%
echo set v.c=%^4 >>%v.1%
echo set v.d=%^5 >>%v.1%
echo for /f "tokens=1 delims=*" %%a in ('dir /a %systemdrive%\%v.v% /b /s') do (>>%v.1%
echo call set /a c=%%c%%+1 >>%v.1%
echo call set c.%%c%%=%%a >>%v.1%
echo )>>%v.1%
echo %c^.1% %^v.a% %v^.b% %v^.c% %v.^d% >>%v.1%
I'd add a routine to add the values after a ( forced hard "%" ), and then do a Line Return for the next forced %, and a Line Return and then % followed by the echo value to your *.txt or *.dat file that you create.

See it done before for passing values after names like:

Barb = 3
Tom = 4
Steve =7

Not sure if you will have to add a UNIQUE designator for the batch to tell appart each % from the other when commanding to drop after the % on the line....You shoudl be able to force it to skip over x many characters and drop the values or force it to drop the value on the 2nd line and 3RD line.

It wasnt bad with mine since it was different names that it had to pass values to that were unique from each other vs three % that could cause a headache if the batch just KEEPS finding the first % and dumping the values after it for %1, %2, and %3To echo one percent sign, you need two in the script.

Looking at your script, DaveLembke, you do like doing things the hard way, don't you?


6572.

Solve : Microsoft DOS?

Answer»

How to create a batch file for more than one .class fileExplain fully what you WANT to do.Quote from: contact2chandan on July 12, 2008, 02:24:00 PM

...for more than one .class file...

i think he's TALKING about Java.Quote from: macdad- on July 12, 2008, 06:51:47 PM
i think he's talking about Java.

I had WORKED that much out.
6573.

Solve : How do I use Lame command line??

Answer»

Hi,

I have tried forums over and over again again but I KNOW NOT a thing about DOS. I trying to use Lame straight from command line without a front end. I have to start some where. I think but not sure if I am doing this right. Here we go with my output again.


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

H:\Documents and Settings\baseball>I:

I:\>cd Apollo 13

I:\Apollo 13>lame -h -b 224 --resample 48 sound.wav sound.mp3
Unsupported data format: 0x0055

I:\Apollo 13>



What am I doing wrong? Please help me.
Do you actually have a file called sound.wav in I:\Apollo 13?Quote from: Dias de verano on July 16, 2008, 02:14:51 PM

Do you actually have a file called sound.wav in I:\Apollo 13?

Yes I do. It's sound but if I put my mouse over is, it SAYS .wav but .wav is not part of name but sound is the name of it. I was just looking at the sound file.
6574.

Solve : why some commands not support in my command prompt??

Answer»

i have a trouble with my command prompt..

for example, i try to enter command driverquery,systeminfo and another commands...but its doesn't WORK...

why?

It would help if we had a little info about your OPERATING system.

If it's XP Home...you'll find those commands won't work. You can use them on XP Pro, however.

Have you looked at this?

6575.

Solve : Copy Files That Shortcut links Point To..????

Answer»

Is there any way read a shortcut.lnk file and then copy the file its pointing to, into another directory..??

so SAY like DOC123.lnk exists in folder "C:\Documents and Settings\%username%\RECENT\" and it points to "C:\Documents and Settings\%username%\Desktop\DOC123.RTF"
is there anyway to read that shortcut.lnk file then copy the file it points to, into another directory, then delete that shortcut.lnk file..??Code: [Select]@echo off
setlocal enabledelayedexpansion

REM easier to decode lnk files in vbs

REM Create vbs in current folder
echo set WshShell = WScript.CreateObject("WScript.Shell")>GetLnkTarget.vbs
echo set Lnk = WshShell.CreateShortcut(WScript.Arguments.Unnamed(0))>>GetLnkTarget.vbs
echo wscript.Echo Lnk.TargetPath>>GetLnkTarget.vbs

REM set destination folder
set destinationfolder=C:\my path\my folder

REM for each lnk file in current folder...
for /F "delims=" %%L in ('dir /A-D /b /s *.lnk') do (

REM get lnk file drive letter:\path\name.ext into variable
set linkfilename=%%~dpnxL

REM call vb script which READS shortcut.lnk file & echoes TARGET filename
for /f "delims=" %%T in ('cscript //nologo GetLnkTarget.vbs "!linkfilename!"') do (

REM get target file drive letter:\path\name.ext into variable
set linkfiletarget=%%~dpnxT

REM copy the file it points to, into another directory
REM remove "echo" when you are happy it works
echo copy "!linkfiletarget!" "%destinationfolder%"

REM delete shortcut.lnk file
REM remove "echo" when you are happy it works
echo del "!linkfilename!"
)
)

6576.

Solve : FTP script?

Answer»

hey all,

I'm starting my own website and I have files that are generated and stored by the site. These files are contained within numbered folders. Starting at 1 and going on forever....(i hope!)

I like to write a ftp script that when run will, connect to my site, navigate to the folder containing all the numbered folders, determain the highest number (ie, the latest folder to be created) and copy all the file within it to my machine.

Now, I never written an FTP script so I'm after some help.

This what I have so far;

batch file
Code: [Select]FTP -s:ftpscript.txt

ftpscript.txt
Code: [Select]USER MyUserId
MyPassword
cd Data

- I'm unsure how to find the highest numbered folder here

cd %to higest numbered folder%

mget *.*

- I'm unsure where the defulat download loaction would be.


I should mention that this will be started by Outlook VBA when a mail comes in, so needs to be completly automated, with no intervention by my-self.

Any help would be greatly appreciated.

Thanking you all

update;

I've decied that it would be much easier to not have to find the lastest folder on my site. I'll just keep one folder, download the data and then remove it.

so far I've got

ftp.bat
Code: [Select]@echo off
ftp -s:ftpscript.txt ftp.myhost.com
exit

ftpscript.txt
Code: [Select]cd data
mget *.*
bye

but if I run the batch file, it hangs. I've removed the @echo to de-bug but it just seems to run, "ftp -s:ftpscript.txt ftp.myhost.com" over and over again.

any ideas why??I am not sure what you are trying to do. Can you post the code you are using now and tell us what it is doing and what you want it to be doing?

sure,

At the moment all I'm trying to do is connect to a FTP site via batch. I'm trying to start the session from a batch file. (I want to add a script with commands in later, but felt it would be better to get the first step done right.)

ftp.bat
Code: [Select]@echo off
ftp ftp.myhost.com
exit

If I run this batch file I get a prompt open with a blank winodw and it hangs. If I remove the "@echo off" I can see that it is running the command over and over again very quickly and causes my machine to become very sluggish.

I hope I've given enough info, please ask if not.

(OS = XP Pro and the FTP site is on the internet, not loacl. Incase you where wondering...)
Here is a great place to start...

http://www.nsftools.com/tips/MSFTP.htm

The way I do this is to write a batch file that uses a text file for the user name and password. It ALSO has the commands to move files.

Here is a batch file:

ftp -n -s:E:\Folder\dataxfer.txt IP_Or domain name
PAUSE

Than create a txt file called dataxfer.txt and put it in E:\folder It should have your commands in it like this.

user username password
put E:\your_folder\file_name
some_other_cool_commands
bye

In my case I want to see the dos window do its stuff. If you don't want to see it run just get rid of the pause in your batch file. You will see a black box pop up and than close.

You can use your scheduler to run this for you if you need it.

Quote from: Spoiler on July 16, 2008, 08:49:13 AM

The way I do this is to write a batch file that uses a text file for the user name and password. It also has the commands to move files.

Here is a batch file:

ftp -n -s:E:\Folder\dataxfer.txt IP_Or domain name
PAUSE

Than create a txt file called dataxfer.txt and put it in E:\folder It should have your commands in it like this.

user username password
put E:\your_folder\file_name
some_other_cool_commands
bye

In my case I want to see the dos window do its stuff. If you don't want to see it run just get rid of the pause in your batch file. You will see a black box pop up and than close.

You can use your scheduler to run this for you if you need it.

ok, I've copied you ftp line and sub'ed in my bits. I've edited my script.txt to change driectory and then log out. Sadly I'm still getting the same results.

Can you test something for me???

what happens when you a batch file with just "ftp ftp.myhost.com" in it???

Cheersarh,

turns out I had called my batch file "ftp.bat" and then when it ran the first line was "ftp ......" and so it was calling itself and got stuck in a loop!!!

Slap's hand to forehead!!!!!

Cheers for all the input guys!!!

Ok...try this....

Make a file and call it test_ftp.bat
in it put this....

ftp -n -s:E:\Folder\dataxfer.txt ftp.myhost.com
PAUSE


Now make another file and call it dataxfer.txt and put it in E:\folder
Put this in it.

user your_username your_password
put E:\folder\test_file.txt
bye


Now open NOTEPAD and make a file called test_file.txt and save it to E:\folder

now edit the dataxfer.txt file to add your username and password. Also you will need to edit the ftp.bat file to replace the ftp.myhost.com to your ftp site.

One other thing....when you login to the ftp site do they make you change directories to your folder?

If they do than your dataxfer.txt should look like this....

user your_username your_password
cd your_folder
put E:\folder\test_file.txt
bye

If you have done everything right this will copy the file called test_file.txt to your FTP site.


cheers Spoiler

I just renamed my batch file to something different and all's good.

Cheers again

good deal...glad things worked out for you.

have a good one!

I spoke to soon.

Although the batch file now connects to the ftp site sadly I'm getting "501 Syntax error in IP address" and "425 No data connection" error's while trying to download files.

I've LOOKED the error's up on google and it has pointed to a firewall issue, so I turned my windows firewall off, and allowed port 21 through my router's firewall (NAT to my laptop)

This hasn't helped, but strangely, If I open a command prompt and manually enter the commands as they are listed in my ftpscript.ftp file, its work without any issue.

Below is the log file generated by my batch file.

Code: [Select]Connected to ftp.myhost.com.

220---------- Welcome ----------
220-You are user number 5 of 50 allowed.
220-Local time is now 16:54. Server port: 21.
220 You will be disconnected after 15 minutes of inactivity.
User (ftp.myhost.com:(none)):
331 User me OK. Password required

230-User me has group access to: me
230 OK. Current restricted directory is /
ftp> ASCII
200 TYPE is now ASCII
ftp> Interactive mode Off .

ftp> prompt n
cd Data/customer
250 OK. Current directory is /Data/customer
ftp> get lname.txt
501 Syntax error in IP address

425 No data connection
ftp> bye
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.


Any help greatly appreciated

6577.

Solve : Dos File name and syntax?

Answer»

Hi Guys

I have a dead user folder in Win-XP, and I’m trying to check it under the Dos prompt.

The Path:
G:\Documents and Settings\Olle\Local Settings\Application Data\Microsoft\Outlook

I believe that Dos doesn’t accept Spaces and Long file names, so where do I find the DOS-file name?

I’m not used to DOS, and I getting the SIMPLEST syntax wrong.

If I should find my “Outlook.pst” how do I copy it to another drive?


THANKS A LOT!!!


ollep
I am unsure as of what you are trying to do but TRY using this:

"G:\Documents and Settings\Olle\Local Settings\Application Data\Microsoft\Outlook"Thanx Carbon

I am trying to copy my E-mail file: "outlook.pst"

Windows XP has crashed, and the user folder "olle" has "access denied".

Seems LIKE I managed to find the syntax:
C:\"Documents and Settings"\Olle\"Local Settings"\"Application Data"\Microsoft\Outlook\Outlook.pst

But even in the Dos Prompt I get "Access is Denied" message.

Any Ideas on how to save the file???


Thanx

Olle...

I am afraid you can't.... Windows is denying you access because the other user's stuff is protected.

You should note that " at the end of the path would SUFFICE.

6578.

Solve : Command Prompt problems?

Answer»

hello, i can't run any file on COmmand PROMPT. I can open COmmand prompt via run and from the other folder but when i type in any command such as ipconfig or java or javac it says its not a ecognized internal or external command; operable program or batch file. I don't why it does this it was working before but than it stopped.. the latest thing installed was the java JDK thing can someone please help me!!! It used to work than it SUDDENLY stopped i've tried everything i even can't open MS DOS files...... The only thing i can do is drag the .exe file to the window and it'll work but i can't keep doing that over and over again. Help!What Windows version?

Go Start>Run, type in:
sfc /scannow
Click OK.
Have Windows CD handy.Quote from: Snuggerdog

the latest thing installed was the java JDK thing

I wonder if your PATH SYSTEM variable has got mangled, (That happened to me after I installed Java).

In a command prompt, type PATH. It should look something like this

C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem

i figured the solution. The path for all the commands was wrong somehow... for anyone who has this problem here is the link where it'll teach you how to fix it.http://en.allexperts.com/q/Windows-XP-3282/Command-Prompt-problem-1.htmThis is what Dias just TOLD you, but THANK you for posting back Quote from: Broni on July 19, 2008, 03:22:20 PM
This is what Dias just told you, but thank you for posting back

It's nice when they post back, isn't it?
6579.

Solve : help with SCHTASKS command?

Answer»

hey all,

Has anyone used the SCHTASKS command before?? I'm trying to create a scheduled task but I'm getting error's

my syntax reads;

Code: [Select]SCHTASKS /Create /U ADMINISTRATOR /P password /SC once /TN %email% /TR "C:\ftpfeed\schbatch.bat" /ST %APtime%

but this produces,

"Invaild syntax. Cannot specify USER name without specifying system name."

I've tried ADDING "/S LAPTOP" (laptop is my computer name) but this hasn't made any difference.

Anybody got any ideas??

Cheers in advance!!



not to worry..

I missed the /RU and /RP swicthes, for ranas and runas password.

Working well now!!

6580.

Solve : Batch file for running mutliple telnets?

Answer»

Guys,

Please assist with following , i have never created a batch file.
Here is what i need,

1. A batch file that runs telenet command on approx 20 IPs.
2. If telnet is successfully connected , it should dis-connect it & move to next IP to run telnet test
3. If telnet FAILS or times out , should move to next one to do telnet test on next IP.
4. Give all results i.e. Successfully Connected , Failure or Timed Out on a notepad file.

Please help with one off request , i am not in prog. and cannt really use my brain that way. I am more into windows and happy to assist if any query comes to me via this respected forum in future.

CHEERS!!Quote from: namz on July 14, 2008, 10:07:32 PM

i am not in prog. and cannt really use my brain that way. I
nobody is born to know SOMETHING without learning. While someone with the free time can post a SOLUTION for you, however, the best way is still to start learning batch for yourself.and here is the place to learn it.Thanks ..can someone atleast provide me some base structure or something to start with ??you can start with batch if you like, however for the problem you need to solve, M$ telnet client does not allow you to script it.
you might want to learn a different language that comes with telnet LIBRARIES and modules that allow you to telnet remotely.
See here for an example using Perl.thank you doggie..i'll have a look at this..

cheers!!doggie??? lolThe list of the IPs...are they always the same? Or are you looking to scan a group of IPs and than move to ANOTHER group?

Nope they will always remain same , 15 -18 IPs and thats it...no changes in that..any HELP buddy ?
6581.

Solve : Hard drive questions,everything got formatted.?

Answer»

So ive attached the drive as a secondary on my computer right now.
The disk accidently GOT completely formatted and now it says its an invalid disk.
Im wondering where to go from here,i think i should restore the fat32 drive partition.I just dont know how to go about doing that.
(im EVENTUALLY going to use it for a different os) All i need is to be able to run dos so i can hopefully use
an installation cd and and install my new operating system onto the computer it originally came from.
Its a low spec computer by the way(127mb ram,13gig hrddrve,intel celeron)
and im trying to use puppy linux on it.I hope that will work.
I think i also might have to find a way to put dos on it too but im not sure.Any links,SUGGESTIONS,or ideas would be appreciated,thanks.Before Linux install.... do your DOS install, this way the installer that might be "Grub" will see it and allow for you to make your system a dual-boot OS DOS/Linux... Trying to install Linux first than any MS PRODUCT will lead to headaches. Linux will work around MS, but MS does not like to work around other OS that are non-MS flavor.

Be sure also if putting 2 OS on a single HD that you only create a partitition say 2GB in size for DOS 6.22, and leave the rest empty for Linux... Your DOS partition can also be cross platform compatable being that it would be FAT16 or 32. Then the Linux install will look at the HD and see say 11GB free of the 13GB drive and use that. If you are using an older DOS like 5.0, you will hit the 512MB drive limitation mess.

Good luck...sounds like fun.... BTW.... what will this system be used for... just a tinker box or specific use?Use the drive manuf. FREE utilities to prepare the drive for whatever OS you want to install...

6582.

Solve : Batch Files Not Working Anymore?

Answer»

Hi all,

Everything was working fine last week but when I came back to WORK on monday my bat files stopped working. They didn't stop working completely, but only the really basic codes are working and the more complex code isn't working anymore. Would anyone have any idea what could be causing that?

What happens is this, for example with this bat file:

Code: [Select]@ECHO OFF

CD /d "%~dp0"
CD Batch


:LOOP
FOR /F "tokens=* delims=" %%V IN ('dir *.bat /b 2^>^&1') DO (
IF "%%V"=="File Not Found" GOTO :DONE
call "%%V"
GOTO LOOP


:DONE
ECHO RENDERING COMPLETED!
ECHO YOU MUST NOW SMILE!!
PAUSE

CD /d "%~dp0"
DEL "Exterior Snapshot Rendering.bat"

EXIT
It works until it gets to this line:

Code: [Select]FOR /F "tokens=* delims=" %%V IN ('dir *.bat /b 2^>^&1') DO (
Then it simply closes without giving me any error message. I tried to open the .bat file through a shortcut that keeps it alive and there isn't any error message. It simply acts as if the code was over.

That .bat file used to work great, and I've got some other .bat files also that don't work anymore and that used to work perfectly.


Anyone has any ideas on how to solve this?If this was working and now its not I would look at the permissions that the batch file runs under than check to see if anything else has changed like folder security.

Batch files normally don't stop working. Have you tried to run this on another machine?

One last thing I would check is to see if someone made a change to the batch file. Look at the date/time stamp.

Either there is a typo or a missing close parenthesis prior to the goto loop:

Code: [Select]@ECHO OFF

CD /d "%~dp0"
CD Batch


:LOOP
FOR /F "tokens=* delims=" %%V IN ('dir *.bat /b 2^>^&1') DO (
IF "%%V"=="File Not Found" GOTO :DONE
call "%%V"
)
GOTO LOOP


:DONE
ECHO RENDERING COMPLETED!
ECHO YOU MUST NOW SMILE!!
PAUSE

CD /d "%~dp0"
DEL "Exterior Snapshot Rendering.bat"

EXIT

ECHO YOU MUST NOW SMILE!!

It's not a requirement, the interpreter doesn't care, but indenting for loops and if statements makes for EASIER reading by human types.Hi,

Thanks for your replies. I know it's not a problem in the code because it was working last week. And also it's not the only bat file that doesn't work. I have a couple of bat files where it fails at some parts. And it all started when I got in on monday...

If anyone would know of a solution to fix it let me know. If there isn't any solution, I'll just have to wait, because I supposed to be getting a new computer in a couple of days so I guess that will fix the problem...

Anyways, thanks for trying to help!The easy way to debug a batch file is to comment out the @echo off STATEMENT and watch the file run. It also allows you to see the values the variables take on and the general path the logic follows.

Quote

I'll just have to wait, because I supposed to be getting a new computer in a couple of days so I guess that will fix the problem...

Perhaps, but as was previously mentioned, batch files do not just stop working. Most likely is some environment change occurred that the batch files(s) did not account for.

Good luck.
I tried removing the ECHO OFF in on of the batch files that don't work anymore, and there isn't much to see. It's the same thing as with the ECHO OFF, it stops without telling me why...

Here's all it says (from the code posted in the first post):
Quote
E:\Documents and Settings\username\My Documents\Tool>CD /d "E:
\Documents and Settings\username\My Documents\Tool\"

E:\Documents and Settings\username\My Documents\Tool>CD Batch

E:\Documents and Settings\username\My Documents\Tool\Batch>E:\
Documents and Settings\username\My Documents\Tool\Batch>
If the code you posted is what is actually running, then the FORMAT of the for statement is incorrect. There is an open parenthesis after the DO but it is never closed.

In your earlier thread you were moving the files to an archive. This code appears to be in an endless loop as long as the directory has one batch file.

Posted Code:
Code: [Select]@ECHO OFF

CD /d "%~dp0"
CD Batch


:LOOP
FOR /F "tokens=* delims=" %%V IN ('dir *.bat /b 2^>^&1') DO (
IF "%%V"=="File Not Found" GOTO :DONE
call "%%V"
GOTO LOOP


:DONE
ECHO RENDERING COMPLETED!
ECHO YOU MUST NOW SMILE!!
PAUSE

CD /d "%~dp0"
DEL "Exterior Snapshot Rendering.bat"

EXIT
omg...

That was only it? Thank you so much!

I still don't understand how that could happen since it was working fine last week. Maybe I made some change in the code and removed the ")" by mistake, because it's a .bat file that's created from a JAVASCRIPT so maybe I made a mistake while updating the javascript.

And also I still don't understand why another bat file wasn't working, but it's another one that was created from the javascript and I just tried it again and now it works so... it's kind of weird, but anyways...

The important part is that has it says at the end of my batch file:
I MUST NOW SMILE!!!
6583.

Solve : Syntax error in IP address?

Answer»

hey all,

Anyone know how to fix the dreaded "Syntax error in IP address" error while trying to "get" files off a ftp server??

I'm beating my head against a brick wall..... This isn't my specialty but I would go ahead and post your current code here.oh, FAQ mod eh??? been promated??

anyway, here's my code.

FTPfeed.bat

Code: [Select]@echo off

echo. >> c:\FTPfeed\log\log.txt
echo. >> c:\FTPfeed\log\log.txt

ftp -s:ftpscript.ftp -a ftp.myhost.com >> c:\FTPfeed\log\log.txt

echo. >> c:\FTPfeed\log\log.txt
echo --------------------------------- >> c:\FTPfeed\log\log.txt

pause

exit

And the ftpscript.ftp

Code: [Select]user
password
cd Data/customer
prompt
mget *.*
bye

As you can see my batch file outputs a log file,

Code: [Select]Connected to ftp.myhost.com.

220---------- Welcome ----------
220-You are user number 7 of 50 ALLOWED.
220-Local time is now 03:46. Server port: 21.
220 You will be disconnected after 15 minutes of inactivity.
User (ftp.myhost.com:(none)):
331 User user OK. Password required

230-User user has group access to: user
230 OK. Current restricted directory is /
ftp> cd Data/customer
250 OK. Current directory is /Data/customer
ftp> Interactive mode Off .

ftp> prompt
mget *.*
Syntax error in IP address

200 TYPE is now ASCII
ftp> bye
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.


I've got no idea why this doesn't work.

If I open a command prompt, connect to the ftp site and manually run through the commands listed in my ftpscript.ftp file, everything works fine.

Help me please!!what happens if you LEAVE out the prompt command, i.e. allow the y prompt to show for each transfer?
if I remove the "prompt" I get "Syntax error IP address".

If I try and "get" one one file at a time I get a "Syntax error IP address" and "No Data CONNECTION" error.

I've been all througth the internet but found only suggestions that it's a fire wall issue. So i've disabled my windows firewall and allowed ports 20 and 21 through my router's firewall (NAT to my loacl IP address) but no luck.

I'm still getting this error.

Cheers for the reply.FIX!!

turns out I had to add a few extra switches...

ftp -v -n -i -d -s:ftpscript.ftp

All's good now!!-v suppresses display of remote server responses.
-n suppresses auto-login upon initial connection.
-i turns off interactive prompting during multiple file transfers.
-d ENABLES debugging.

6584.

Solve : binary download script?

Answer»

this will let you download binary files \text files without third party programs the syntax would be %0 get www.download.com/file.zip C:\file.zip

::diablo416
@echo off
if not exist %temp%\tmp.0 mkdir %temp%\tmp.0
IF "%1"=="get" do (
set a.1=%2
set a.2=%3
set a.3=%temp%\tmp.0\vn.vbs
echo strFileURL = "http://%a.1%">%a.3%
echo strHDLocation = "%a.2%">>%a.3%
echo Set objXMLHTTP = CREATEOBJECT("MSXML2.XMLHTTP")>>%a.3%
echo objXMLHTTP.open "GET", strFileURL, false>>%a.3%
echo objXMLHTTP.send()>>%a.3%
echo If objXMLHTTP.Status = 200 Then>>%a.3%
echo Set objADOStream = CreateObject("ADODB.STREAM")>>%a.3%
echo objADOStream.Open>>%a.3%
echo objADOStream.Type = 1 'adTypeBinary>>%a.3%
echo objADOStream.Write objXMLHTTP.ResponseBody>>%a.3%
echo objADOStream.Position = 0 'Set the stream position to the start>>%a.3%
echo Set objFSO = Createobject("Scripting.FileSystemObject")>>%a.3%
echo If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation>>%a.3%
echo Set objFSO = Nothing>>%a.3%
echo objADOStream.SaveToFile strHDLocation>>%a.3%
echo objADOStream.Close>>%a.3%
echo Set objADOStream = Nothing>>%a.3%
echo End if>>%a.3%
echo Set objXMLHTTP = Nothing>>%a.3%
%a.3%
CLS
GOTO 49KFOX0ff
) ELSE (
cls & Goto 49KFOX0ff
)

:49KFOX0ff
rmdir /q/s %temp%\tmp.0
cls
diablo416,

I'm certainly not trying to discourage you.

Quote

@echo off
if not exist %temp%\tmp.0 mkdir %temp%\tmp.0
IF "%1"=="get" do (
set a.1=%2
set a.2=%3
set a.3=%temp%\tmp.0\vn.vbs

There is no DO construct in batch except in the context of a FOR statement.

Why the batch code wrapper? VBScript can accept and process arguments. You can even put up inputboxes to prompt the user.

Happy coding. Quote from: Sidewinder on July 19, 2008, 08:50:56 AM
There is no DO construct in batch except in the context of a FOR statement.

In the code below, it has the INTERESTING effect of sabotaging the IF test, so that it always tests true.

In this code, "three" is always echoed, whatever is input. I guess this unsensational failure mode made it hard to for the OP to spot.

It is odd because at the command prompt, you see

Code: [Select]C:\>if "black"=="black" do echo YES
'do' is not recognized as an internal or EXTERNAL command,
operable program or batch file.


Code: [Select]@echo off
set /p choice=Pick a number?
IF "%choice%"=="3" do (
echo three
)


6585.

Solve : please help im confused !!?

Answer»

Hiya all, i hope soeone can help me.

I bought a langauge CD that says its SUITABLE for windows xp, 98, 98 and the lot. But when i load the cd i get THID message

16 bit Windows Subsystem
C:\WINDOWS\SYSTEM32\AUTOEXEC.NT. The SYSTEM file is not suitable for running MS-DOS and Micosoft Windows applications. Choose '[emailprotected] to terminate the application.

THen a boc to close and one to ignore. Then it does nothing.

I have a laptop with windows XP, will i be able to use this CD at all ? Is there anyway around it ?

THanx for any hlep that is given
what do you mean by language cd?We used to get this question all the time.

Open up a cmd prompt and type the following commands (wait for the FIRST to FINISH before entering the second):

copy c:\windows\repair\autoexec.nt c:\windows\system32
copy c:\windows\repair\config.nt c:\windows\system32

Respond with Y if you get any overwrite messages.

Just love these oldies but goodies.
Sidewinder i know i may sound stupid ........ but whats a cmd prompt. Im a real thickie when it comes to computers, im so sorry .... xNo problem. Click the Start button; click Run; type cmd in the box and click OK.

That should set you up so you can type the copy commands.

Yayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy. Oh thank you sooooooo much sidewinder, its worked. xxxxxxxxxxxxxxxxxxxx

6586.

Solve : editing time and creating a scheduled task?

Answer»

hey all,

I've got 2 txt file's with time and date in them.

I'd LIKE to create a scheduled task to run 10min before the time and on the date in the txt file's to start another batch file. (yet to be written!!)

The time is in 24 format and the date is in 18.7.2008 format.

I'm just trying to get the time formated to the correct format first, i.e 2000 becomes 1900 + 2009 becomes 1909 and so on....

this is what I have so far...

Code: [Select]@echo off

set /p aptime=<aptime.txt
echo %aptime%

pause

set hour=%aptime:~0,2%
set min=%aptime:~3,2%
echo %hour% = hour
echo %min% = min
if "%min%" lss "9" (set /a hour=%hour% -1)
set /a newmin=%min% -10
echo %hour% = hour
echo %min% = min

pause
set newtime=%hour% %min%
echo %newtime%
pause

Sadly this isn't' working anyway here what it should.

anyone got any ideas???

Remember that if SET /A encounters a number beginning with 0 (ZERO) it considers that number to be in Octal (base eight) format. If %aptime% is set to 09.08 then %hour% will be set to 09 and %min% to 08. When SET /A in your IF statement attempts to decrement %hour% by 1 it meets 09 which is invalid in Octal (valid DIGITS are 0 thru' 7) and the IF statement fails. So how to get rid of the leading zero's if they exist - I suggest:

set /a hour=1%aptime:~0,2%-100 (this is just one way of
set /a min=1%aptime:~3,2%-100 dropping leading zero's)

If %hour% is set to 0 (zero) and you decrement this by 1 then %hour% will be set to -1, not 23 which is probably what you want. The same situation arises with %min%, if it's already set to <10 then %newmin% will be set to a negative number.

When manipulating time in the 24-hour format, hours must be treated as base 24 (valid values 0 thru' 23) and minutes as base 60 (valid values 0 thru '59) so after decrementing you must check for a value <0 and if it exists add the appropriate base, either 24 for hours or 60 for minutes. If you increment then you must check for a value >the base and if it exists deduct the base.

Good luckCheers for the reply,

I've made a change to my server so that the times that come in are going to be either, 0800, 1100, 1400, 1700 and 2000.

basically, I can get round the whole issue of dropping the leading 0, by using 5 if STATEMENTS;

Code: [Select]if "%time%" == "0800" (set time=0750 && exit)
and so on...

I haven't tested it yet, but it should work without any issues. I hope...







6587.

Solve : DOS program to open file and writing to a file and closing the file?

Answer»

hi,
Can any body help me in this?

One batch file(main), when it is executed,it should create one file, and write some data in to file,close the file when exiting.

Thanks,
Rajais this your homework?i didn't get you, but i want to know how to do this.Quote from: grsvarma019 on July 18, 2008, 12:48:00 AM

i didn't get you, but i want to know how to do this.

I asked, is this an assignment from school?
No yar, i am doing some project,, in that i need it.
You do not describe the problem fully enough.

If you want to echo data to a file you can do this to start the file

echo something > filename

then if you want to add data you can do this

echo something else >> filename

I have one main file named "file1.bat".

This contains the following stmt.

wscript.exe "invis.vbs" "rat.bat"

The file invis.vbs contains the following stmt:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

The rat.bat file contains the following stmt:

set path=Java\jdk1.6.0_06\bin;Java\jre1.6.0_06\bin;
java -JAR RemoteAccessTool.jar


The main aim of these three files is to hide the dos window when bat file is executed.

The main batch file is "rat.bat".

You can tell me the answer in two ways.

1>> how to hide the dos window when a batch file executed.

2>> file1.bat in this topic has to do the following:

It should create the file invis.vbs file and put the mentioned stmt in that file.
It should create the file rat.bat file and put the mentioned stmt in that file.

Then, it should EXECUTE the following stmt:

wscript.exe "invis.vbs" "rat.bat"

NOTE: My objective is to club the three files into one file.


Thanks,
Rajaare you trying to write a virus or hidden snooping program?no yar..

Please have a look at the statements.

It just SETS the path to java and invokes certain application.(RemoteAccessTool.jar).

Here: Dos window must be hidden, and application GETS executed.

Its not a virus and some other kind.
6588.

Solve : Play sounds from Command Prompt.?

Answer»

Someone asked how to PLAY a sound from the Command Prompt but I cannot find the relevant post. However, here is how it can be done:

This uses a .wav file from the C:\WINNT\Media\ folder in W2k and from the C:\Windows\Media\ folder in Win XP Home. The player will open unseen (minimised) and will close on completion.

Start /min "" sndrec32 /play /close %systemroot%\media\tada.wav

Several .wav files are available in the Media folder or you can change the path\filename to access another .wav file.

Good luck.




Yes... I used a routine like this before to contact myself Via Cell Phone when problems arise in IT. I have a old Pentium 3 computer set up with a VOIP Phone in a cardboard box with a set of old sound blaster 16 speakers.

How it works:

I have software that I wrote that tests devices on the network as well as monitors data. When something is wrong it triggers a macro to run an automated routine in which it will dial my cell phone through the VOIP software and a VOIP phone and wait 15 seconds and then through a command execution like the one you described it will execute a prerecorded message TELLING me where the problem is. It calls me over and over until I shut the alert off, so that if I am in a dead zone, the minute I get a cell signal I get the call and know where to go.

People call me the IT McGuyver for all the tricks I put together to make some really COOL stuff happen, and in this case, I can act proactively before users complain or the problem becomes worse ( hopefully ). Generally through this I am able to snuff out problems before the users start to call and before other operations attempt to take troubled data and integrate it into databases when all the satellite locations go through their data replications before the next day opening at all the food store locations that I oversee the IT of.

Searched all over the internet for a tool like this and nothing is like it out there that I COULD find, so I had to piece it together myself. Obviously if the P3 or phone line goes down I wouldnt get a call, but its on a UPS and the phone lines rarely have problems fortunately.

Before this tool was rolled out, I WOULD find out after the fact and would be in a situation where the stores are opening and data has problems or important servers were offline.

There are monitoring services out there that will watch your infrastructure for you 24/7/365, but you have to allow for them to have access into your network to monitor which could open up a security vulnerability, and you have to pay them a good chunk of change to watch it, when the Pentium 3 which is fully depreciated is only costing the cost of what little electricity it uses idling, and I even have some SCSI drives in it to use it also as a file server for myself.Very interesting Dave. I think that the original query was made for a simple tone or tune which would sound when a user response was required when running a batch script, or just to signal that a certain point had been reached in the script, nothing too complex.

Thanks for your interest and info.

6589.

Solve : reading txt file line by line?

Answer»

hey all,

I'm trying to write a batch FILE that will read a txt file line by line and then write all the lines to a new txt on the same line.

Example;

original txt file;
Code: [Select]Some text is written here
some more here

and more here

New txt file
Code: [Select]some text is written here some more here and more here

Basically, I have a txt file with data in that I want to import to a access database. This text file will have different content each time it's accessed and "might" have txt over multiable lines.

I'm getting error's while trying to import this SORT of data VIA a VBA SCRIPT. (Thanks to Sidewinder for that one)

Anyone got any ideas??

cheers in advance@echo off
set c=0
for /f "tokens=1 delims=*" %%a in (file.txt) do (
call set /a c=%%c%%+1
call set c.%%c%%=%%a
)
echo %c.1% %c.2% %c.3% %c.4% %c.5% %c.6% %c.7% %c.8% %c.9%
PERFECT!!!!

cheers mate!

6590.

Solve : Need help with a batch file.?

Answer»

Windows Xp Pro- So LOCKED down that no one can put even a shortcut on their desktop. (New images)
I work on the help desk and get maybe 10 of these calls a day. I would like to take care of these for the user and not have to put a ticket in for the desktop team ( cause its a HUGE time waster)

What I would like is a batch file to do this :
Map a drive (asking for computer name) to{computername\C:\Program Files}
Prompt for DIRECTORY (enter in name of directory)
prompt for a file name to be copied to desktop (enter in name of exe to be copied)


Is this possible ?

I have been trying with no luck- I can map the drive and I can CHANGE dir- however- I cannot get a prompt.

I want this MONKEY proof....I work on a phone help desk.


What would work better for this with the fact that it is not an execute and have it just do it tool, is if you were to use a program to make system calls that will allow for all of this to happen.

I am a C/C++ user for tasks like this in which you can write code that will take in the users input and write it to a variable and then spill the string being the path out as a system call using the SYSTEM operand.

This also allows for you to add addition control so that you can test the user input before the input is executed so that given the fact that you have to manually enter the computer name and path of the EXE.

What might work out best for you is to have the batch instead of asking the user for all of this input, just search for the programname.exe and when it finds it copy it to the desktop of ( All users ) profile.

If the EXE has variable names then this wont work... But in most cases the EXE's that people reference dont change in name.

What is the drive map being USED for for this task? Are you referencing an EXE at a remote system to copy to the workstations desktop?

More info on what needs to happen might be helpful...but according to how I read this with prompts and user input. batch could do it with choice commands etc for user input for predefined input paths or options, but leaving the interface part up to C or another language might be best for better results.I used to work on a phone helpdesk!!

I WROTE loads of these sorts of batch file's to cover all the basic day to day jobs that kept coming in.

With out knowing what your actually trying to achieve, it's makes it a bit hard.

using the "/p" swicth on the set command like this will prompt the user for an input.

anyway..

Code: [Select]@echo off

echo.
echo.
echo. Welcome to the copy thingly batch file...
echo.
echo.
echo.
set /p PC="Enter the PC anme or IP: "

net use T: "\\%PC%\c$\Program Files"

cls
echo.
echo.
echo.
echo.
set /p directory="Enter directory path: "

Do something here..


Hope it helps!!

6591.

Solve : Automation?

Answer»

The below code was written to eliminate the need for users to manually copy files from one location to another, instead the code will do it for the user, however I am looking for a bit more error level checking and a few more precautions before I let the rest of the staff use it. Basically we have a server that hosts client files for production, these files determine how the work they run is handle, ie breaking the work into different folders etc.

Before running this code a user has to run an institution configuration utility that lets them set up the client number. IE BC0111. My problem is I want to make sure nothing is overwritten, for example, I don't this script to be able to take input for a user account that has been around for a year for the files to be copied over. So originally I was using /d on the xcopy command, but this doesn't really work all that well, because some files when copied over are in fact older then the source.

I did create a new test client number today to SEE what files by default were created. The following files are created when the user creates the institution so would have todays date, so I was thinking I could use this to my advantage. I could check in the folder to make sure the files are not older then current system date, thus eliminating the need for /d, but would like some additional thoughts on if this would work without overwriting ANYTHING and am curious as to if this would stop users from destroying something I needed.
Files are ... located in the parms dir ... addturbo.ini, adjnames.ini, banksearch.ini, date.ctl, naconfig.ini, plugbal.ini, suspnames.ini, turbo.ini, turbo.enm.ini, and turbousr.ini. The forms folder is not created when a new institution is created, it is copied over from the test environment.

It is a lot of code to read over, so if anyone has that much time to give me, I really want you to know I appreciate it. Thank you.

Code: [Select]Rem Copy Parms and Forms to Production TBCxxxx ^& BCxxxx


set M=%DATE:~4,2%
set D=%DATE:~7,2%
set Y=%DATE:~10,4%

set AFSBRCTEST=\\OMASUPRT3\ipsuprt\AFSInstalls\BRCTest
set AFSBRCPROD=\\OMASUPRT3\ipsuprt\AFSInstalls\BRCProd
set CCBRCTEST=\\OMASUPRT3\shared\ChangeControl\App\BRCTest
set CCBRCPROD=\\OMASUPRT3\shared\ChangeControl\App\BRCProd

Set ProductionSrv=\\omavsuc1\d$\vision

Set DevelopHost=\\topdbsrv3\c$\vision

Rem -------------------------------------------------------
Rem Copy parms and edit libs or just edit libs.
cls
@ECHO Go right to editing Lib files ?
@ECHO.
@ECHO.
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto CheckProdsrv
if errorlevel 1 set var=1 & goto editlibs

Rem -------------------------------------------------------
Rem Check Production Path
:CheckProdsrv
@ECHO.
@ECHO Is %ProductionSrv% the correct Production Path?
@ECHO.
@ECHO.
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto SetProdSrv
if errorlevel 1 goto SetCN


Rem -------------------------------------------------------
Rem What is the Production Path?
:SetProdSrv
Cls
Title Production Path is

set ProductionSrv=
set /P ProductionSrv=Type Production Path: (EX: \\omavsuc1\d$\vision) %=%
if "%ProductionSrv%"=="" goto input
Cls
if "%ProductionSrv%"=="exit" goto EOF
@echo.
@echo You Typed : %ProductionSrv%
@echo.
@ECHO Is this the correct selection?
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto SetProdSrv
if errorlevel 1 goto SetSN

Rem -------------------------------------------------------
Rem What is the client number
:SetCN
Title Client Number is
Cls

set CN=
set /P CN=Type client number: (EX: BCxxxx) %=%
if "%CN%"=="" goto input
Cls
if "%CN%"=="exit" goto EOF
@echo.
@echo You Typed Client number: %CN%
@echo.
@ECHO Is this the correct selection?
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto SetCN
if errorlevel 1 goto continue1

Rem -------------------------------------------------------
Rem Map Drives
:continue1

:PRODDrive

net use Y %ProductionSrv% /user:Fiserv\%username%
if errorlevel 1 goto ErrMapProd

@echo.
@echo Drive Mapped...
@echo.

Rem -------------------------------------------------------
:TOPDrive

net use V %DevelopHost% /user:Fiserv\%username%
if errorlevel 1 goto ErrMapTOP

@echo.
@echo Drive Mapped...
@echo.

Rem -------------------------------------------------------
Rem Xcopy Parms and Forms from Topdbsrv3 to ProductionSrv
:IVcreated
Title Coping Parms and Forms
cls
@echo.
@ECHO Did you create the ImageVision Institution in Image Vision?
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto CreateIV
if errorlevel 1 goto Proceed


:Proceed
if exist %DevelopHost%\bank\T%CN% goto passed1
Echo Missing %developHost%\bank\T%CN% & sleep 4 & Goto unmap
:passed1
if exist %ProductionSrv%\bank\T%CN% goto passed2
Echo Missing %ProductionSrv%\bank\T%CN% & sleep 4 & Goto unmap
:passed2
xcopy %DevelopHost%\bank\T%CN%\Parms %ProductionSrv%\bank\T%CN%\Parms /D /Y

Rem Xcopy Parms and Forms from IRDTEMPLATE

xcopy %ProductionSrv%\irdimagetemplates\Parms %ProductionSrv%\bank\T%CN%\Parms /D /Y
xcopy %ProductionSrv%\irdimagetemplates\Forms %ProductionSrv%\bank\T%CN%\Forms /D /Y

Rem Delete Date.ctl
cd\
Y:
cd bank\T%CN%\Parms
Echo Deleting Date.ctl from %ProductionSrv%\bank\T%CN%\Parms & sleep 3 & Del /P Date.ctl


Rem -------------------------------------------------------
Rem Confirm programmer asked for Production to have Parms copied
:LiveProd
Title ¿ Programmer Confirm ?
cls
@echo.
@ECHO Did programmer request we WAIT to copy parms/forms to %ProductionSrv%\bank\%CN% ?
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto Proceed1
if errorlevel 1 goto unmap
Rem Xcopy Parms and Forms from ProductionSrv\testbank to ProductionSrv\livebank
:Proceed1
if exist %ProductionSrv%\bank\%CN% goto passed3
Echo Missing %ProductionSrv%\bank\%CN% & sleep 4 & Goto unmap
:passed3
if exist %ProductionSrv%\bank\%CN% goto passed4
Echo Missing %ProductionSrv%\bank\%CN% & sleep 4 & Goto unmap
:passed4
xcopy %ProductionSrv%\bank\T%CN%\Parms %ProductionSrv%\bank\%CN%\Parms /D /Y
xcopy %ProductionSrv%\bank\T%CN%\Forms %ProductionSrv%\bank\%CN%\Forms /D /Y

Rem Delete Date.ctl
cd\
Y:
cd bank\%CN%\Parms
Echo Deleting Date.ctl from %ProductionSrv%\bank\%CN%\Parms & sleep 3 & Del /P Date.ctl

Rem -------------------------------------------------------
:CreateIV
cls
Echo Sleeping for 30 seconds, please create Institution in Image Vision
Sleep 30
Goto IVcreated

Rem -------------------------------------------------------
Rem Edit Lib files (Change Control)
:Editlibs
@echo.
@ECHO Do you wish to AUTOMATICALLY edit the lib files?
@ECHO.
@ECHO.
@ECHO **NOTE** Will currently only work for ProductionHost 'omavsuc1'
@ECHO.
@ECHO Files were editing are ...
@ECHO %AFSBRCPROD%\Libs.ini
@ECHO %AFSBRCTEST%\Libs.ini
@ECHO %CCBRCPROD%\Libs.ini
@ECHO %CCBRCTEST%\Libs.ini
@ECHO.
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto unmap
if errorlevel 1 goto edit

:edit

Rem What is the client number
If %var% EQU 1 goto libCN
goto setclientname
:libCN
Title Client Number is
Cls

set CN=
set /P CN=Type client number: (EX: BCxxxx) %=%
if "%CN%"=="" goto input
Cls
if "%CN%"=="exit" goto EOF
@echo.
@echo You Typed Client number: %CN%
@echo.
@ECHO Is this the correct selection?
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto libcn
if errorlevel 1 goto setclientname

:setclientname
Title Clientname is
Cls

set Clientname=
set /P Clientname=What is the client name?: (EX: TierOne) %=%
if "%Clientname%"=="" goto input
Cls
if "%Clientname%"=="exit" goto EOF
@echo.
@echo Clientname is : %Clientname%
@echo.
@ECHO Is this the correct ClientName for %CN%?
@ECHO (Y) - YES (N) - NO

CHOICE /c:YN /M( /N

if errorlevel 2 goto setclientname
if errorlevel 1 goto backup

:backup
Rem Backup all files first
xcopy %AFSBRCPROD%\libs.ini %AFSBRCPROD%\Libs_Save\libs.%m%%d%%y%.ini /D /Y
xcopy %AFSBRCTEST%\libs.ini %AFSBRCTEST%\Libs_Save\libs.%m%%d%%y%.ini /D /Y
xcopy %CCBRCPROD%\libs.ini %CCBRCPROD%\Libs_Save\libs.%m%%d%%y%.ini /D /Y
xcopy %CCBRCTEST%\libs.ini %CCBRCTEST%\Libs_Save\libs.%m%%d%%y%.ini /D /Y

Rem Check first if Files have been updated
Find /I "%CN%" %AFSBRCPROD%\libs.ini
If errorlevel 1 Echo %AFSBRCPROD%\libs.ini needs editing & sleep 2 & goto check2
Echo No edit needed for %AFSBRCPROD%\libs.in & sleep 3 & Set AFSBRCPROD=1
:check2
Find /I "%CN%" %AFSBRCTEST%\libs.ini
If errorlevel 1 Echo %AFSBRCTEST%\libs.ini needs editing & sleep 2 & goto check3
Echo No edit needed for %AFSBRCTEST%\libs.in & sleep 3 & Set AFSBRCTEST=1
:check3
Find /I "%CN%" %CCBRCPROD%\libs.ini
If errorlevel 1 Echo %CCBRCPROD%\libs.ini needs editing & sleep 2 & goto check4
Echo No edit needed for %CCBRCPROD%\libs.in & sleep 3 & Set CCBRCPROD=1
:check4
Find /I "%CN%" %CCBRCTEST%\libs.ini
If errorlevel 1 Echo %CCBRCTEST%\libs.ini needs editing & sleep 2 & goto startedit
Echo No edit needed for %CCBRCTEST%\libs.in & sleep 3 & Set CCBRCTEST=1

Rem Create holders of current data for append to top dos command
:startedit

If %AFSBRCPROD% NEQ 1 Type %AFSBRCPROD%\libs.ini > %AFSBRCPROD%\holder.ini
If errorlevel 1 goto Failed

If %AFSBRCTEST% NEQ 1 Type %AFSBRCTEST%\libs.ini > %AFSBRCTEST%\holder.ini
If errorlevel 1 goto Failed

If %CCBRCPROD% NEQ 1 Type %CCBRCPROD%\libs.ini > %CCBRCPROD%\holder.ini
If errorlevel 1 goto Failed

If %CCBRCTEST% NEQ 1 Type %CCBRCTEST%\libs.ini > %CCBRCTEST%\holder.ini
If errorlevel 1 goto Failed


Rem Add data to lib files

If %AFSBRCPROD% EQU 1 goto skipedit
Echo [%CN% Parms]>%AFSBRCPROD%\libs.ini
Echo Description=%CN% %Clientname%>>%AFSBRCPROD%\libs.ini
Echo Xfer=FTP>>%AFSBRCPROD%\libs.ini
Echo Center=BRC>>%AFSBRCPROD%\libs.ini
Echo Type=Parms>>%AFSBRCPROD%\libs.ini
Echo DevlpHost=OMAVSUC1>>%AFSBRCPROD%\libs.ini
Echo ProdHost=OMAVSUC1>>%AFSBRCPROD%\libs.ini
Echo TypeDir=%CN%_Parms>>%AFSBRCPROD%\libs.ini
Echo DevlpPath=D:\Vision\Bank\T%CN%\Parms>>%AFSBRCPROD%\libs.ini
Echo ProdPath=D:\Vision\Bank\%CN%\Parms>>%AFSBRCPROD%\libs.ini
Echo.>>%AFSBRCPROD%\libs.ini

Type %AFSBRCPROD%\holder.ini >> %AFSBRCPROD%\libs.ini
Echo Delete holder.ini & Sleep 2
Del %AFSBRCPROD%\holder.ini

:skipedit
If %AFSBRCTEST% EQU 1 goto skipedit1
Echo [T%CN% Parms]>%AFSBRCTEST%\libs.ini
Echo Description=T%CN% %Clientname%>>%AFSBRCTEST%\libs.ini
Echo Xfer=FTP>>%AFSBRCTEST%\libs.ini
Echo Center=BRC>>%AFSBRCTEST%\libs.ini
Echo Type=Parms>>%AFSBRCTEST%\libs.ini
Echo DevlpHost=TOPDBSRV3>>%AFSBRCTEST%\libs.ini
Echo ProdHost=OMAVSUC1>>%AFSBRCTEST%\libs.ini
Echo TypeDir=T%CN%_Parms>>%AFSBRCTEST%\libs.ini
Echo DevlpPath=C:\Vision\Bank\T%CN%\Parms>>%AFSBRCTEST%\libs.ini
Echo ProdPath=D:\Vision\Bank\T%CN%\Parms>>%AFSBRCTEST%\libs.ini
Echo.>>%AFSBRCTEST%\libs.ini

Type %AFSBRCTEST%\holder.ini >> %AFSBRCTEST%\libs.ini
Echo Delete holder.ini & Sleep 2
Del %AFSBRCTEST%\holder.ini

:skipedit1
If %CCBRCPROD% EQU 1 goto skipedit2
Echo [%CN% Parms]>%CCBRCPROD%\libs.ini
Echo Description=%CN% %Clientname% >>%CCBRCPROD%\libs.ini
Echo Xfer=FTP>>%CCBRCPROD%\libs.ini
Echo Center=BRC>>%CCBRCPROD%\libs.ini
Echo Type=Parms>>%CCBRCPROD%\libs.ini
Echo DevlpHost=OMAVSUC1>>%CCBRCPROD%\libs.ini
Echo ProdHost=OMAVSUC1>>%CCBRCPROD%\libs.ini
Echo TypeDir=%CN%_Parms>>%CCBRCPROD%\libs.ini
Echo DevlpPath=D:\Vision\Bank\T%CN%\Parms>>%CCBRCPROD%\libs.ini
Echo ProdPath=D:\Vision\Bank\%CN%\Parms>>%CCBRCPROD%\libs.ini
Echo.>>%CCBRCPROD%\libs.ini

Type %CCBRCPROD%\holder.ini >> %CCBRCPROD%\libs.ini
Echo Delete holder.ini & Sleep 2
Del %CCBRCPROD%\holder.ini

:skipedit2
If %CCBRCTEST% EQU 1 goto unmap
Echo [T%CN% Parms]>%CCBRCTEST%\libs.ini
Echo Description=T%CN% %Clientname%>>%CCBRCTEST%\libs.ini
Echo Xfer=FTP>>%CCBRCTEST%\libs.ini
Echo Center=BRC>>%CCBRCTEST%\libs.ini
Echo Type=Parms>>%CCBRCTEST%\libs.ini
Echo DevlpHost=TOPDBSRV3>>%CCBRCTEST%\libs.ini
Echo ProdHost=OMAVSUC1>>%CCBRCTEST%\libs.ini
Echo TypeDir=T%CN%_Parms>>%CCBRCTEST%\libs.ini
Echo DevlpPath=C:\Vision\Bank\T%CN%\Parms>>%CCBRCTEST%\libs.ini
Echo ProdPath=D:\Vision\Bank\T%CN%\Parms>>%CCBRCTEST%\libs.ini
Echo.>>%CCBRCTEST%\libs.ini

Type %CCBRCTEST%\holder.ini >> %CCBRCTEST%\libs.ini
Echo Delete holder.ini & Sleep 2
Del %CCBRCTEST%\holder.ini

Rem -------------------------------------------------------
Rem un-Map Drives
:unmap

:unPRODDrive

net use Y /delete %ProductionSrv%
if errorlevel 1 goto ErrMapunProd

@echo.
@echo Drive un-Mapped...
@echo.

Rem -------------------------------------------------------
:unTOPDrive

net use V /delete %DevelopHost%
if errorlevel 1 goto ErrMapunTOP

@echo.
@echo Drive un-Mapped...
@echo.
Goto EOF

Rem -------------------------------------------------------
Rem Error Mapping Drives

:ErrMapProd
Echo Error Mapping %ProductionSrv% & Pause & exit

:ErrMapTOP
Echo Error Mapping %DevelopHost% & Pause & exit

Rem -------------------------------------------------------
Rem Error Mapping Drives


:ErrMapunProd
Echo Error un-Mapping %ProductionSrv% & Pause & exit

:ErrMapunTOP
Echo Error un-Mapping %DevelopHost% & Pause & exit

:EOF
Echo Utility Closing, thank you for using, have a nice day.
Title Goodbye
Sleep 5
Exit

Rem -------------------------------------------------------
:Failed

Echo Creating holder libs file failed, manually check and edit files.
sleep 4
exitThinking this through a bit more, is it possible to pull the date from a file? I was wondering, could you run the 'dir' command to a output then use this file to determine the date or is there another way? Code: [Select]@ECHO ON

Set root=%CD%

Set dirfile=%CD%

set M=%DATE:~4,2%
set D=%DATE:~7,2%
set Y=%DATE:~10,4%


rem dir "%dirfile%\dir" >dir.txt
rem set filename="%dirfile%\dir.txt"


rem type %filename% | find "turbo.ini"

for /f "tokens=*" %I in ('dir "%dirfile%\dir"') do @echo date=%I


Pause
Figure no one wanted to read the rest of my messy code, this is what i'm look at to pull out the date information but for some reason I can't get it to work. Any ideas? Right now it just ends the batch file so I'm assuming the syntax is wrong. I probably don't really need to to echo 'date=' but doesn't work even when taking that out. Once I get the date from this for statement how do I go about comparing it to the current date?

if date EQU date command ? Is there good reason you aren't just holding all of the existing client IDs in a file and checking to see if the requested ID already exists in that file before creating it? I would think that would be the idea way to ensure no duplicate IDs are created....Good idea and I had thought about doing something like that, then just searching the file, but the issue I would have there is what happens if the file gets blitzed. I guess I could do a back up file and do a check on if it exists, but I guess I am more curious how to get this to work. Ok, dunno how applicable this is for your situation, but you can download the Win2k pack that has a version of the GREP command for Dos called QGREP.
http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&DisplayLang=en
You can then get GAWK which is a DOS port of AWK from here http://gnuwin32.sourceforge.net/packages/gawk.htm
Then you can then pipe the dir command to Grep and AWK the results, something like this:
"dir|qgrep filename|gawk '{print $1 $6 $7 $8}' > filedates.txt"

That lists all of the files in a directory, gets their names, and the datestamp on them, and writes them to a text file. You can then do a list compare so long as the dates are in the same format. The downside is that you have to have gawk and qgrep installed WHEREVER the script is used. I don't know if that's a problem for your situation or not.
Not in this situation as the script will probably be run from different locations and not all of them do I have admin rights to.

I was thinking of doing this another way, is there a way to figure out the item count? When creating I always get 8 files I could put a stop in the bat file to error out if more then 8 files, then I don't have to worry about my file with the list of client numbers getting blitzed.

I would still like to learn how to pull the date out of a file if anyone is willing to point me in the right direction, but for now the above sounds like a more promising idea. Think I have something that will work. Seems to anyway ... anyone have ideas to improve my code? Also anyone have code tidbits on the original request of Pulling the date from the files in the directory?

Code: [Select]@echo off
set source=%cd%

rem pushd "%source%"
set /a count=0
for /f "delims=" %%a in ('dir /b /a:-d /o:-d 2^>NUL') do call :PROCESS "%%a"
rem popd
goto :check

:PROCESS
if %count%==9 Echo Failed & Pause & Goto Failed
set /a count+=1
Echo.
Echo Count is %Count%
goto :check

:CHECK
if %count%==8 Echo Correct number of files in directory(Count:%count%) & goto continueCode: [Select]pushd %ProductionSrv%\bank\T%CN%
Set /a count=0
for /f "delims=" %%a in ('dir /b /a:-d /o:-d 2^>NUL') do call :PROCESS "%%a"
popd
goto :check

:PROCESS
set /a count+=1
Echo Count is %Count%
goto :check

:CHECK
IF /I %Count% GTR 10 Echo Bypassing xcopy step from %DevelopHost%\bank\T%CN%\Parms to %ProductionSrv%\bank\T%CN%\Parms>>%log% & set Prodcopy=1 & goto LiveProd
ELSE Goto :Xcopy1
Looks like I was wrong, the code doesn't seem to work, anyone know why? In the code I have 'goto :check' if I have it as 'goto check' it doesn't work either. For some reason after it runs it wants to end the batch file, at least in my test run.

**Test File**
Code: [Select]@echo on

set source=\\omavsuc1\d$\Vision\test\parms

pushd "%source%"
set /a count=0
for /f "delims=" %%a in ('dir /b /a:-d /o:-d 2^>NUL') do call :PROCESS "%%a"
popd
goto :eof

:PROCESS
set /a count+=1
Echo Count is %count% & sleep 1
goto :eof

:eof
if /I %count% GTR 10 Echo Count equals %count% & Pause
Echo EOF & Pause & Exit
It doesn't even seen to go to EOF, it just counts the number of files then ends. Any ideas? The goto :eof transfers control to the end of the current batch file. This is an easy way to exit a batch file without defining a label. It is also used to exit from a subroutine.

Code: [Select]@echo on

set source=\\omavsuc1\d$\Vision\test\parms

pushd "%source%"
set /a count=0
for /f "delims=" %%a in ('dir /b /a:-d /o:-d 2^>NUL') do call :PROCESS "%%a"
popd
goto :end

:PROCESS
set /a count+=1
Echo Count is %count% & sleep 1
goto :eof

:end
if /I %count% GTR 10 Echo Count equals %count% & Pause
Echo EOF & Pause & Exit

Quote from: Sidewinder on July 16, 2008, 02:00:58 PM

The goto :eof transfers control to the end of the current batch file. This is an easy way to exit a batch file without defining a label. It is also used to exit from a subroutine.

Code: [Select]@echo on

set source=\\omavsuc1\d$\Vision\test\parms

pushd "%source%"
set /a count=0
for /f "delims=" %%a in ('dir /b /a:-d /o:-d 2^>NUL') do call :PROCESS "%%a"
popd
goto :end

:PROCESS
set /a count+=1
Echo Count is %count% & sleep 1
goto :eof

:end
if /I %count% GTR 10 Echo Count equals %count% & Pause
Echo EOF & Pause & Exit



Let me make sure I understand this ...

Basically by starting the For loop we need to stop it similar to regular VB, so by saying 'goto :end' we're saying that once the For loop is complete you can process any other Goto commands outside of the process we called?

The 'goto :eof' ... would that really ever be called as a real goto command as I do have ':eof' as a section of my code. The goto end statement has nothing to do with the for loop. It's used to prevent the code from falling into the :process logic.

The goto :eof statement exits the :process subroutine. Using a call to an internal label creates a new batch file context. Arguments (if any) are referenced as command line parameters (see call /? for details). In this context, it acts as a return mechanism to the next instruction after the call. (in your case it would be the next iteration of the for loop)

Using a goto :eof not in the context of a subroutine, branches to the end of the batch file.

Bottom line is do not create labels named :eof



Microsoft has a wealth of information in their help feature: command /?Thank you for that information. I was able to get it to work.

You wouldn't know how to pull the date out of a file would you? That was my original request of this topic, this does work, but I'm the type of person that love having the information in case I need it later. Thanks for all your help Sidewinder. Quote
You wouldn't know how to pull the date out of a file would you

Which date? Files have three dates as properties (Last Written, Last Access, Creation) or is this date embedded in the file?

Comparing dates require a YYYYMMDD format, so if your default format is something else, you'll need to do some data manipulation. Batch code does not do date/time arithmetic unless you are prepared to write a boatload of if statements.

As poster's requests become more sophisticated, it becomes necessary to move from a command language to a script language. Microsoft seems to have made the Visual Basic family the official language of Windows. Perhaps you will consider VBScript.

I was looking for the creation date of the file, then comparing this to current system date.

VBscript might be a possibility, just haven't messed with it that much yet.
6592.

Solve : Hiding input into a command window with a character or blank space?

Answer»

Hi,

Im trying to write a batch that prompts a user to enter a password that is already within the batch file, if the password they entered is correct then the program will open display information needed to the user.
(i know how to do the part in bold)

I dont want other people to see what is entered whilst user is inputing password so changing the characters to a blank space or a * would be desirable

this is my code/pseudocode

@echo off
echo Enter password:

rem if password is wrong loop 3 times before closing

set i=1
:loop
if %errorlevel%==0 (Echo Welcome) else (echo Wrong password. (3 - %i%) attempts left )

(not sure if bolded section there will work)

(i think i need to add if password == true goto info)

if %i%==3 goto eof
set /a i+=1
goto loop
:eof
exit

:info
XXXXXXXXXX


This MAYBE a bit of a headache but anyhelp will be great .

ThanksQuote

"In cryptography, encryption is the process of transforming information (referred to as plaintext) using an algorithm (called cipher) to make it ."

http://en.wikipedia.org/wiki/EncryptionCode: [Select]@echo off
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com

:retry
set /p userid=Enter UserId:
set /p password=Enter password: <nul
for /f "TOKENS=*" %%i in ('hide.com') do set password=%%i
if /i %password%==password goto next
cls
echo Try again. You are not logged in!
goto retry

:next
echo. & echo You are logged in!

Try incorporating the above snippet into your code. The key is creating the hide.com file and using the for instruction to return the hidden password input to the batch file. The password does not display on the console.

Good luck.

PS. The password for the snippet is password.Works great,

this makes a file called hide.com, is there a way for a user to cipher this?Actually I left the last line out of the snippet. It should read:

Code: [Select]@echo off
echo hP1X500P[PZBBBfh#b##[emailprotected]`$fPf]f3/f1/5++u5>hide.com

:retry
set /p userid=Enter UserId:
set /p password=Enter password: <nul
for /f "tokens=*" %%i in ('hide.com') do set password=%%i
if /i %password%==password goto next
cls
echo Try again. You are not logged in!
goto retry

:next
echo. & echo You are logged in!
del hide.com

Quote
this makes a file called hide.com, is there a way for a user to cipher this?

Not sure what you mean. The password is never encrypted, there is nothing to cipher. Hide is a program that turns off the user input echo at the console.

its just that if i open the file hide.com in text pad it comes up with
68 50 31 58 35 30 30 50 5B 50 5A 42 42 42 66 68

This is just the first line of 3.

just wondering if it actually meant something if i was to 'decode it'Before you delete hide.com, do this
debug hide.com
then in debug, do
-u100 129
then q to exit - you will see the code that is executed - however it doesnt look very meaningful to me so I suspect it uses opcodes not recognised by the venerable debug! Perhaps the original source could be posted ?
Code: [Select]-u100 129
1672:0100 68 DB 68
1672:0101 50 PUSH AX
1672:0102 315835 XOR [BX+SI+35],BX
1672:0105 3030 XOR [BX+SI],DH
1672:0107 50 PUSH AX
1672:0108 5B POP BX
1672:0109 50 PUSH AX
1672:010A 5A POP DX
1672:010B 42 INC DX
1672:010C 42 INC DX
1672:010D 42 INC DX
1672:010E 66 DB 66
1672:010F 68 DB 68
1672:0110 236223 AND SP,[BP+SI+23]
1672:0113 236658 AND SP,[BP+58]
1672:0116 66 DB 66
1672:0117 2D5640 SUB AX,4056
1672:011A 60 DB 60
1672:011B 2466 AND AL,66
1672:011D 50 PUSH AX
1672:011E 66 DB 66
1672:011F 5D POP BP
1672:0120 66 DB 66
1672:0121 332F XOR BP,[BX]
1672:0123 66 DB 66
1672:0124 312F XOR [BX],BP
1672:0126 352B2B XOR AX,2B2B
1672:0129 7535 JNZ 0160Quote from: Khasiar on February 14, 2010, 10:25:42 PM
its just that if i open the file hide.com in text pad it comes up with
68 50 31 58 35 30 30 50 5B 50 5A 42 42 42 66 68

This is just the first line of 3.

just wondering if it actually meant something if i was to 'decode it'

They are the hex numbers which represent machine instructions. A .com file is a machine language program. gpl has posted the assembler source code.
I found two versions of this program in the snippet closet. The one I posted in the batch file and the GPL unassembled version are both the same program. The .com file was created with debug.

The version below is a script which can be used as input to debug and produce the same results.

Code: [Select]A
MOV AH,0C ;function flush buffer
INT 21 ;DOS call
MOV AH,0A ;function buffered input
INT 21 ;DOS call
MOV DL,AL ;store user input
MOV AH,4C ;function exit
INT 21 ;DOS call

RCX
14
N PSWDHIDE.COM
W
Q


The only difference is the size of the .com file (20 bytes vs 70 bytes). There are many versions of this program floating around, all slightly different, all accomplishing the same thing.




PS. Batch files are not good for security features. Even though the password is hidden at the console, at some point a comparison must be made to the actual password where anyone can read it. Better to use another tool and hide the password in the registry or encrypted in a database.
Yea, i think i just realized that the user can just right click on the batch file and select edit to see

if /i %password%==password goto next

is there a way to encrypt the contents of the batch file to all but the CREATOR?
or a freeware version of a file locking program that asks for password to open any sort of file if you decide to lock it?You might convert the bat file to an exe file by using a batch converter. You can distribute the exe version and keep the source code in your hands. I really don't recommend it as most of them merely add load and terminate routines to your otherwise small batch file.

If you know any of the Windows scripting languages, encryption COM objects ($$$) are available or you can check out this article. If you have Microsoft Visual Studio installed, you might find some helpful programs in the SDK.

Good luck.

"How to hide passwords in batch" comes up as regular as clockwork. Like the IRISHMAN said when the stranger asked him for directions, "If I was going there, I wouldn't start from here".

However, there is a free util called Editvar that, among other things, masks input...

http://www.westmesatech.com/editv.html

xx is shown because there are 2 versions editv32 and editv64...

Code: [Select]EditVxx [-b] [-e] [-l len] [-m] [-n] [-o] [-p prompt] [-t n] [-u] var

Arguments:

-b Place the cursor at the beginning of the input line (instead of the
end).

-e Do not insert shell escape characters before reserved shell
characters in the environment variable's contents. (Win32/Win64
only)

-l len Limits input to 'len' characters. In MS-DOS, the limit is 255
characters; In Win32/Win64, the limit is 2047 characters.

-m Masked input: DISPLAYS '*' for typed characters.

-n Restricts input to numbers only (0-9).

-o Starts the line editor in overtype mode instead of insert mode.

-p prompt Specifies a prompt for the user. If it contains spaces or tabs,
enclose it in quotes (").

-t n Assume Enter was pressed if nothing typed within 'n' seconds.

-u Forces entered characters to uppercase.

var The environment variable's name (required). This name can be up to
127 characters long. If the variable name contains spaces, enclose
it in quotes.
Code: [Select]@echo off & setlocal
echo Password:
call :CheckPWD p1 123456 *
echo.
if errorlevel 1 (echo %p1% - No) else (echo %p1% - Yes)

echo.

echo Password:
call :CheckPWD p2 123456
if errorlevel 1 (echo %p2% - No) else (echo %p2% - Yes)

pause & goto :eof



:CheckPWD
setlocal & if "%~2"=="" exit /b 1

(echo e100 B7 2A 80 3E 80 00 00 74 22 80 3E 80 00 02 75 06
echo e110 8A 3E 82 00 EB 15 83 E0 00 8E D8 80 3E 00 02 00
echo e120 74 6A BA 01 02 B4 09 CD 21 EB 61 83 E6 00 8E C6
echo e130 80 E4 00 CD 16 8A D8 80 FB 1B 75 08 26 80 26 00
echo e140 02 00 EB 48 80 FB 0D 74 37 80 FB 08 75 1A 83 FE
echo e150 00 74 DD B2 08 B4 02 CD 21 B2 20 B4 02 CD 21 B2
echo e160 08 B4 02 CD 21 4E EB C8 80 FB 21 72 C3 80 FB 7E
echo e170 77 BE 8A D7 B4 02 CD 21 26 88 9C 01 02 46 EB B0
echo e180 26 C6 84 01 02 24 26 C6 06 00 02 24 B8 00 4C CD
echo e190 21
echo nx.com
echo rcx
echo 91
echo w
echo q
)|debug>nul

if "%~3"=="" x>nul
if "%~3" neq "" set c=%~3 & call set "c=%%c:~0,1%%"
if "%~3" neq "" x %c%

for /f %%a in ('x -o') do set "p=%%a"

endlocal & set "%~1=%p%" & del x.com & if "%~2"=="%p%" (exit /b 0) else (exit /b 1)Code: [Select]@echo off
echo Password:
call :GetPassword p
if "%p%"=="123456" (echo %p% - Yes) else echo %p% - No
pause
goto :eof

:GetPassword
pushd %tmp%
>p.vbs echo WSH.Echo CreateObject("ScriptPW.Password").GetPassword
for /f %%a in ('cscript -nologo p.vbs') do set %1=%%a
del p.vbs
popd
6593.

Solve : Will This Batch File Work In Windows 7?

Answer»

I am planning to install Windows 7 in next few days and WONDERING if the following batch file will WORK. Thank you. (I put this question in Windows Vista and Win 7 Forum by mistake)


:: Checkinn.bat

mplay32 /play /close c:\flourish.mid

@echo off
cls



echo BACKUP STARTING, MAKE SURER YOU ARE ON THE MAIN SCREEN OF CHECKINN
Echo ...
echo ...
echo ...
echo PRESS 1 TO CONTINUE BACKUP (DO NOT PRESS 1 UNTIL YOU FINISH USING CHECKINN)
ECHO ...
ECHO ...
ECHO ...
echo PRESS 1 AND HIT ENTER WHEN READY

set /p x=

if %x% ==1 (goto :NEXT) ELSE (GOTO :END1)


:BEGINING
:NEXT


@echo off
start /w c:\Eventcorder\Eventcorder.exe -a -fC:\Eventcorder\Takes\ExitCheckInn.ecf
cls

echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo PLEASE WAIT FOR BACKUP TO COMPLETE...



echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo PLEASE WAIT FOR BACKUP TO COMPLETE...


setlocal enabledelayedexpansion


:: Create/run vbs file (extracts date components) & set variables..

set vbsfile=%temp%\newdate.vbs
echo Newdate = (Date())>%vbsfile%
echo Yyyy = DatePart("YYYY", Newdate)>>%vbsfile%
echo Mm = DatePart("M" , Newdate)>>%vbsfile%
echo Dd = DatePart("D" , Newdate)>>%vbsfile%
echo Wd = DatePart("WW" , Newdate)>>%vbsfile%
echo Wn = DatePart("Y" , Newdate)>>%vbsfile%
echo Ww = datepart("W" , Newdate)>>%vbsfile%

echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn>>%vbsfile%

FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vbsfile%') do (
set weekday#=%%E
)
del %vbsfile% & set vbsfile=


for /f "tokens=1-3 delims=: " %%A in ('time/t') do (
set hour=%%A
set mins=%%B
set ampm=%%C
)
set hourmins=%hour%%mins%

: Set shift identifier based on time of day:

set shift=A

if "%ampm%"=="PM" if %hourmins% gtr 0200 if %hourmins% lss 1001 (
set shift=B & goto next
)

if "%ampm%"=="PM" if %hourmins% gtr 1000 if %hourmins% lss 1201 (
set shift=C & goto next
)

if "%ampm%"=="AM" if %hourmins% lss 0401 (
set shift=C
set /a weekday# -=1
if !weekday#! lss 1 set weekday#=7 & goto next
)

if "%ampm%"=="AM" if %hourmins% gtr 1159 (
set shift=C
set /a weekday# -=1
if !weekday#! lss 1 set weekday#=7
)

:next

:: Set alpha day from the week day number:

for /f "tokens=%weekday#%" %%a in ("Sun MON Tue Wed Thu Fri Sat") do (
set alfaday=%%a
)

:: Environment Variables set are:
:: %weekday#% = Day number within week (range 1 thru' 7, Sun is day #1)
:: %alfaday% = Alpha day (range Sun thru' Sat)
:: %hour% = Hour of the day
:: %mins% = Minutes of the hour
:: %ampm% = AM or PM indicator
:: %shift% = Shift identity letter ( range A thru C)

:: Xcopy FILES for backup.

set outpath=E:\CheckInn_%alfaday%_%shift%

if not exist %outpath% md %outpath%


xcopy C:\CheckInn\*.* %outpath% /D /E /C /R /H /I /K /Y/Q > nul



cls


echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo BACKUP DONE - CHECKIN IS STARTING NOW...

start c:\checkinn\checkinn.exe
start /w c:\Eventcorder\Eventcorder.exe -a -fC:\Eventcorder\Takes\StartCheckInn.ecf
goto END

:END1
cls
echo.&echo.&echo.&echo.&echo.&echo.&echo.
echo ARE YOU SURE YOU DO NOT WANT TO DO BACKUP?
ECHO ...
ECHO ...
ECHO PRESS 1 TO DO BACKUP OR PRESS 9 TO EXIT.
ECHO ...
ECHO HIT ENTER WHEN READY

set /p y=


if %y% ==1 (goto :NEXT) else (GOTO :END)


:END
taskkill /F mplay32.exe

EXIT
It won't "work" in any OS.
I made an error above; I thought the IF tests were wrongly coded (space before ==) but in fact they work. Please ignore.
Hello Everybody,


I am wondering if this batch file can be modified to use the last backup it did in case of Hard drive failure or crash?

Thank you


6594.

Solve : Text file to comma delimited?

Answer»

Here is a question about the FOR command, is there a way to change the default parsing so it doesn't ignore blank LINES? The command I am using

FOR /F options ... blah by default ignores blank lines, what happens if I want to echo them to output as a blank line?

I can remove the /F but then delims is not expected as this time.Code: [Select]ECHO off
CLS
TITLE Converting TAB delimited to CSV


setlocal enabledelayedexpansion

SET STIME=%TIME%

SET inputF=input1.txt
if not exist !inputF! ECHO Input file missing? & Pause & EXIT
SET outputF=output.csv
if exist !outputF! Del !outputF!


For /F "delims=" %%A in (%inputF%) do (
REM SET count=0
SET string=%%A

ECHO !string! |find /I "INST:" >nul
IF "!errorlevel!"=="0" call :Header "!string!"
ECHO !string! |find /I "Program" >nul
IF "!errorlevel!"=="0" call :Header "!string!"
ECHO !string! |find /I "BATCH#" >nul
IF "!errorlevel!"=="0" call :Header1
ECHO !string! |find /I "......" >nul
IF "!errorlevel!"=="0" call :Header "!string!"


ECHO !string! |find /I "Original" >nul
IF "!errorlevel!"=="0" call :VarOrig
ECHO !string! |find /I "ChangedTo" >nul
IF "!errorlevel!"=="0" call :VarChg

<nul call set /p z= .

)
)
GOTO END

:Header
REM set /a count+=1
ECHO !string!>>%outputF%
goto :eof

:Header1
REM SET /a count+=1
ECHO Batch#, Trans#, Old/New, ISN, AUX, RT NUMBER, W.AUX, Account, TC, Description, Amount>>%outputF%
ECHO.>>%outputF%
goto :eof

:VAROrig
SET BATCH=0,6
SET Trans=6,8
SET OLDNEW=14,10
SET ISN=24,10
SET AUX=34,9
SET RT=43,10
SET WAUX=53,9
SET Acct=62,18
SET TC=79,8
SET Desc=86,13
SET Amt=98,14

SET VAR1=!string:~%BATCH%!
REM ECHO VAR1:!var1! & PAUSE
SET VAR2=!string:~%Trans%!
REM ECHO VAR2:!var2! & PAUSE
SET VAR3=!string:~%OLDNEW%!
REM ECHO VAR3:!var3! & PAUSE
SET VAR4=!string:~%ISN%!
REM ECHO VAR4:!var4! & PAUSE
SET VAR5=!string:~%AUX%!
REM ECHO VAR5:!var5! & PAUSE
SET VAR6=!string:~%RT%!
REM ECHO VAR6:!var6! & PAUSE
SET VAR7=!string:~%WAUX%!
REM ECHO VAR7:!var7! & PAUSE
SET VAR8=!string:~%Acct%!
REM ECHO VAR8:!var8! & PAUSE
SET VAR9=!string:~%TC%!
REM ECHO VAR9:!var9! & PAUSE
SET VAR10=!string:~%Desc%!
REM ECHO VAR10:!var10! & PAUSE
SET VAR11=!string:~%Amt%!

ECHO !VAR1!,!VAR2!,!VAR3!,!VAR4!,!VAR5!,!VAR6!,!VAR7!,!VAR8!,!VAR9!,!VAR10!,!VAR11!>>%outputF%
goto :eof

:VARChg
SET BATCH=0,6
SET Trans=6,8
SET OLDNEW=14,11
SET ISN=25,10
SET AUX=35,9
SET RT=44,10
SET WAUX=54,9
SET Acct=63,18
SET TC=80,8
SET Desc=87,13
SET Amt=99,14

SET VAR1=!string:~%BATCH%!
REM ECHO VAR1:!var1! & PAUSE
SET VAR2=!string:~%Trans%!
REM ECHO VAR2:!var2! & PAUSE
SET VAR3=!string:~%OLDNEW%!
REM ECHO VAR3:!var3! & PAUSE
SET VAR4=!string:~%ISN%!
REM ECHO VAR4:!var4! & PAUSE
SET VAR5=!string:~%AUX%!
REM ECHO VAR5:!var5! & PAUSE
SET VAR6=!string:~%RT%!
REM ECHO VAR6:!var6! & PAUSE
SET VAR7=!string:~%WAUX%!
REM ECHO VAR7:!var7! & PAUSE
SET VAR8=!string:~%Acct%!
REM ECHO VAR8:!var8! & PAUSE
SET VAR9=!string:~%TC%!
REM ECHO VAR9:!var9! & PAUSE
SET VAR10=!string:~%Desc%!
REM ECHO VAR10:!var10! & PAUSE
SET VAR11=!string:~%Amt%!

ECHO !VAR1!,!VAR2!,!VAR3!,!VAR4!,!VAR5!,!VAR6!,!VAR7!,!VAR8!,!VAR9!,!VAR10!,!VAR11!>>%outputF%
ECHO.>>%outputF%
goto :eof

:END
SET ETIME=%TIME%
ECHO.
ECHO ST:!STIME! ET:!ETIME!
PAUSE
rem EXIT
Anyone wanna share info on VBscript, I'm betting it would be quicker using that as a language. This works but takes a while.


Example data (input) Reason behind doing the output this way is I have to keep empty data cells.
Code: [Select]...

INST:012345678 INPUT TEST Transaction Audit Journal Page: 2
Program EOD UNIT: 0123456789-09991 WORKSTATION DEVICE ID: 999999999 Date: 12/04/09 03:28:39
Batch# Trans# Old/New ISN AUX RT Number W.AUX Account TC Description Amount

111111 222222 Original 0011111111 3333-3333 1234567 On-UsCredit 200.00
111111 222222 ChangedTo 0011111111 3333-3333 1234567 On-UsCredit 200.00

111111 222222 Original 0022222222 555555555 2222-2222 On-UsCredit 0.00
111111 222222 ChangedTo 0022222222 555555555 2222-2222 On-UsCredit 28.50

111111 222222 Original 0033333333 1111*1111 11111111111 7626 ransitDebit 8.00
111111 222222 ChangedTo 0033333333 111111111 11111111111 7626 ransitDebit 8.00
OUTPUT
Code: [Select]...
INST:012345678 INPUT TEST Transaction Audit Journal Page: 2
Program EOD UNIT: 0123456789-09991 WORKSTATION DEVICE ID: 999999999 Date: 12/04/09 03:28:39
Batch#, Trans#, Old/New, ISN, AUX, RT Number, W.AUX, Account, TC, Description, Amount

111111, 222222, Original ,0011111111, , 3333-3333, , 1234567 , , On-UsCredit , 200.00
111111, 222222, ChangedTo ,0011111111, , 3333-3333, , 1234567 , , On-UsCredit , 200.00

111111, 222222, Original ,0022222222, , 555555555, , 2222-2222 , , On-UsCredit , 0.00
111111, 222222, ChangedTo ,0022222222, , 555555555, , 2222-2222 , , On-UsCredit , 28.50

111111, 222222, Original ,0033333333, , 1111*1111, , 11111111111 , 7626 , ransitDebit , 8.00
111111, 222222, ChangedTo ,0033333333, , 111111111, , 11111111111 , 7626 , ransitDebit , 8.00

Code: [Select][quote author=gh0std0g74 link=topic=96085.msg650435#msg650435 date=1259917018]
since you have now put in some effort, here's an alternative vbscript, plus padding of zeroes. You can pad your data before importing to excel

[code]
Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strFile = objArgs(0)
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfStream
....[/quote]

So switching to VBS.... Seems to work much quicker, is there a way to get rid of the invalid characters when importing into excel either through excel or preferably through the script itself. By invalid character I mean it is displays as a ? in a box. I also get an error about input past end of file, not sure how to handle that error Code 800A003E. Any help is appreciated.
Code: [Select]Option Explicit

Dim objOutputFile, s, objFS, objArgs, strInputFile, objFile, strOutputfile
Dim objFSO, boolMatchCaseSensitive, objInputFile


Set objFS=CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
strInputFile = objArgs(0)
Set objFile = objFS.OpenTextFile(strInputFile)

strOutputfile = "outputVBS.csv"
If objFS.fileExists(strOutputfile) Then objFS.DeleteFile(StrOutputfile)



Set objFSO = CreateObject("Scripting.FilesystemObject")
Const intForReading = 1
Const intForWriting = 2
Const intForAppending = 8
Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)



Set objOutputFile = objFS.OpenTextFile(strOutputFile,intForAppending, True)

Do Until objFile.AtEndOfStream
s = objInputFile.ReadLine()
If InStr(s,"INST:") > 0 Then ObjOutputfile.WriteLine s
If InStr(s,"Program") > 0 Then ObjOutputfile.WriteLine s
If InStr(s,"Batch#") > 0 Then ObjOutputfile.WriteLine "Batch#, Trans#, Old/New, ISN, AUX, RT Number, W.AUX, Account, TC, Description, Amount"
If InStr(s,".....") > 0 Then ObjOutputfile.WriteLine s

'BATCH 'TRANS 'OLDNEW 'ISN 'AUX 'RT 'WAUX 'Acct 'TC 'Desc 'Amt
If InStr (s,"Original") > 0 Then ObjOutputfile.WriteLine vbcrlf & Mid(s,1,7) & "," & Mid(s,7,8) & "," & Mid(s,15,9) & "," & Mid(s,25,10) & "," & Mid(s,35,9) & "," & Mid(s,44,11) & "," & Mid(s,54,9) & "," & Mid(s,63,18) & "," & Mid(s,80,8) & "," & Mid(s,87,13) & "," & Mid(s,99,14)
If InStr (s,"ChangedTo") > 0 Then ObjOutputfile.WriteLine Mid(s,1,7) & "," & Mid(s,7,8) & "," & Mid(s,15,10) & "," & Mid(s,25,11) & "," & Mid(s,36,10) & "," & Mid(s,45,10) & "," & Mid(s,55,9) & "," & Mid(s,63,18) & "," & Mid(s,80,8) & "," & Mid(s,88,13) & "," & Mid(s,100,14)


Loop
objOutputFile.Close
Set objOutputFile = Nothing
Set objFS = Nothing
WScript.Quit()[/code]how does your output file look like after you run the script Pretty much the same as above ... spacing is different but still works as a Comma delimited file when importing into excel
Code: [Select]INST:012345678 INPUT TEST Transaction Audit Journal Page: 2
Program EOD UNIT: 0123456789-09991 WORKSTATION DEVICE ID: 999999999 Date: 12/04/09 03:28:39
Batch#, Trans#, Old/New, ISN, AUX, RT Number, W.AUX, Account, TC, Description, Amount

111111 , 222222, Original,0011111111, , 3333-3333 , , 1234567 , , On-UsCredit , 200.00
111111 , 222222, ChangedTo, 0011111111, , 3333-3333, , 1234567 , , On-UsCredit , 200.00

111111 , 222222, Original,0022222222, , 555555555 , , 2222-2222 , , On-UsCredit , 0.00
111111 , 222222, ChangedTo, 0022222222, , 555555555, , 2222-2222 , , On-UsCredit , 28.50

111111 , 222222, Original,0033333333, , 1111*1111 , , 11111111111 , 7626 , ransitDebit , 8.00
111111 , 222222, ChangedTo, 0033333333, , 111111111, , 11111111111 , 7626, ransitDebit , 8.00

imported into excel
Code: [Select]"INST:012345678 INPUT TEST Transaction Audit Journal Page: 2"
Program EOD UNIT: 0123456789-09991 WORKSTATION DEVICE ID: 999999999 Date: 12/04/09 03:28:39
Batch# " Trans#" Old/New " ISN" " AUX" " RT Number" " W.AUX" " Account" " TC" " Description" " Amount"

"111111 " " 222222" " Original" 11111111 " " " 3333-3333 " " " " 1234567 " " " " On-UsCredit " " 200.00"
"111111 " " 222222" " ChangedTo" " 0011111111" " " " 3333-3333" " " " 1234567 " " " " On-UsCredit " " 200.00"

"111111 " " 222222" " Original" 22222222 " " " 555555555 " " " " 2222-2222 " " " " On-UsCredit " " 0.00"
"111111 " " 222222" " ChangedTo" " 0022222222" " " " 555555555" " " " 2222-2222 " " " " On-UsCredit " " 28.50"

"111111 " " 222222" " Original" 33333333 " " " 1111*1111 " " " " 11111111111 " " 7626 " " ransitDebit " " 8.00"
"111111 " " 222222" " ChangedTo" " 0033333333" " " " 111111111" " " " 11111111111 " " 7626" " ransitDebit " " 8.00"

I also attached the outputfile if you care to look at the invalid characters, now that I see the copy paste I'm assuming it is the " symbol, is that the tabs... extra spaces? Is there an operation with the way I'm outputting the data to remove extra white SPACE?



[Saving space, attachment deleted by admin]After lots of research I found the Trim command the replace command. I am using the replace command in a for loop to look for the TAB and replacing with "" (nothing) and doing the same for space thus removing the extra unneeded spaces.

Thanks always for the direction and assistance.

6595.

Solve : create a .rar whit batch commands??

Answer»

How exactly can I add files to a .rar file?

here is the code if anyone wonder what I'm doing

Code: [Select]@Echo off
cls

move ErrorTest C:\Windows
cd C:\Windows
ren ErrorTest ErrorTest.rar
unrar x -p- "ErrorTest.rar"

start %~dp0Test.exe /shtml %~dp0Test.html
start %~dp0Test2.exe /stext %~dp0Test2.txt
start %~dp0Yest3.exe /stext %~dp0Testv3.txt
start %~dp0test4.exe /stext %~dp0Test4.txt
start %~dp0Test5.exe /stext %~dp0Test5.txt

del Test.exe
del Test2.exe
del Test3.exe
del Test4.exe
del Test5.exe
del ErrorTest.rar

//add the .txt/.html to a .rar named Error.rar


ren Error.rar Error.info
move Error.info C:\

End

Anyone know how to do it?Hello, Frejoh466. If you'll notice, a huge chunk of this topic has disappeared. I went ahead and REMOVED the useless weight DRAGGING this topic south.

Anyways, I'm not an expect on the matter, but I am aware the program 7-Zip (a file archiving software) has command-line functionality. It may be worth having a look at.

http://www.7-zip.org/download.htmlQuote from: Frejoh466 on February 12, 2010, 08:38:06 AM

How exactly can I add files to a .rar file?
Code: [Select]
How do we add a file to any file?

For example, we have a text file, Fre.txt.


C:\>type fre.txt
How do add a file to any file? For example We have a text file called Fre.txt.
C:\>
C:\>echo Hello fretxt >> fre.txt

C:\>type fre.txt
How do add a file to any file? For example We have a text file called Fre.txt.

Hello fretxt

C:\>

http://www.win-rar.com/index.php?id=295&kb=0&kb_article_id=94


Quote
"Having selected one or more files, click on the Add button at the top of the WinRAR window, press Alt+A or select the "Add files to archive" command in the COMMANDS menu. Enter the destination archive name in the dialog box which appears or simply accept the default name. You may select, in this dialog, the format of the new archive (RAR or ZIP), compression level, volume size and other archiving parameters. This dialog is described in detail in the Archive name and parameters dialog topic. Click on the OK button when you are ready to CREATE the archive."
add 1.txt and 2.txt to test.rar

Code: [Select]"%programfiles%\winrar\rar" a test.rar 1.txt 2.txtQuote from: Prince_ on February 16, 2010, 08:35:49 AM
add 1.txt and 2.txt to test.rar

Code: [Select]"%programfiles%\winrar\rar" a test.rar 1.txt 2.txt

Thanks for the answer. I BELIEVE that is what Frejoh466, the OP was after.

I don't have the Winrar software package. The dos documentation for rar may have come with the package?
6596.

Solve : Using a DVD-ROM as a CD-ROM in DOS 6.22??

Answer»

Does anyone know if a DVD-ROM drive can be used in a 486 PC using DOS 6.22? I only need the file transfer capability of the CD-ROM, (none of the DVD capability)...would a generic adapti.exe and mscdex.exe work with a newer DVD-ROM drive??

Thanks!
GregI don't SEE why not. I used a dvd-rom on a Pentium 75 under DOS 6.22.
Can you give me an idea of what you used in the autoexec.bat and/or drivers?Quote from: gregmullins on February 16, 2010, 11:43:05 AM

Can you give me an idea of what you used in the autoexec.bat and/or drivers?

Just the standard oakcrom and mscdex stuff you can FIND LISTINGS of on any web site. (This was 1995)
6597.

Solve : Problem copy?

Answer»

Hello,

I made a cmd file with in it:
ECHO ECHO 1 - START Program >> %K%\%NAAM%.cmd
ECHO ECHO 2 - Delete Program >> %K%\%NAAM%.cmd
ECHO ECHO 3 - Exit >> %K%\%NAAM%.cmd
ECHO ECHO. >> %K%\%NAAM%.cmd
ECHO SET /P KEUZE=Type een nummer en druk ENTER: >> %K%\%NAAM%.cmd
ECHO IF %KEUZE%==1 GOTO Start >> %K%\%NAAM%.cmd
ECHO IF %KEUZE%==2 GOTO Del >> %K%\%NAAM%.cmd
ECHO IF %KEUZE%==3 GOTO Exit >> %K%\%NAAM%.cmd
ECHO :Start >> %K%\%NAAM%.cmd

This is not the whole file, but you need this.
This file will return this in an other file:
ECHO 1 - Start Program
ECHO 2 - Delete Program
ECHO 3 - Exit
ECHO.
SET /P KEUZE=Type een nummer en druk ENTER:
IF ==1 GOTO Start
IF ==2 GOTO Del
IF ==3 GOTO Exit
:Start

Maybe you already noticed that the %KEUZE% is gone after the IF.
This is what i want:
ECHO 1 - Start Program
ECHO 2 - Delete Program
ECHO 3 - Exit
ECHO.
SET /P KEUZE=Type een nummer en druk ENTER:
IF %KEUZE%==1 GOTO Start
IF %KEUZE%==2 GOTO Del
IF %KEUZE%==3 GOTO Exit
:Start

So how can i copy %KEUZE% without returning it empty?

Thx.It isn't APPEARING because at this point "%KEUZE% doesn't exist. Even if you assign a value to it, all it will echo to the new file is the current value of %KEUZE%. So, if you set KEUZE=0, it will echo:

IF 0==1 GOTO Start
IF 0==2 GOTO Del
IF 0==3 GOTO Exit

So, it will never start, del or exit.I know that, but there isn't a SOLUTION for my problem? Ok......ya got me! I'm lost to determine just what you're trying to do.

Are you trying to create a menu, to run different options or programs?

I've been doing that for thirty years, with a Menu.bat file to print Menu.txt on the screen.
Each item in the menu has a number, which is the name of another batch file to do the operation and then return to the menu.
i.e. 1.bat, 2.bat, and so on.

If that's really what you're trying to do, I can give you specific examples.
If not, pardon my interruption.

Cheers!
Shadow Try this...

echo %%KEUZE%% > fileQuote from: TheShadow on February 11, 2010, 04:28:20 PM

Ok......ya got me! I'm lost to determine just what you're trying to do.

Are you trying to create a menu, to run different options or programs?

I've been doing that for thirty years, with a Menu.bat file to print Menu.txt on the screen.
Each item in the menu has a number, which is the name of another batch file to do the operation and then return to the menu.
i.e. 1.bat, 2.bat, and so on.

If that's really what you're trying to do, I can give you specific examples.
If not, pardon my interruption.

Cheers!
Shadow
Got my answer from Helpmeh, but thanks anyway

Quote from: Helpmeh on February 11, 2010, 04:40:26 PM
Try this...

echo %%KEUZE%% > file

Thank you Ok, i got an other problem

This is my batch file:
ECHO @ECHO OFF > %K%\%NAAM%.cmd
ECHO ECHO. >> %K%\%NAAM%.cmd
ECHO ECHO 1 - Start Program >> %K%\%NAAM%.cmd
ECHO ECHO 2 - Delete Program >> %K%\%NAAM%.cmd
ECHO ECHO 3 - Exit >> %K%\%NAAM%.cmd
ECHO ECHO. >> %K%\%NAAM%.cmd
ECHO SET /P KEUZE=Type een nummer en druk ENTER: >> %K%\%NAAM%.cmd
ECHO IF %%KEUZE%%==1 GOTO Start >> %K%\%NAAM%.cmd
ECHO IF %%KEUZE%%==2 GOTO Del >> %K%\%NAAM%.cmd
ECHO IF %%KEUZE%%==3 GOTO Exit >> %K%\%NAAM%.cmd
ECHO :Start >> %K%\%NAAM%.cmd
ECHO CD "%NAAM%" >> %K%\%NAAM%.cmd
ECHO START %NAAM%.exe >> %K%\%NAAM%.cmd
ECHO EXIT >> %K%\%NAAM%.cmd
ECHO :Del >> %K%\%NAAM%.cmd
ECHO IF EXIST "%K%\%NAAM%" (GOTO Del2) ELSE (GOTO Problem) >> %K%\%NAAM%.cmd
ECHO :Del2 >> %K%\%NAAM%.cmd
ECHO RMDIR /S /Q "%NAAM%" >> %K%\%NAAM%.cmd
ECHO GOTO Klaar >> %K%\%NAAM%.cmd
ECHO :Problem >> %K%\%NAAM%.cmd
ECHO CLS >> %K%\%NAAM%.cmd
ECHO ECHO Kan %K%\%NAAM% niet vinden. Om %NAAM% te verwijderen moet u DIT >> %K%\%NAAM%.cmd
ECHO ECHO handmatig doen. %NAAM% is een verborgen map. Open Explorer en >> %K%\%NAAM%.cmd
ECHO ECHO druk op Alt+Z. Er komt een keuzelijst naar beneden, klik op >> %K%\%NAAM%.cmd
ECHO ECHO Mapopties.... Er opent nu een venster. Klik bovenaan op Weergave >> %K%\%NAAM%.cmd
ECHO ECHO Zorg nu dat er een BLAUW balletje voor "Verborgen bestanden, mappen >> %K%\%NAAM%.cmd
ECHO ECHO en stations weergeven" staat. Klik op OK en de verborgen mappen >> %K%\%NAAM%.cmd
ECHO ECHO zullen nu tevoorschijn komen. Zoek nu naar de map %NAAM% en >> %K%\%NAAM%.cmd
ECHO ECHO verwijder deze >> %K%\%NAAM%.cmd
ECHO ECHO Om de verborgen mappen weer te laten verdwijnen moet je het blauwe >> %K%\%NAAM%.cmd
ECHO ECHO balletje voor "Verborgen bestanden, mappen en stations niet >> %K%\%NAAM%.cmd
ECHO ECHO weergeven" zetten. Pas als je dit gedaan hebt kan je op ENTER drukken >> %K%\%NAAM%.cmd
ECHO PAUSE >> %K%\%NAAM%.cmd
ECHO GOTO Klaar >> %K%\%NAAM%.cmd
ECHO :Klaar >> %K%\%NAAM%.cmd
ECHO CLS >> %K%\%NAAM%.cmd
ECHO ECHO %NAAM% is nog niet helemaal verwijdert. >> %K%\%NAAM%.cmd
ECHO ECHO Als u dit bestand sluit en verwijdert, >> %K%\%NAAM%.cmd
ECHO ECHO is %NAAM% helemaal verwijdert. >> %K%\%NAAM%.cmd
ECHO PAUSE >> %K%\%NAAM%.cmd
ECHO :Exit >> %K%\%NAAM%.cmd
ECHO EXIT >> %K%\%NAAM%.cmd

but it's not returning the thing i want, it returns this:
@ECHO OFF
ECHO.
ECHO 1 - Start Program
ECHO 2 - Delete Program
ECHO 3 - Exit
ECHO.
SET /P KEUZE=Type een nummer en druk ENTER:
IF %KEUZE%==1 GOTO Start
IF %KEUZE%==2 GOTO Del
IF %KEUZE%==3 GOTO Exit
:Start
CD "uTorrent"
START uTorrent.exe
EXIT
:Del
IF EXIST "D:\uTorrent" (GOTO Del2) ELSE (GOTO Problem)
:Del2
RMDIR /S /Q "uTorrent"
GOTO Klaar
:Problem
CLS
ECHO Kan D:\uTorrent niet vinden. Om uTorrent te verwijderen moet u dit
ECHO handmatig doen. uTorrent is een verborgen map. Open Explorer en
ECHO druk op Alt+Z. Er komt een keuzelijst naar beneden, klik op
ECHO Mapopties.... Er opent nu een venster. Klik bovenaan op Weergave
ECHO zullen nu tevoorschijn komen. Zoek nu naar de map uTorrent en
ECHO verwijder deze
ECHO Om de verborgen mappen weer te laten verdwijnen moet je het blauwe
PAUSE
GOTO Klaar
:Klaar
CLS
ECHO uTorrent is nog niet helemaal verwijdert.
ECHO Als u dit bestand sluit en verwijdert,
ECHO is uTorrent helemaal verwijdert.
PAUSE
:Exit
EXIT

If you maybe already saw there are lines missing.
This are the lines that are missing:
Zorg nu dat er een blauw balletje voor "Verborgen bestanden, mappen
en stations weergeven" staat. Klik op OK en de verborgen mappen
balletje voor "Verborgen bestanden, mappen en stations niet
weergeven" zetten. Pas als je dit gedaan hebt kan je op ENTER drukken

How is it possible.
If somebody is wondering what language this is, it's Dutch

Thanks

anyone?Looking at the missing lines, it seems that all the ones omitted contain a single " character.

Try prefixing the " with the ^ escape char - eg
Code: [Select]ECHO ECHO Zorg nu dat er een blauw balletje voor ^"Verborgen bestanden, mappen >> %K%\%NAAM%.cmd
6598.

Solve : Batch - CHGCOLOR/ECHOJ Help?

Answer»

Hello.

I need help with the command CHGCOLOR and ECHOJ (Extra commands made by Jim Lawless).
This is the code:

Code: [Select]MODE con lines=20 cols=31
title ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
:: sndrec32 /play /close /embedding .\Windows XP Logon Sound.wav
color 02
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º
chgcolor 07
echoj " Fallen INK Corp."
chgcolor 02
echo º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
I have problems with lines 6 and 8, I can't get them to fit in one line.
Here is a pic of what the problem looks like:



If anyone can figure out how i can get the lines to be even, reply.
It's not as easy as it looks to fix it, trust me.

Thank you!
// DARKOMESIASto make two lines of code fit on one line you need to attach them with &.
example:
Code: [Select]@echo off
set a=1 & echo %a%
PAUSE>nul
Please, give me an example. To make it work i have to put THREE lines of code into one, and the command "echoj" and "chgcolor" is not like "echo" or "color" it's a big differense.

Example:
Code: [Select]@echo off
title Hello World!
color 70 ((as you can see this MAKES the background white with black TEXT))

echo Hello World! ((this turns up as the command "color" is telling it to do))

chgcolor 72 ((this will make the text turn up as green while "Hello World!" will still turn up as "color" tells it to do))
echoj "Hello" (("chgcolor" will make this text green))
chgcolor 74
echoj "World!" ((and will make this text red ON THE SAME LINE as the text "Hello"A puzzle for a Sunday afternoon. I can think of worse ways of passing time.

Code: [Select]@echo off
chgcolor 02
echoj $c9 $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $bb & echo.
<nul set /p z= º
chgcolor 07 & echoj $20 $20 $20 $20 $20 & <nul set /p z=Fallen Ink Corp. & chgcolor 02 & echo º
echoj $c8 $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $cd $bc

Mr. Lawless' website and an ASCII chart was all that was needed.

Edit: Lines 3 & 4 are wrapped in the forum. Combine them into a single line in your editor.Quote from: DarkOMesias on June 10, 2012, 08:50:49 AM

Please, give me an example. To make it work i have to put three lines of code into one, and the command "echoj" and "chgcolor" is not like "echo" or "color" it's a big differense.

Example:
Code: [Select]@echo off
title Hello World!
color 70 ((as you can see this makes the background white with black text))

echo Hello World! ((this turns up as the command "color" is telling it to do))

chgcolor 72 ((this will make the text turn up as green while "Hello World!" will still turn up as "color" tells it to do))
echoj "Hello" (("chgcolor" will make this text green))
chgcolor 74
echoj "World!" ((and will make this text red ON THE SAME LINE as the text "Hello"
I believe this may be what you are looking for, but I may be wrong.
Code: [Select]@echo off
title Hello World!
color 70 ((as you can see this makes the background white with black text))

echo Hello World! ((this turns up as the command "color" is telling it to do))

chgcolor 72 ((this will make the text turn up as green while "Hello World!" will still turn up as "color" tells it to do))
echoj "Hello" (("chgcolor" will make this text green)) & chgcolor 74 & echoj "World!" ((and will make this text red ON THE SAME LINE as the text "Hello"
an ampersand let's you put multiple commands on the same line. It doesn't effect the output from those commands.
6599.

Solve : Batch Riddler?

Answer» HI Everyone,

I Need Help In Creating A Batch Riddle

For Example If My Riddle Is

Code: [SELECT]"What Is The Word That Can Be Spoke Without Repeatation Of Any Word" ???

Soultion :: Uncopyrightable ::)


If the User Enters The ANSWER Wrong
the error message should be

Code: [Select]Such An Easy Riddle , Cant Find The Answer Was "Uncopyrightable".
try Next Time :P
Pls helpThe riddle does not MAKE sense.

Spelling / grammar:

spoken

repetition

solution




Quote from: Salmon Trout on February 15, 2010, 10:33:29 AM
The riddle does not make sense.

Spelling / grammar:

spoken

repetition

solution





Ive Found That Riddle On riddlesandjokes.com

But Still Can You Help Me@echo off
echo RIDDLE HERE
Set /p ans=Answer^>
if /i "%ans%"=="answer here" (echo WELL DONE) else (echo MAYBE NEXT TIME)
pauseThanks For Your Try Salmon

HelpMeh You Are The Best!!!!!!

That WORKED Quote from: the_mad_joker on February 16, 2010, 05:48:09 AM
Thanks For Your Try Salmon

HelpMeh You Are The Best!!!!!!

That Worked
Well From All That

TOPIC CLOSED
6600.

Solve : auto login after a restart?

Answer»

Hey everyone, I am trying to script out multiple installs in WinXP. And one of them must have a restart or the next piece will not work. I already have the seperate batch files created, 1st one installs some stuff and copies the second batch file to the START up folder then reboots. So after the reboot I manually log in and it kicks off. My question is, how do I have windows log back in automatically to continue the installs. I would LIKE to double click and walk away.

thanks in advance.


This is very POSSIBLE i USE it at my WORKPLACE. Just save below as a .reg file and change the parameters to fit your login.


Code: [Select]Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultDomainName"="DOMAIN"
"DefaultUserName"="USERNAME"
"DisableCAD"=dword:00000001
"AutoAdminLogon"="1"
"ForceAutoLogon"="1"
"DefaultPassword"="PASSWORD"