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.

4451.

Solve : dos program error?

Answer»

I have a dos program created in foxpro for dos 2.6. It runs smoothly in WIN98 but when i TRY to run it in win2000 a message appear "Invalid database number".

Hope anybody could HELP me.The Windows 2000 version of Microsoft Data Access Components (MDAC) MAY not support DOS FoxPro 2.6.

There are upgrades and patches for DOS FoxPro 2.6.

Check out: http://support.microsoft.com/kb/q102893/

Just some thoughts.

PS. Please don't post the same message multiple TIMES on different boards.

4452.

Solve : Compatibility MS-Dos - 2003 Server ????

Answer»

Hello all,
I TRY to do a NETWORK with MS-Dos and 2003 Serv.
I want to KNOW if 2003 S. is compatible with MS-Dos?
Because when I do a "Net Use" the new drive is create but i haven't the right to read the folder...
Maybe a too high level security (Policy...??)
Can you help me ?? (Sorry for my english..... lol )Your DOS machine may need drivers. CHECK out DOS-Client for Microsoft Networks

This may be HELPFUL or give you some ideas.

Good luck.

4453.

Solve : Rename duplicate files?

Answer»

Several people here at my office scan FILES onto their C drive during the day. At night time we run a batch file which will copy those files to a central file server.

My problem comes when a file name already exist on the server, thus leaving the would-be copied file sitting on the C drive. This then requires me to MANUALLY add a 1 to the end of the file name then copy.

Here is what my existing batch file looks like:

Code: [Select]
rem @echo off
dir \\scanner1\scan >> c:\scanm\scanm1.log

move /-y \\scanner1\scan\pic*.* e:\data\arch\scan\pic >> c:\scanm\scanm1.log
move /-y \\scanner1\scan\doc*.* e:\data\arch\scan\doc >> c:\scanm\scanm1.log

dir \\scanner1\scan >> c:\scanm\scanm1e.log


I would like to add something into this batch file so say if say I try to copy a picturesky.jpg to the server and there already exists a picturesky.jpg, it will rename the new file to picturesky1.jpg or something of that nature.

Any thoughts or HELPS would be appreciated.You mentioned a server environment, so this may work:

Code: [Select]
set from=\\scanner1\scan
set to=e:\data\arch\scan\pic

for /f "tokens=1-2 delims=." %%a in ('dir /b %from%\pic*.*') do (
if not exist %to%\%%a.%%b (move /-y %from%\%%a.%%b %to% >> c:\scanm\scanm1.log) else (call :FindPic)
)
GOTO :eof

:FindPic
call set /a tail=%%tail%%+1
if not exist %to%\%%a%tail%.%%b (move /-y %from%\%%a.%%b %to%\%%a%tail%.%%b >> c:\scanm\scanm1.log & set tail=0) else (call :FindPic)


FindPic is recursive to find the next available file name. A better solution would be Windows Script

Hope this helps.

PS. The code SNIPPET for pic* files. You can take care of the doc* files.

4454.

Solve : Store each line of file content in an array?

Answer»

Hi Fellas,


Could SOMEBODY help please. Basically, I have an output file, the content of which I would like to hold in an array to ENABLE me carry out some action, line by line.

For instance, let's just say my output file has the following 2 lines:

************************

c:\temp\myFiles\print.java
c:\temp\myFiles\copy.java

************************

I then want to be able to use a for loop to recursively perform a certain action on each file. For instance, I would like to be able to copy each file to a SPECIFIED destination.

How can I get round this?Use a for loop to read thru the file, no array NEEDED. Based on your sample file, this may work:

Code: [Select]
for /f %%a in (output.file) do (copy %%a destinationpath)


If you had mentioned what PROCESS had created this output.file, it might be possible to incorporate it into the FOR loop also.

Hope this helps.

4455.

Solve : nested files renaming?

Answer»

Hi all,

I WOULD like to rename all the files (including in the nested folder) to other name. What is the COMMAND for that.

RENAME will rename the current folder's files. But I would like to rename the files in the nested FOLDERS too. How to do that?

Regards,
PRASAD UREN [drive:][path]filename1 filename2

[GLB]Gizmo73[/glb]

4456.

Solve : compute execution time?

Answer»

i don't know how to compute the time that it takes for a batch file to execute.
i also have a folder(named "a" for example) and i want to
keep some files and some folders( folder "b" and files "c" and "d" for example) and delete all the rest("b","c" and "d" are INSIDE the folder "a").
Does ANYONE have any ideas???

thanks in advance...Copy the files to the root of "a" that you want saved and TYPE RD on each directory you want removed.

[glb]Gizmo73[/glb]Batch language does not do date or time calculations, unless you are prepared to write a boatload of IF statements or complex RECURSIVE routines.

One idea, put a time /t > batch.log statement at the beginning and a time /t >> batch.log statement at end of your batch file. You'll have to do the actual arithmetic.

Hope this helps.

4457.

Solve : login password by Batch file?

Answer»

When I OPEN an application that is password protected using a bat.file, how can I have it automaticly enter the password in the login BOX. ex. OPENING a ms ACCESS datadase that is password protected.I doubt a batch file can do this. The batch file and the application are running in two separate data spaces. Try Windows Script which has a SendKeys method.

If you are just going to circumvent the protection, why password protect the file at all?

Good LUCK.

4458.

Solve : Bat file for play/eject cdrom?

Answer»

Old age.....i had it somewhere.....and now after**** years i decide to use it......but can remember the script..long script....is all i can give you.Merlin,

This script will EJECT a CD:

Code: [Select]
Dim WMP: Set WMP = CreateObject("WMPlayer.OCX")
Dim CDROMs: Set CDROMs = WMP.cdromCollection

'If CDROMs.Count >= 1 Then
' For i = 0 to CDROMs.Count - 1
CDROMs.Item(0).Eject
' Next
'End If

Set WMP = Nothing
Set CDROMs = Nothing
WScript.Quit


The above script will eject the first CD it FINDS. Make changes if you have more than one. If you uncomment the lines marked ' , all the CD drives will pop open.

As for playing a CD, just execute the PROGRAM that created the file. Most applications allow a command line argument for opening a file when the app is loaded.

Hope this HELPS. Thanks SIDEWINDER.......i will execute it when i get a chance.

Jul 22nd, 2005, 3:15pm

update: Code works ok......nice one! seemed shorter t then the one i had!

4459.

Solve : saving variable as a file for later use?

Answer»

Hi,

I know this will be a real EASY question for most of you. I use the bat script below to back up files from one computer to another. What I want to do is save the value of the %input% variable to a file at the root of C:\. I have another batch file that I run on a new computer that will RESTORE all the files I have backed up. I would like that bat script to read the value in the file on C:\ of the backup computer and assign it to the %INPUT% variable on the new computer. In essence what I want to do is transfer the value of a variable from one computer to another. I am not a programer, I just did some cutting, pasting, and modifying to make this script, so go easy on me. Thanks in advance for your help.

Charlie

@echo off
echo Enter Computer Name You are Transfering Files From and Press ENTER:
REM This gets the From Computer Name and stores it as %Input% variable
FC con nul /lb1 /n |FIND "1:" > %temp%.\t1.bat
echo e102'set %%1='> %temp%.\t2.dat
for %%? in (w q) do echo %%?>> %temp%.\t2.dat
DEBUG %temp%.\t1.bat < %temp%.\t2.dat > nul
call %temp%.\t1.bat INPUT
for %%? in (t1.bat t2.dat) do del %temp%.\%%?
Echo
echo Enter Computer Name You are Transfering Files To and Press ENTER:
REM This gets the To Computer Name and stores it as %Input1% variable
FC con nul /lb1 /n |FIND "1:" > %temp%.\t1.bat
echo e102'set %%1='> %temp%.\t2.dat
for %%? in (w q) do echo %%?>> %temp%.\t2.dat
DEBUG %temp%.\t1.bat < %temp%.\t2.dat > nul
call %temp%.\t1.bat INPUT1
for %%? in (t1.bat t2.dat) do del %temp%.\%%?
Echo
:BEGIN
CLS
ECHO PLEASE CHOOSE THE MACHINE YOU ARE TRANSFERING FILES FROM
ECHO (1) OS
ECHO (2) OSJ
ECHO (3) CD
CHOICE /N /C:123 PICK A NUMBER (1, 2, or 3)%1
REM - THE NEXT THREE LINES ARE DIRECTING USER DEPENDING UPON INPUT
IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END
:THREE
mkdir \\%INPUT1%\c\%INPUT%
mkdir \\%INPUT1%\c\%INPUT%\Cd
xcopy /E C:\Cd \\%INPUT1%\c\%INPUT%\Cd
GOTO END
:TWO
mkdir \\%INPUT1%\c\%INPUT%
mkdir \\%INPUT1%\c\%INPUT%\Jr
xcopy /E C:\Jr \\%INPUT1%\c\%INPUT%\Jr
GOTO END
:ONE
mkdir \\%INPUT1%\c\%INPUT%
mkdir \\%INPUT1%\c\%INPUT%\Os
xcopy /E C:\Os \\%INPUT1%\c\%INPUT%\Os
:END
EXIT

Before someone goes blind reading your post:

Is this a Windows machine and if so what version?

What is the DEBUG program you create on the fly expected to do?

Let us know. Hi,

I am writing this batch file on a windows 98 machine. The code I posted basically copies specified files on the machine it is run on to another computer (as specified by %Input1%) and to a specific folder (as specified by %input%).

When I setup a new machine I will need to copy said files onto the new machine. I want to be able to run a batch file on the new machine that will do this. I would like the bat file to be able to read the original %Input% value as originally assigned. Hope that makes a little more sense. Thanks for your help.

ChalrieThere is a NIFTY little utility Answer that will eliminate half your file.

ANSWER allows you to prompt for user data and store it in the environment space. Each time it runs the environment variable is overwritten, so be sure to save each value to your own variables. Put into a directory along your path and you can use it anywhere.

Code: [Select]
answer Enter Computer Name You are Transfering Files From:
set from=%answer%
answer Enter Computer Name You are Transfering Files To:
set to=%answer%
:BEGIN
.
.
.


Using fc to prompt for input is an old DOS trick which may not work anymore in Windows, CON and NUL are invalid in this context.

Good luck.

4460.

Solve : redirecting input in a DOS batch file?

Answer»

Hello,
I'm not very experienced with DOS so this may seem kinda basic. I have a DOS program that takes command line input and I want to write a script to execute it. In unix (K-shell) I might write something like:

/bin/ksh
program << +
2
inputfile.dat
outputfile.dat
3
+

in a text file and make it an executable and run it.
How would I do this in DOS and do I call the file a .bat file? I'm running Win ME w/ the MSDOS prompt. Let me know if I need to define the question better.If i understand you CORRECTLY all your wanting to do is pass parameters to a dos batch.....? if so DOS uses the "%" to reference external parameters. they are assigned sequencially 1 thru 9 and then you use the shift if you need more.

example

runaprg.bat a data.dat

this how you would write runaprg.bat

echo off
if %1==a goto myproga
if %1==b goto myprogb
goto notvalid

:myproga
myaexe %2
goto end

:myprogb
mybexe %2
goto end

:notvalid
echo ... %1 is not a valid entry

:end

i use a batch file to format a diskette on the a drive and i do not want a bunch of yes no questions

so i have a batch file called formata.bat

the batch file says

format a:/q/u

is this what you want to do?
???Just call the executable from the .bat file along with the parameter you wish to pass. The entry would be EXACTLY like you would enter from the command line, providing the DIRECTORY is in the path. OTHERWISE, you would use cd command to change to the proper directory.This is standard UNIX syntax called "at document" to invoke a series of commands sequentially after having started some program.
I need the same functionality to connect to a database and then run specified commands.
Beginning to think it's not possible in DOS.
Thanks enormously in advance for any CLUES.

4461.

Solve : Easy Q...Cant Find Answer?

Answer»

Hey peoples,

just wondering how to start the computer in ms dos mdoe without using a BOOT disk - iv done it before but cant remember how to - iv searched the NET high low and everyone keeps suggesting using a boot disk - (my a:/ is FUK'd)

cheers for NE help

Simosorry, im talking about XP osPush the F8 key while the computer is booting.

4462.

Solve : Compare listed files & get diff file names?

Answer»

Hi All,


Could anyone help on this please. This is the scenario:

I have two parent folders with nested folders and files.
The FOLDER contents are pretty much identical, although between the two, a file might be missing/exist in one folder, but not the other.

I have managed to generate two output files listing all files in each directory tree. The list gives the full paths.

My objective is now to be able to RECURSIVELY traverse both folders and perform the following:

1) Generate a report of all files that are not common to both directories, i.e. files appearing in one list but not the other.

2) Where a file appears in both lists, carry out a file compare to establish whether they differ. If they differ, echo the file name to a final output file.

Any ideas fellas?


Thanks.

Are you writing Windows Script or batch file logic? Also let us know your OS.

I'm also unclear about #2. What file name? The one from folder1 or folder2. Even though the file names are the same, they have different paths. There are two compare file commands (fc and comp) that may be helpful. Writing your own logic for file compare can be a nightmare, especially for files of unequal length (the files have to be resynched each time a difference is found).

Get back to us. Hi Sidewinder,

Sorry if I failed to explain fully. Now then, here goes:

Let's look at it this way:

Say I have made two software releases. All source code are held in a source control repository.

I now need to identify the following:

1/ Which files are deprecated from the older release

2/ Which files are in the new release, but not in the old

3/ Which files were common to both, but are modified

Sadly, my source control tool does not have the capability of carrying out the above and so I have to rely on good and trusted batch scripting.

As such, I proceed to export all files making up each release to two locations, in order to carry out a file compare.

I now want to recursively compare the files within each folder, making sure the comparison starts from a common folder name at each location, e.g. \myFiles\.., as PER below.

\\server1\myFiles\print.java - Revision 1 (Release 1)

\\ server2\myFiles\print.java - Revision 2 (Release 2)

Note that the fact we have different revisions for the above file does not necessarily mean they are different by content.

Now by way of a batch COMMAND, I wish to carry out a compare of both revisions.

Should my comparison reveal that the two revisions differ, the next step will be to carry out a specific action, such as a deployment of the NEWER revision, to a specified location. If they're the same, no action is carried out.

I hope you've now got a gist of what this is all about. By the way, my OS is XP Professional.

Thanks for your assistance.

Batch language. Hmmmmm.

Just some pseudo code. You may get some ideas. I sure hope the directory trees on both servers are identical.
Code: [Select]
set server1=\\server1\myFiles
set server2=\\server2\myFiles

for /f %a in ('dir /a:-d /b /s %server2%\*.*') do (
call set pgm=%%%a:~18%
if exist %server1%\%pgm% (echo ver1:yes ver2:yes %%a) else (echo ver1:no ver2:yes %%a)
)

for /f %a in ('dir /a:-d /b /s %server1%\*.*') do (
call set pgm=%%%a:~18%
if exist %server2%\%pgm% (who cares, do nothing, posted in first FOR) else (echo ver1:yes ver2:no %%a)
)


Questions:

1. If pgm is in ver 1 and ver 2, does not ver 2 trump ver 1?

2. If pgm is in ver 2 but not ver 1 is this not a new pgm?

3. If pgm is in ver 1 but not ver 2:
pgm deprecated?
pgm unchanged from ver 1? copy to ver 2?

Arrays might work too, but you'd suck the all the oxygen out of the environment space. I can't see any reason to do file compares, but maybe I'm missing something.

Hope this helps.

4463.

Solve : Print from DOS Batch File?

Answer»

I am running a SQL DTS Extract to an Excel spreadsheet. I would like to print this spreadsheet from a DOS batch file so I can schedule it using Task Manager, but don't know the syntax.

We are a Terminal Services, so our printers are all defined on a DOMAIN Controller. I've LOOKED at the PRINT command but can't seem to GET it to work.

Any ideas from the experts?

Thanks,
LeslieTry printing the XLS from within Excel. If you pass along the spreadsheet name on the Excel command line, it will OPEN the workbook and then use an Auto_Open macro (that you write) to do the printing of the entire workbook or selected sheets.

Excel workbooks contain many special characters and probably confuse the PRINT command.

Hope this helps.

4464.

Solve : Installing Driver for CD, with no operating system?

Answer»

I recently got a new hard drive for my Compaq Deskpro 6000, and installed a new CD-ROM, because the ORIGINAL one broke.
Anyways, the CMOS was reset, etc. Everything on a clean slate.
So, I WANT to INSTALL Windows 95, but the CD-ROM has no DRIVER, so I can't. As well, I don't even have MS-DOS on it. I can only get prompt by using the Windows 95 boot disk.
Even when I put in the bootdisk to install Windows CD, the boot disk doesn't have the driver needed for the drive.
I really need help, running out of patience:(TRY a Windows 98 bootdisk from bootdisk.com

4465.

Solve : cmd programs?

Answer»

I have CMD in the C drive, not in any folders, and i want to open FIREFOX with it, but when I try to enter it(program files\mozilla firefox\firefox.exe) it SAY " ' Program' is not reconzined etc etc... i need helpFirefox is a windows program & it won't work on DOS.

4466.

Solve : USB Printer...?

Answer»

Hi,
My NEW shiny HP printer/scanner/copier/invisible friend all in one printer is not recognised by dos. Is it because it connects via the USB port?Refresh us! As to what OPERATING system does this question concern? does the keyboard OPTION WORK prnt screen....I am RUNNING windows xp. when in the dos window it does not recognise my usb printer. Is there nothing I can do? the oonly ports on option are lp1 and lp2

4467.

Solve : starting in DOS?

Answer»

How do I shut down my COMPUTER running Windows XP and restart in DOS Hold down the f8 key on boot up......CMD PROMPT....its not dos anymore..... C:\> windows help /? and list of COMMANDS will appear if that is what you are after....

4468.

Solve : How to get the first character of the argument?

Answer»

Hi All,


How to get the first character of command line argument from DOS Batch command?

Regards,
Arjun.Apparently only environment variables can be expanded and not command line variables. There is ALWAYS a way to do things in the bizzare WORLD of DOS.

Code: [Select]
set var=%1
set var=%var:~0,1%

Hope this helps.

PS. OS DEPENDENT: not Win9x

4469.

Solve : Save on a floppy with MS-DOS?

Answer»

If I need to save a document to a floppy from MS-DOS what do I do.

It's name is gatsbyloveletter.doc (Microsoft Word).Use Windows Explorer. Find the file and holding down the left MOUSE BUTTON, drag and DROP the file ONTO the floppy drive...usually drive A:

OR (WINXP or 2000)

copy gatsbyloveletter.doc A:

OR (Win9x)

copy gatsbylo~1.doc A:

OR

while in Word do a saveas directly to the A: drive

Hope this helps.

4470.

Solve : command for Bypass dos to BIOS call?

Answer»

Problem:

NEED to flash BIOS. (wrongly flashed BIOS)

If I do floppy boot, computer doesn`t go to command LINE, but hangs in ceartan stage.
So I guess, that dos MAKES some call to BIOS , and thats why it hangs.
Thats why I want to ask you, if you know any commands to put into config.sys, to specify dos , not to make call to BIOS.

Any ideas ?I'm not aware of any config.sys directive that will help you out. If you flashed the wrong BIOS into the machine, you MAY have to bring it to a shop where they can re-write with the proper content using an EPROM writer machine.

Good luck. Hey

I made the Hot Flash

And now it works. But I was just wondering, is there any possibility.Any possibility of what?

4471.

Solve : Computer Registry Question?

Answer»

(maybe this is the wrong forum, but HELP would be appreciated anyway!)

How do I access the Computer REGISTRY to view it, and if possible, remove unwanted bits? Had a lot of spyware junk in my machine. Wondering if i can clean up the registry now that the comp is protected again.You can run regedit from the Windows run box. Protect yourself by creating a restore point (on some Windows systems) or backing up (exporting) the registry before making any changes.

Be CAREFUL when messing around with the registry. You can make Windows unusable. well, initially, i just want to be able to look at it and not change or delete anything.

this should be okay. anyway, BELIEVE me, my windows couldn't be any more unstable than it was recently!!

i assume i can go in and look and then just EXIT??Yes you can...and much safer too!

4472.

Solve : URGENT PROBLEM!!?

Answer»

lo,
I have a problem...
since yesterday my harddisc crashed and I can't reboot my computer now...
There are some very very important files on it so i realy have to recover the files.
I think there is a way threw MS-DOS.. but I dont know how to do that:s


Some1 plz help me if u can help me!

Greetz, FrederikScanreg/fix.........or scanreg/restore....commands may do it...jeah I could try that..
but I can't reboot my computer:s
How can i type that in DOS then?

Greetz.You can download a bootdisk from Boot Disks although I don't know how that will help you out. Did the disk head PHYSICALLY touch the disk surface or are you just having problems booting the machine. DATA recovery services can be very expensive.

It cannot be stressed ENOUGH that everyone should backup their system on a regular basis. Yes, it's time consuming, but some data can never be reproduced or recovered.

Good luck. Please DESCRIBE Exactly what happens when you Hit the Start Button on your computer....
Does ANYTHING at all happen, what happens?

4473.

Solve : shortcut key?

Answer»

For a batch file.

Right clcik -> PROPERTIES->"program" tab

In the field "shortcut KEY" i assigned "ctrl+alt+X"

but after pressing "ctrl+alt+x" the batchfile won't run.

what's the reason?What bat file is it
It is

start/w site1

Pause

start/w site2

pause

start/w site3

where SITEX is the url of site number x

4474.

Solve : Here is a bat file code that makes your pc faster!?

Answer»

here is a bat code that clears all history and cookies on your pc.{makes it FASTER}:
Code: [Select]
cls
@ECHO OFF
ECHO. ***********************************
ECHO. ** Clean Cookies and Temp Files **
ECHO. ** Will not work in NT **
ECHO. *******************************
deltree /y c:\WINDOWS\cookies\*.*
deltree /y c:\windows\tempor~1\*.*
deltree /y c:\progra~1\Netscape\Users\default\Cache\*.jpg
deltree /y c:\progra~1\Netscape\Users\default\Cache\*.gif
deltree /y c:\progra~1\Netscape\Users\default\Cache\*.htm
deltree /y c:\progra~1\Netscape\Users\default\archive\*.htm
deltree /y c:\progra~1\Netscape\Users\default\archive\*.gif
deltree /y c:\progra~1\Netscape\Users\default\archive\*.jpg
deltree /y c:\windows\temp\*.*
deltree /y c:\temp\*.*
deltree /y c:\windows\Recent\*.*
deltree /y c:\recycled\*.*
cls
EXIT

paste it into a notpad document and SAVE it on your desktop as "junksquash.bat". Then double click on it to use!!(please reply if it helps)!!DELTREE does not EXIST on all flavors of Windows and not all users have Netscape installed. A better approach would be a script that queries what browser is used and then take any appropriate action.

The DELTREE COMMAND has been replaced by the DEL command and the /s switch in some editions of Windows. Complications arise when an application is not installed in the default directory. A well written script would need to follow the installation path to know where various files are located.

Just my 2¢ worth. sorry
sidewinder (I was wondering why it says you're a computer expert?)I used this and it hhelped me out a little bit more and I have win98.

4475.

Solve : Help..?

Answer»

How do I go from c:\Documents and Settings\Fam.jacks> to just c:\? Everytime I type c: it just goes back to c:\Documents and Settings\Fam.jacks>.. Pretty irritating, dunno what to do cuz I never use MS-DOS.

Can anyone HELP with my nooby-problem ^^?

Grtz, Bubba.In your CASE type cd \

Also consider:

cd directoryname CHANGES DIRECTORY on the CURRENT drive

cd /d drive:\directoryname changes both drive and directory

pushd drive:\directoryname changes both drive and directory

Hope this helps. In your case type cd \

Yep! Thanks for your help !

4476.

Solve : working on a bach for homwork to help clear thing up?

Answer»

I am trying to get a batch file work here is the codeCode: [Select]CLS
@Echo on
Rem =======who knows=======
pause
Rem =====This is my txt batch===
pause
echo off
K:
cd wugxp
Dir *.txt /w /P
cd ..\
k:
cd wugxp\games
Dir *.doc /w /p
xcopy ls.doc C:\longshot.doc /v/w/r
cd..\..\
and I keep on getting a error when it getting rdy to xcopy that reads
File creation error - A required privilege is not held by the client.
I'm trying to copy from drive K:\ to drive c:\ If you can help that be grate.
i got it fixed
mdf1,
I don't have a K: Drive. I used D: Drive. I did not use xcopy but instead used copy. I named the batch file kay.bat. The batch file, kay.bat listed first and then the output is listed. This should get you started. Good Luck

See Post # 10 below:billrich, i think its been told you before, use code tags when POSTING your code. make it easier to read. Put code tags also if you want to demonstrate the output of your batch/script.Ghost wrote:
"If you want to demonstrate the output of your batch/script."


To demonstrate the output is as important as the code.Quote from: billrich on March 21, 2009, 02:41:30 PM

Ghost wrote:
"If you want to demonstrate the output of your batch/script."


To demonstrate the output is as important as the code.

So, naturally- you cannot use code tags? You'll only get a sore head, BC_P, if you bang it against this particular BRICK wall.
Quote from: Dias de verano on March 21, 2009, 03:40:28 PM
You'll only get a sore head, BC_P, if you bang it against this particular brick wall.


you're probably right- it only looked like the MORTAR was CRACKING. Which is more important: The message or the vehicle?

We all should be clones of each other?


p.s. The code Tag was added. Don't worry; be happy.


To be the same as my fellow Clones, I must get a Tattoo@billrich, please see picture of what it means to put your code in code tags.

[attachment deleted by admin]To:
Ghost Clone,

Here is the code asked for by mdf1 in post # 1 above

From:
Bill Clone

Code: [Select]C:\>type kay.bat
@Echo OFF

D:

cd \
dir wu*


Pause
REM D: will take us from C:\ drive to D:\ drive; I do not have a K: drive

cd wugxp

Dir *.txt /w /p
cd \
REM Cd \ will return to root directory D:\

cd wugxp\games
Dir *.doc /w /p

REM The following copy will copy D:\wuxp\games\ls.doc to C:\longshot.doc

REM xcopy ls.doc C:\longshot.doc /v/w/r ( do you need xcopy? )

copy ls.doc C:\longshot.doc

C:\>
To:
Ghost Clone,

Here is the Output for the Kay.bat batch file:

From:
Bill Clone

Code: [Select]C:\>kay.bat
Volume in drive D is My Book
Volume Serial Number is 0850-D7C5

Directory of D:\

03/20/2009 09:24 PM <DIR> wugxp
03/20/2009 09:43 PM <DIR> wuxp
0 File(s) 0 bytes
2 Dir(s) 138,952,855,552 bytes free
Press any key to continue . . .
Volume in drive D is My Book
Volume Serial Number is 0850-D7C5

Directory of D:\wugxp

caavsetupLog.txt caisslog.txt christmas.txt
count.txt date.txt db.txt
disklog.txt for.txt homewk.txt
Instruct_for.txt listone.txt list_of_program_files.txt
log.txt noperiod.txt period.txt
pipe.txt show.txt str3.txt
task.txt temp1.txt testfilnam.txt
x.txt xmas.txt xxx.txt
z.txt zeke.txt
26 File(s) 828,670 bytes
0 Dir(s) 138,952,855,552 bytes free
Volume in drive D is My Book
Volume Serial Number is 0850-D7C5

Directory of D:\wugxp\games

ls.doc
1 File(s) 4,195 bytes
0 Dir(s) 138,952,855,552 bytes free
1 file(s) copied.

D:\wugxp\games>C:
4477.

Solve : Finding a specifc file across multiple drives?

Answer»

Sorry if this can be found elsewhere on the forum, but after a half dozen searches using VARIOUS phrases I couldn't find the answer.

What I need help with is how to find a specific "flag" file that resides in the root directory of a drive. It's probable that the drive letter will change which is why I need to be able to iterate through the list of drives on the machine.

Pseudo code would be:

Code: [Select]for each DRIVELETTER in E: - Z:
if exists flag_file.txt
set X = driveletter
return
end
end

do something with X

Thanks for your help.
Henry
coding is base on your pseudocode:

Code: [Select]@echo off

for %%a in (e F g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\flag_file.txt (
set x=%%a:\
goto:x
)
)
if not defined x echo flag_file.txt Not Found & goto:EOF
:x
echo First Found Drive=%x%
Quote from: Reno on March 21, 2009, 05:55:34 AM

coding is base on your pseudocode:

Code: [Select]@echo off

for %%a in (e f g h i j k l m n o p q r s t u v w x y z) do (
if exist %%a:\flag_file.txt (
set x=%%a:\
goto:x
)
)
if not defined x echo flag_file.txt Not Found & goto:eof
:x
echo First Found Drive=%x%

That's perfect! I knew that there had to be an "elegant" way of doing this, but finding good documentation on the use of the For command hasn't been easy.

Many thanks!!

- Henry
4478.

Solve : cleanmgr?

Answer»

Hi all

1-)if I write cleanmgr on CMD a window appear to choose the disk I want to CLEAN

can I choose the disk from CMD?

2-)How can I make a program works in background?

thank youWhat do you mean by 'Clean Disk'?hello

Quote

What do you mean by 'Clean Disk'?

clean the disk means:
delete:
- Download program files
- Temporary internet files
empty recycle bin
clean setup log files
and others you can see by opening cleanmgr

thanks

Try: cleanmgr /d drive_letter:

hhhhh

very very good

thanks a lot

what about RUN tha batch file in the back ground?You COULD use: Code: [Select]start "" /min batch_file_namethaaaaaaaaanks I run Window's Disk Cleanup a bit differently.

I run the "Extended Disk Cleanup" using this shortcut:

%SystemRoot%\System32\Cmd.exe /c Cleanmgr /sageset:35 & Cleanmgr /sagerun:35

It works great to remove much more JUNK than just cleanmgr by itself.
But here's my problem,,,,, It automatically scans every drive in my system and that's SIX. That wastes a lot of time. I only want it to scan drive C: and then quit.

I've tried putting /C: in the line in several places but nothing works. It still scans all drives.
Does anyone know how to force it to scan C: and then quit.

Shadow Did you try:

Code: [Select]%SystemRoot%\System32\Cmd.exe /c Cleanmgr /d C: /sageset:35 & Cleanmgr /sagerun:35
4479.

Solve : Help needed to write simple batch program?

Answer»

I need to create a batch program which will call a particular executable FILE, change some options in that file, and then execute it.

Example:
I have called an executable file MPTDemo...(ALREADY done this much atleast)
But this opens a window in which i have to select an option from the drop down list(which i want to set as default) and should move to the next window by auto-clicking "ok" and the next window again should be by-passed by clicking "ok"...because THAT is when my actual program will execute.

Some help please!!!
I'll put up screenshots also, of what i wanna do, if that makes it any clearer!Ah, good old batch file writing.

Well what exactly are you trying to do.

What screens pop up exactly?
If the selection is in the CMD window you will most probably be able to add a LINE of code which will auto select.
But we need screen shots.

Quote from: kizza1645 on March 19, 2009, 04:56:05 AM

What screens pop up exactly?
Quote from: confusedgalvandana on March 19, 2009, 02:47:06 AM
But this opens a window in which i have to select an option from the drop down list

nt dos doesn't have drop-down list, so it's certainly a windows program. no, you can't click-clack-click windows prog from cmd.exe. another option is to write the code in wscript (already installed by default), or download 3rd party software, such as autoit, or write it in high-level language, such as VB, VC++, etc.

which one do you prefer?Thank you for replying
Yes, the program that i'm trying to run IS a windows program.

Well actually, the application that we automatically want to invoke is itself coded in VC++, so i'm guessing i should somehow change the code of that application such that it takes the option i want by default?

The problem i have though, is that the code is extremely complex to understand and i cant figure out where the code for the dropdown list exists among all the project files and workspaces...

Can i code in VC++ the default options i want...and bypass the rest of the windows (2 of them) coz all i have to do is click "ok" on them both. I want to bypass that and move onto the third screen which is the actual executable.
At the same time i want to auto-invoke that application....which is why i thought i should use batch programming.

Any thoughts on this?if you have the source code, why would you code the 2 DialogBox in the first place? since it's not going to function anyway.

Comment the line(s) where it create the instance of 2 DialogBox, then rebuild the executable.

Quote from: confusedgalvandana on March 19, 2009, 06:44:10 AM
At the same time i want to auto-invoke that application....which is why i thought i should use batch programming.
create a shortcut in desktop or start menu???
this make me wonder if you did write the code yourself.I did not write any code in that application...it's an already existing application for which i downloaded the source code(freely available on the same site) and i have been working on for the past couple of weeks...i am just using the application...but i want it to conform to particular conditions....which it is not..

And by auto-invoke....i meant that it should start without any person having to click on it....the kind of application that i am developing needs a person to be monitored continuously...i want my program to check for a few conditions and if they are satisfied, i want this application to be invoked.

The name of the application i'm working with is Machine Perception Toolbox(MPT).
I have already mailed the authors of the software too....but awaiting reply.
All i wanted to know was if its possible to write code such that in the first two windows "ok" option is selected so that directly the 3rd window is displayed.Quote from: confusedgalvandana on March 19, 2009, 07:21:19 AM
And by auto-invoke....i meant that it should start without any person having to click on it....the kind of application that i am developing needs a person to be monitored continuously...i want my program to check for a few conditions and if they are satisfied, i want this application to be invoked.

I may be wrong but it sounds like you are trying to have a program start and monitor what some one is doing with out them knowing. If so there are already programs out there that will do this. Is this for a company or home?Hey...no...the person knows he is going to be monitored...basically we are using a tool that allows us to monitor and count the rate at which a person blinks (which may SOUND kinda stupid! but thats what we wanna do)..

Anyways the screenshots are attached.
&GT;

In the screenshot, the first one opens automatically....i want to find a way to automatically select "blinkDetector" from the dropdown list and "ok" to be clicked so that it directly opens the 2nd dialog box.

And this is not for any company, its a project i've taken up, thats all.

Please help!!


[attachment deleted by admin]In the first place, is it even possible to manipulate applications involving windows dialog boxes using batch programming?? Quote from: confusedgalvandana on March 19, 2009, 11:32:34 PM
In the first place, is it even possible to manipulate applications involving windows dialog boxes using batch programming??
from my few months experience in Batch, i am certain the answer is no. but if someone know how to control windows program from pure batch, i really realy want to know how to do it.

here is the vbs code: (untested, i dont have the software)
Code: [Select]with createobject("wscript.shell")
.run "c:\program files\your exe program here",1,false:wsh.sleep 1000
if .appactivate("Projects") then
.sendkeys "{down 4}~~"
else
wsh.echo "Unable to activate Projects"
end if
end with

to run it double click the vbs file in windows explorer.
or type in command prompt:
cscript//nologo auto.vbs
or
wscript//nologo auto.vbs

if you want to auto-invoke, you could put it in startup folder, or modify registry in the run section, or use a taskscheduler.

because you have the source code, you could modify it also. but reading someone else source code is a very very tedious job.
4480.

Solve : Changing delimiter in a text file.?

Answer»

Hi All

I currently have a text file in the format of:

"Name","Customer Document","{Sequence Number}","773","{Batch Class Name}","Name","{Document FORM Name}","Bank Code","Customer Number","11111","Customer Name","ABC","{Scan Operator's Station ID}","Highbury01","{Batch Creation Date}","2/13/2009","{Batch Creation Time}","10:48:54 AM","\\Images\00000190.TIF"

where each value is delimited by a comma(,).

How would i write a batch file which is going to acess this .txt file on a daily basis, and convert all comma (,) values into pipe ). so it will look as follows:

"Name"|"Customer Document"|"{Sequence Number}"|"773"|"{Batch Class Name}"|"Name"|"{Document Form Name}"|"Bank Code"|"Customer Number"|"11111"|"Customer Name"|"ABC"|"{Scan Operator's Station ID}"|"Highbury01"|"{Batch Creation Date}"|"2/13/2009"|"{Batch Creation Time}"|"10:48:54 AM"|"\\Images\00000190.TIF"

I know i can find and replace in notepad but i'd rather have a batch file created and added to a schedule so that there is no human intervention.few ways
1) vbscript
Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject")
Set d = CreateObject("Scripting.Dictionary")
strFile = "C:\test\file.txt"
Set objFile = objFS.OpenTextFile(strFile,1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
WScript.Echo Replace(strLine,",","|")
Loop

2) specific text processing tools like sed and (g)awk will do the job. these tools can also be found in Microsoft Services for Unix (if you have it).
Code: [Select]C:\test>sed "s/,/|/g" file.txt
"Name"|"Customer Document"|"{Sequence Number}"|"773"|"{Batch Class Name}"|"Name"|"{Document Form Name}"|"Bank Code"|"Cus
tomer Number"|"11111"|"Customer Name"|"ABC"|"{Scan Operator's Station ID}"|"Highbury01"|"{Batch Creation Date}"|"2/13/20
09"|"{Batch Creation Time}"|"10:48:54 AM"|"\\Images\00000190.TIF"

3) Programming languages, eg Python or Perl as well as others.
eg Python
Code: [Select]for line in open("file.txt"):
print line.strip().replace(",","|")
Can there EVER be a comma within a value?Thanks Ghost. well let me be more specific.

I need to search the text file for commas (most likely using the find command) and replace it with a pipe. from my research, the only command is MUNGE.exe which i have to download but i am not too keen on. So pretty much, every night, the schedule is going to execute the batch file which inturn will search the specific text file for commas and replace it with a pipe.

VB is not my strong point so i want to avoid it as much as possible.

Is there any other wayHey BC_Programmer, no, the values that are being written into the text file are being taken out of DB2 and we have ensured that those values do not contain any comma'she gave you three different ways...ghostdog74,

sed "s/,/|/g" file.txt worked like a charm.

The sed download for windows was quick and easy.


You guys provide solutions so quick that the original poster fails to see what you have done.

It looks like the people requesting help would provide more feedback.

The unix commands are much better than DOS Batch or DOS commands.

What is the best download site for the other unix commands that will work with windows?

Bill

well- there is unxutils, found here:

http://unxutils.sourceforge.net/

and I found this:

http://lifehacker.com/362316/use-unix-commands-in-windows-built+in-command-prompt


I'm sure ghostdog can shed some more light on this... I haven't really used linux (except for a few recoveries)Quote from: BC_Programmer on March 19, 2009, 08:56:42 AM

well- there is unxutils, found here:

http://unxutils.sourceforge.net/

and I found this:

http://lifehacker.com/362316/use-unix-commands-in-windows-built+in-command-prompt


I'm sure ghostdog can shed some more light on this... I haven't really used linux (except for a few recoveries)


1) Microsoft services for unix
2) Cygwin and
3) GNU for Windows

I use the Core Utils

http://gnuwin32.sourceforge.net/packages/coreutils.htmnot to forget these tools also
1) FindUtils for windows , the find command much better than WINDOW's version
2) DiffUtils , for comparing files and such.
3) Gawk, Sed as mentioned.
4) Grep.

For a full list of available unix commands for Windows, check out this directory
4481.

Solve : Trying to make a batch file need help?

Answer»

The first batch file I NEED help with is to use REPLACEABLE parameter that will accept a file name from the command line and list the contents of that file using a pipe command for example: the user types in User list the contents of the user file.doc will list and pause between pages The computer I am using is window vista Text editor is notepad++Code: [Select]@echo off
type %1 | more
echo.Done
Pause
Hope this helps
,Nick(macdad-)Doing his homework but he'll get the grade not you. HOWEVER there is a gotcha in that code which the OP may or may not discover... was that intentional? (Let's not spell it out)

Thank for the Help the code seems to work
Code: [Select]@Echo off
dir %1
Type %1 *.fil| more
pauseQuote from: mdf1 on March 19, 2009, 01:54:40 PM

Thank for the Help the code seems to work
Code: [Select]@Echo off
dir %1
Type %1 *.fil| more
pause

what is that *.fil part for?

to bring up any of the file with the ext of .fil. I tried using wild card but it brought everything up on that drive and I only need a specific ext. Quote from: Dias de verano on March 19, 2009, 12:35:07 PM
Doing his homework but he'll get the grade not you. However there is a gotcha in that code which the OP may or may not discover... was that intentional? (Let's not spell it out)



I think so too Quote from: mdf1 on March 19, 2009, 02:04:17 PM
to bring up any of the file with the ext of .fil. I tried using wild card but it brought everything up on that drive and I only need a specific ext.

You don't UNDERSTAND what a replaceable parameter is, and your teacher will see that and be able to help you, which is good.

So let's LEAVE it like that, eh folks?

i should have asked him if it was homework.

but oh well....
4482.

Solve : how to create log file?

Answer»

hi
i have write following ftp script to upload file in server


username
pass
bin
hash
prompt
lcd filepath
mput *.*
this is text file to name test and BATCH file is


ftp -s:test.txt servername

exit

the script is ok but i have crate log file to the output of how to run of this bat file
can any one help
thanks is advanceCode: [Select]>>Logfile.txt
Put that at the end of your lines to go to that.thank for replay
but this is not work
the error is invalid commandput it at the end of your ftp command.yes i have write the end of the line
but the error is invalid command

username
pass
bin
hash
prompt
lcd filepath
mput *.*
>>logfile.txtIf you WANT to have more error control for your FTP script , you can
1) use a better FTP to offers you options such as debugging or verbose output.
2) use a better language such as PYTHON(or Perl) which comes with FTP libraries with error control
Code: [Select]from ftplib import FTP
import os
def upload(ftp, file): ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
os.chdir("localpath")
ftp = FTP('localhost')
ftp.set_debuglevel(3) # <------------------------ set debugging mode.
try:
ftp.login("user","pass")
except Exception, e:
print "error ",e #<---------------------------- this part will execute is login fails
else:
for files in os.listdir("."):
if os.path.isfile(files):
upload(ftp,files)
Quote from: rihan on March 18, 2009, 09:16:32 PM

yes i have write the end of the line
but the error is invalid command

username
pass
bin
hash
prompt
lcd filepath
mput *.*
>>logfile.txt


at the end of your ftp command:

Quote from: rihan on March 17, 2009, 10:30:58 PM
ftp -s:test.txt servername >> logfile.txt

4483.

Solve : help with Batch file which just stops??

Answer»

Hi All thanks with all the help so far !

I do have a problem at the min tho....

I am running a program which encrypts an swf file
(which i finally got working with some help)

However a new problem has occurred ..... as soon as the file is encrypted the batch file just stops and doesnot continue onto other tasks?

I was wandering if this is due to needing to wait for the encrypt program to finish, however any tasks i put after the encrypt are not called so how would you guys recommend i get round this issue?maybe you should post your code but to wait for program use Code: [SELECT]start /waitGOTO MAIN

:MAIN
CLS
COLOR 07
SET /P GAMENAME= [STRING]

IF EXIST "C:\Documents and Settings\tester\Desktop\mainDirectory\%GAMENAME%_main.swf" GOTO ENCRYPT
GOTO FILE ERROR

:ENCRYPT
COLOR 06

attrib -R "C:\Documents and Settings\tester\Desktop\mainDirectory\%GAMENAME%_main.swf"
echo Read only attribute removed for %GAMENAME%_main.swf

CD "C:\Program Files\SWF Encrypt 4.0\"
SWFEncrypt.exe -overwrite "C:\Documents and Settings\tester\Desktop\mainDirectory\%GAMENAME%_main.swf"

ECHO FILE ENCRYPTED!
GOTO END


:FILE ERROR
ECHO COULD NOT FIND FILE !
GOTO END

:END

As i mentioned I had some help to get to this stage but what I am thinking is....as the ENCRYPTING is taking place would the batch file continue?
If so it may explain why when it gets to here:

SWFEncrypt.exe -overwrite "C:\Documents and Settings\tester\Desktop\mainDirectory\%GAMENAME%_main.swf"

it executes this line a freezes?Quote from: cmd_noob on March 19, 2009, 05:43:21 AM

I was wandering if this is due to needing to wait for the encrypt program to finish, however any tasks i put after the encrypt are not called so how would you guys recommend i get round this issue?

hello cmd_noob, any message box being shown by SWFencrypt?
press CTRL+ALT+DEL, and check if the program is still responding?

there is version 5 available here: http://www.amayeta.com/software/swfencrypt/Thanks i checked the task manager and it seems the thread for swf encrypt is still running when i open another cmd and kill it, the batch file continues and does what is supposed to do.

The only problem is that i cannot put a Taskkill after the swf encrypt as the task willnot run ??

Strange

oh and i am running 4.0strange.....

when you run this swfencrypt with the COMMAND line switch -overwrite, does the application run as a windows program or console application??

you should look into why this swfencrypt doesn't QUIT after it has finish encrypting the swf file. and does it actually finish encrypting the file? try to delete this file manually before encrypting "C:\Documents and Settings\tester\Desktop\mainDirectory\%GAMENAME%_main.swf".

EXAMPLE of Executing Windows Program:
c:\MsPaint.exe - this statement will return as soon as the MsPaint Form is loaded
c:\start/wait MsPaint.exe - this statement will only return when you Close/Exit the application
c:\start %comspec% /c mspaint.exe - this statement will run mspaint.exe in a new window cmd.

so if this swfencrypt is executed as windows program, it should be returning once the form is loaded.Hey Reno

I am running it like swfencrypt.exe"C:\documents and...."

and it seems to run in a console state.
I have tried everything, it's crazy. It does however work if i manualy start up the program and then find the swf file. Thanks Reno
Seems like there is a problem with swf encrypt as it works but hangs for like 10 mins before killing the process

4484.

Solve : Help with batch file please !!!?

Answer»

Hi everyone I have had a read on these forums (and loads others!)
And I cannot see where I am going wrong?

So I am asking for your help to see if anyone here know what I should look into next?
Here is my code so far ......

@echo off
GOTO MAIN

:MAIN
CLS
COLOR 07
SET /P GAMENAME= [STRING]

IF EXIST "C:\Documents and Settings\tester\Desktop\RandomFolder\%GAMENAME%*" GOTO ENCRYPT
GOTO FILE ERROR

:ENCRYPT
ECHO FOUND FILE!
COLOR 06
attrib -r "C:\Documents and Settings\tester\Desktop\RandomFolder\%GAMENAME%_main.swf"

echo Read only attribute removed for %GAMENAME%_main.swf

CD "C:\Program Files\SWFEncrypt 4.0\swfencrypt" -overwrite "C:\Documents and Settings\tester\Desktop\RandomFolder\%GAMENAME%_main.swf"
PAUSE
GOTO END


:FILE ERROR
ECHO COULD NOT FIND FILE !
GOTO END

:END

Can anyone here see any reason this would work please I feel like I have tried everything and am now just STARING at my screen

Thanks !Well does it work or not ?

if not, what is it supposed to do and how does that differ from the actual behaviour ?Hi thanks for posting
It is supposed to start a program which encrypts swf files
(by using the -overwrite command)

However I get an error which states:
The filename, Directory name or volume label syntax is incorrect

When i try the same program with the files in the same place (but not using the batch file)
it works fine?

I just wandered if anyone noticed anything which could be wrong with this code?

Thanks again! Code: [Select]C:>cd c:\windows\notepad.exe test.txt
The system cannot find the PATH specified.

got it?Ok
so if the code has the correct path name what do I need to add to my batch file to make it recognise the pathname?

Sorry for being SLOW just that i am new to this style of coding, but thanks ALOT for your help !!Quote from: cmd_noob on March 18, 2009, 09:06:32 AM

CD "C:\Program Files\SWFEncrypt 4.0\swfencrypt" -overwrite "C:\Documents and Settings\tester\Desktop\RandomFolder\%GAMENAME%_main.swf"

remove the "CD" from the above line so it become:
"C:\Program Files\SWFEncrypt 4.0\swfencrypt" -overwrite "C:\Documents and Settings\tester\Desktop\RandomFolder\%GAMENAME%_main.swf"

make sure %gamename%_main.swf existThanks for quick reply
just tried that and the error has now changed to
"the system could not find the path specified"

However the path was coppied from the address bar from the top of the directory?

Is there anything that can be seen as wrong from the above code?


Thanks again!remove/comment @echo off to start debugging.


change:
IF EXIST "C:\Documents and Settings\tester\Desktop\RandomFolder\%GAMENAME%*" GOTO ENCRYPT
to
IF EXIST "C:\Documents and Settings\tester\Desktop\RandomFolder\%GAMENAME%_main.swf" GOTO ENCRYPT

does this path is correct?
C:\Program Files\SWFEncrypt 4.0\swfencryptthanks for yor help,

I started taking appart line by line to see what was causing the problem.

I found out iw was this line :

cd "C:\program files\SWF Encrypt 4.0\swfencrypt" -overwrite "C:\Documents and Settings\tester\Desktop\randomFile\%gameName%_main.swf"

and have since changed it to this:

CD "C:\Program Files\SWF Encrypt 4.0
swfencrypt "C:\Documents and Settings\tester\Desktop\randomFile\%gameName%_main.swf"

this seems to encrypt the file as expected however strangly the batch file then freezes and does not continue onto the next set of instructions?

thanks to all your help
it seems to work (although not quite as planned) but i think there is something wrong with the ecryption program as it takes about 10 mins to kill the task...... OH well need to search for a more compatible piece of software

Thanks agin for all your help!!
4485.

Solve : Dual Boot Windows XP and MS DOS 6.0?

Answer»

Greetings
I wanna dual boot my XP with MS DOS 6.0. I have a BOOTABLE CD of DOS. I read somewhere that

Code: [Select]format C:\ /s
sys C:

will make C: bootable and install DOS to it. I also know that DOS cant read NTFS PARTITIONS. I have a FAT partition namely I: on which I want to install DOS but it is not detected by the bootable cd.
Any ideas?
Ralph
Quote from: Ralph Spencer on March 17, 2009, 11:47:45 PM

I have a bootable CD of DOS

Illegal. DOS 6 was only distributed on Floppy.

Quote from: Ralph Spencer on March 17, 2009, 11:47:45 PM
Greetings
Code: [Select]format C:\ /s
sys C:

will make C: bootable and install DOS to it. I also know that DOS cant read NTFS partitions. I have a FAT partition namely I: on which I want to install DOS but it is not detected by the bootable cd.
Any ideas?



performing the described commands will also erase everything on your C: drive- including windows.

If your I: drive is a USB drive then you are out of luck.
Thanks for help.

Luck is REFUELED. I: Drive is a partition on my HDD.DOS MUST be installed first. it only UNDERSTANDS FAT. (not fat32- just fat16).


the partition must be at the beginning of the disk as well.


C: would be DOS 6, and then you can install XP on the remainder of the disk (D:)- XP will automatically install it's OS selection menu for you.Thanks.. I'll try..
4486.

Solve : Pls help with path independent batch files?

Answer»

hey all
I have some UNC paths in my batch files that do not exist at other network locations. I'm wondering if there's a way to get RID of the paths so that my coworkers dont have to modify the batch files to match their network drive mapping.
thanks,Can you please share code so we can see what you are trying to achieve.... probably going to want to create a path that points to C:\somefolder to make universalThe batch file is a silent install which runs an MSI off a network share, the path to the msi is something like this
\\servername\xxx\xxxxx\install.msi
If somehow I can get rid of the specific location infront of the msi then I can distribute the script to other support folks so they can run the silent install without having to change the path to match their network share.
thanks,I don't quite know what you are doing. But here are the SYSTEM-set variables.


Code: [Select]ALLUSERSPROFILE = C:\ProgramData

APPDATA = C:\Users\username\AppData\Roaming

CommonProgramFiles = C:\Program Files\Common Files

COMPUTERNAME = LAPTOPCOMPUTER

ComSpec = C:\Windows\system32\cmd.exe

FP_NO_HOST_CHECK = NO

HOMEDRIVE = C:

HOMEPATH = \Users\username

LOCALAPPDATA = C:\Users\username\AppData\Local

LOGONSERVER = \\LAPTOPCOMPUTER

NUMBER_OF_PROCESSORS = 2

OS = Windows_NT

PROCESSOR_ARCHITECTURE = x86

PROCESSOR_IDENTIFIER = x86 Family 6 Model 15 Stepping 13, Genuin

PROCESSOR_LEVEL = 6

PROCESSOR_REVISION = 0f0d

ProgramData = C:\ProgramData

ProgramFiles = C:\Program Files

PROMPT = $P$G

PUBLIC = C:\Users\Public

SESSIONNAME = Console

SystemDrive = C:

SystemRoot = C:\Windows

TEMP = C:\Users\username\AppData\Local\Temp

TMP = C:\Users\username\AppData\Local\Temp

USERDOMAIN = LaptopComputer

USERNAME = username

USERPROFILE = C:\Users\username

windir = C:\Windows




The RESULTS vary, but those are variables that are set by the system. I wasn't looking for a system variable but thanks for your reply.

4487.

Solve : REG ADD Problem?

Answer»

Hello

you know that we use the command reg add to add keys or VALUES to the registry

sometimes you need to ad a key with a long name and more than section
LIKE this

Code: [Select]reg add HKLM\software\Good morning
cmd doesn't ACCEPT that

what I have to do?

thanksuse quote marks if key or data contains any spaces, like this

Code: [Select]REG ADD "HKCU\Software\Microsoft\Windows Mail\Mail" /v "Font SIZE" /t REG_DWORD /d 0x00000009 /f

Thanks very very much

4488.

Solve : Batch coding - which command to use??

Answer»

hmm.... SOMEBODY should write a small program that does the same thing as GetTickCount() and uptime, but instead uses QueryPerformanceFrequency() and QueryperformanceCounter().well, so if it measures time since system is up, how is it possible to measure time elapse between command executions? Quote from: ghostdog74 on March 18, 2009, 04:13:21 AM

well, so if it measures time since system is up, how is it possible to measure time elapse between command executions?

subtraction.Quote from: ghostdog74 on March 18, 2009, 04:13:21 AM
well, so if it measures time since system is up, how is it possible to measure time elapse between command executions?

You should read the code I posted earlier. I reproduce a relevant portion

Code: [Select]set /a elapsed=%finshtime%-%starttime%Quote from: BC_Programmer on March 18, 2009, 04:10:57 AM
hmm.... somebody should write a small program that does the same thing as GetTickCount() and uptime, but instead uses QueryPerformanceFrequency() and QueryperformanceCounter().

Beware

http://www.virtualdub.org/blog/pivot/entry.php?id=106

Ok ... so i see what you are doing. its the same as using %time% except that %time% doesn't give you millseconds.Quote from: ghostdog74 on March 18, 2009, 04:22:20 AM
that's not what i meant. What i meant is, you are taking the milliseconds from the tickcount.exe output correct? and what does this milliseconds mean? Is it the time since the system is up and running, or is it the time elapsed between 2 execution of a code. your system may be up since yesterday and assuming you have not shut down the computer, you are running this code only today. So is tickcount used for the correct purpose?

it is the time since the system is running.


you run it once. you store that value.

you run some code to benchmark.

you run it again, storing the new value.

you take the difference between the values, thus getting the number of milliseconds that elapsed while the code was running.




Anyway, I decided to go ahead and implement a QueryPerformanceCounter program; attached.

run it without parameters, and it returns the current value given my QueryPerformanceCounter.

run it again, passing in the value RETURNED previously and it spits out the number of seconds that have elapsed... with quite a number of decimals, I might add...






[attachment deleted by admin]Quote from: ghostdog74 on March 18, 2009, 04:22:20 AM
that's not what i meant. What i meant is, you are taking the milliseconds from the tickcount.exe output correct? and what does this milliseconds mean? Is it the time since the system is up and running, or is it the time elapsed between 2 execution of a code. your system may be up since yesterday and assuming you have not shut down the computer, you are running this code only today. So is tickcount used for the correct purpose?

Tickcount measures the time that the system has been up and running. It does not MATTER if the computer was started yesterday or even last week, since the INT32 value rolls over every 49.8 days.

Quote from: ghostdog74 on March 18, 2009, 04:22:20 AM
Ok ... so i see what you are doing. its the same as using %time% except that %time% doesn't give you millseconds.

Mine does, well TENS of milliseconds, which is really what tickcount does. (it only has 10 msec accuracy)

Code: [Select]C:\>echo %time%
10:37:03.34
Quote from: Dias de verano on March 18, 2009, 04:38:40 AM
Mine does, well tens of milliseconds, which is really what tickcount does. (it only has 10 msec accuracy)

Code: [Select]C:\>echo %time%
10:37:03.34

not that accurate. though i never really got my hands dirty yet, i believe you can get "uptime" through the Win32_OperatingSystem->LastBootUptime. then going through Date formatting to get milliseconds. anyway.....Quote from: ghostdog74 on March 18, 2009, 04:48:14 AM
not that accurate. though i never really got my hands dirty yet, i believe you can get "uptime" through the Win32_OperatingSystem->LastBootUptime. then going through Date formatting to get milliseconds. anyway.....

you can, but it is simply wrapping around the GetTickCount() API.

As shown here:

http://msdn.microsoft.com/en-us/library/ms725473(VS.85).aspx

chances are any "uptime" properties/routines are merely calling GetTickCount() and processing the result. (actually, chances are they are actually calling GetTickCount64()...so we are suddenly using third-party tools now ? whaddya mean?
4489.

Solve : vbs to delete files

Answer»

I found this vbs submitted to this forum by Sidewinder on August 8, 2008:

+++++++++++++++++++++
Set fso = CreateObject("Scripting.FileSystemObject")
fs = "c:\dvr_data"
ShowFiles(fs)

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.FILES

For Each objFile In kf
'If fso.GetExtensionName(objFile) = "avi" then
'If objFile.DateCreated < date - 3 Then
WScript.Echo objFile & " " & objFile.DateCreated
'fso.DeleteFile objfile
'End If
'End if
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub
+++++++++++++++++++++

I can follow what is happening in most of the script and was able to modify it and put it to use for deleting OLD files in a specific folder.

How do I modify it so the starting folder is: "C:\Documents and Settings\%username%\some_folder"?

I do not know the syntax to set the username variable in the script. I know I can't use the %username% as I can in a batch file.

My goal is to use this in a logoff script to DELETE files OLDER than 1 day from a common folder in any user's folder in C:\Documents and Settings.
Code: [Select]Set oShell = CreateObject( "WScript.Shell" )
user = oShell.ExpandEnvironmentStrings("%UserName%")
fs = "C:\Documents and Settings\"&user&"\some_folder"
Thank you. That works great and made my day!

I also changed objFile.DateCreated to objFile.DateLastModified. I found out there is a HISTORY file that needs to be retained in the target folder.

Thank you again for your attention to my question.

4490.

Solve : .bat networking test?

Answer»

I'm trying to create a .bat file to use for networking support. The file will run a ipconfig /all, tracert, ping and output the results to a file.
The catch is I know some people will run it who don't have access to the c:\ and will still need to create the file. Thus I need to check access and then write the file to the c:\ else write it to other directory. I'm thinking i'll use ver to check the OS afterwards but I need help writing an if or something to get around access denied when writing the file.

On a side note, I'd like to include the public IP address in here but not certain the best way to do that yetwhy not just create a network LOCATION (IE share) on a server that everyone has modify access to. Then all you need to do is map a drive to the share and log the results to the share. you could even use the %computername% var in the log file so you keep track of each computer.

please let me know if this will work or if you need more information / help.users don't all have access to same serverwhat type of network are you working on? are the clients on the same domain or are you working with different networks?completely different users are CUSTOMERS who have their own networksOK well give this a try and let me know. ( I have done limited testing with it.)


Code: [Select]@echo OFF
CLS

set admin=N
set domain=%USERDOMAIN%\
If /i "%domain%" EQU "%computername%\" set domain=
set user=%domain%%username%
for /f "Tokens=*" %%a in ('net localgroup administrators^|find /i "%user%"') do set admin=Y

If %admin% == Y goto isAdmin

ECHO NO NOT ADMIN
pause
GOTO END

:isAdmin
ECHO YES ADMIN
pause

:END


you can have two different sets of code one for admins and one for non admins.interesting but what if other user groups have admin access? then they would show as non-Administrators, right?this should test for users explicitly defined in admins.

Are you asking will they show up if they are a member of a domain GROUP?
the answer is no.

but if you are asking about groups like power users then yes you would just need to change the group the query is looking in to.


Code: [Select]for /f "Tokens=*" %%a in ('net localgroup [powerusers]^|find /i "%user%"') do set admin=Y
so there isn't a way to test the command

ping www.google.com > C:\ping.txt

To see if you will return an "Access is denied"? I was hoping to use some sort of if errorlevel statement but couldn't grasp it.Like the attrib command can view attributes for a file...what you could also try and do is create a folder on the root of the system. Then check and see if it exists. if it dose then the user has the rights needed.

also if you are using scheduled tasks then you can run then as a different user. md will work as when I get Access denied, as you said I can continue with the batch, i'll check for the directory and then remove it. this should work, but would like to think there's a more direct way.Quote

but would like to think there's a more direct way.

By redirecting STDERR back to the STDOUT data stream, you should be able to trap the message and implement plan B.

Code: [Select]@echo off
for /f "tokens=* delims=" %%v in ('ping www.google.com ^> C:\ping.txt 2^>^&1') do (
if /i "%%v" equ "Access is denied." echo Implement Plan B
)

The literal message must be spelled exactly as issued by the OS. It is not case sensitive.

Hope this helps.
4491.

Solve : FTP (again...)?

Answer»

I know this is getting a bit old. Whenever I ask about FTP, people always put the commands/username/password into another file. I can't do that (While remaining secure). Can the commands STAY in the batch file?I don't think so. The STDIN device is normally assigned to the keyboard device. It can be redirected to a file, however if you redirect it back to the FTP batch file all those pesky batch commands will be interpreted incorrectly in the FTP shell.

QUOTE from: Sidewinder on March 11, 2009, 04:38:40 PM

I don't think so. The STDIN device is normally assigned to the keyboard device. It can be redirected to a file, however if you redirect it back to the FTP batch file all those pesky batch commands will be interpreted incorrectly in the FTP shell.


So what you are saying that FTP in batch must be:
Code: [Select]ftp -s:file.ext ftp.host.com
What I am asking is can I put all the commands that WOULD be in file.ext in the batch file?There is a way of keeping it in the batch, but its no more secure than having it in a separate file, you still need the login details in plain view.

You will have to google it, but essentially it involves tacking the CONTROL file on to the end of your batch -- heres a link to one example http://www.dostips.com/DtCodeBatchFiles.php#Batch_FtpBatch
Good luck
GrahamQuote from: GPL on March 12, 2009, 04:36:51 AM
There is a way of keeping it in the batch, but its no more secure than having it in a separate file, you still need the login details in plain view.

You will have to google it, but essentially it involves tacking the control file on to the end of your batch -- heres a link to one example http://www.dostips.com/DtCodeBatchFiles.php#Batch_FtpBatch
Good luck
Graham

The people I am dealing with aren't smart enough to know how to "decompile" a exe (from a .bat). I'll check the link ASAP.Quote from: Helpmeh on March 11, 2009, 12:11:24 PM
I know this is getting a bit old. Whenever I ask about FTP, people always put the commands/username/password into another file. I can't do that (While remaining secure). Can the commands STAY in the batch file?
the "proper" ways to do it,
1) use SFTP (secure FTP). Using Keys instead of password.
2) still using windows FTP client, BUT giving proper access control to whoever needs to execute the batch. Whoever has no business meddling with the batch file, will not be allowedQuote from: ghostdog74 on March 14, 2009, 09:35:20 AM
the "proper" ways to do it,
1) use SFTP (secure FTP). Using Keys instead of password.
2) still using windows FTP client, BUT giving proper access control to whoever needs to execute the batch. Whoever has no business meddling with the batch file, will not be allowed


What??? The people who will be running the batch file don't know enough about batch to know how to "decompile" it...so as long as I "compile" it to a .exe , they can't see the code. I don't want them to download anything that they don't need to.

What do you mean for the SECOND part?Quote from: Helpmeh on March 16, 2009, 07:58:37 PM

What??? The people who will be running the batch file don't know enough about batch to know how to "decompile" it...so as long as I "compile" it to a .exe , they can't see the code. I don't want them to download anything that they don't need to.
you will never know if a person is smart or not smart. don't assume. trust me.

Quote
What do you mean for the second part?
I don't know how you are using FTP. you just want your users to do file transfers to your servers?? it might be better to shed some light on what you are doing with the file transfers. Quote from: ghostdog74 on March 16, 2009, 08:17:49 PM
you will never know if a person is smart or not smart. don't assume. trust me.
I don't know how you are using FTP. you just want your users to do file transfers to your servers?? it might be better to shed some light on what you are doing with the file transfers.

The people who I am dealing with have absolutely NO knowledge of DOS whatsoever.

What I am doing with FTP is,
1. Appending a file
2. Getting a file

Pretty simple...

So what do you mean for this?
Quote from: ghostdog74 on March 14, 2009, 09:35:20 AM
2) still using windows FTP client, BUT giving proper access control to whoever needs to execute the batch. Whoever has no business meddling with the batch file, will not be allowed
4492.

Solve : Silent URL PopUp??

Answer»

hello i hope SOMEONE can help a NEWB with this
is it possible to pop up a website url with a bat file but silently
i know i can pop it up minimized like this but i want the whole process to be silent

start /min iexplore.exe HTTP://www.google.com

ThanksWhat are your intentions?to drop my websites cookiesThis could very easily be used for viruses, think how much damage you could do. It silently opens a website and starts downloading a Trojan HORSE.

LOCK please...

4493.

Solve : Possible to check for other 'open' dos windows with a batch file??

Answer»

I'd like to run 2 batch files over 24 hour period. The batch files should finish in 2 hours and are separated by more then 6 hours. However, in the event that one stalls, I want to be able to exit any NEW batch files if a new batch starts when the other batch FILE is still running. My question: Is it possible to check for other open dos windows in a batch file and if so how?

Thanks
MCIf you are using a XP system then you COULD use the task commands.

EX:
tasklist /v
taskkill

here is a link to MS web page describing information on what you are LOOKING for.

Link : http://technet.microsoft.com/en-us/library/cc720110.aspxinstead of doing unnecessary steps of checking dos windows, why not rectify the problem on WHY your batch/program can stall?

4494.

Solve : Day of the Week?

Answer»

Quote from: Reno on March 16, 2009, 04:03:28 AM

the first solution you post at 1:50 failed on year<1900 and year>2100

why does it FAIL?

Oh hold on... I think I know why...


Quote
For /f "delims==" %%N in ( ' cscript //nologo evaluate.vbs "weekday("1/1/2009")" ' ) do set daynumber=%%N
For /f "delims==" %%D in ( ' cscript //nologo evaluate.vbs "weekdayname(weekday("1/1/2009"))" ' ) do set dayofweek=%%D


Instead of ENCLOSING the dates as a STRING, use date literals:

Quote
For /f "delims==" %%N in ( ' cscript //nologo evaluate.vbs "weekday(#1/1/2009#)" ' ) do set daynumber=%%N
For /f "delims==" %%D in ( ' cscript //nologo evaluate.vbs "weekdayname(weekday(#1/1/2009#))" ' ) do set dayofweek=%%D




tests SEEM to work from the year 100 to 9999, with various month and day combinations.

Not to take away from the pure batch solution of COURSE

4495.

Solve : How to change the size of the window in a batch file?

Answer»

This is a frequently asked question so I thought I might POST this.

To change the size do this command.


Code: [Select]mode con cols=? lines=? >nul

Then where the question marks are you insert how many columns ACROSS you want and how many lines down.
I don't know if the command mode is on every computer. But it was on my computer by default.
I also figured this out at MasterJakeOnline, a small PROGRAMMING website.Cool, thanks.

By the way, is that Greek in your sig?YES, don't READ it, it's a super secret .

4496.

Solve : Directory Date??

Answer»

I wonder if someone could help me slve a SLIGHT problem.

I want to use the DIR function to search for the oldest directory and then perform other code on it using the xcopy command to refresh files in the directory.
This is not a problem.
My issue is that I would like to alter somehow the directory date. Renaming the directory does not work as it retains its original date.

Obviously deleting it and creating a new one does solve the issue but I dont want to do this as it will mean ultimately re-copying files to the directory. FILE sizes in my backup routine are reasonably large ENOUGH to MAKE a total new copy quite noticeable re the time taken to perform the batch xcopy function.
When the files are already there and just need a refresh then this is almost instant.

Anyone with any ideas? Would appreciate the help.
Cheers
There is nothing built into Windows that changes file / folder dates. You would have to download a 3rd party utility. There are plenty of free and paid for utilities out there. Google for "Change folder date utility".
Here's one that looks pretty good.

http://www.snapfiles.com/reviews/Attribute_Changer/achanger.htmlI have tried to use 'Filetouch' but unfortunatley it does not do what I want.
It will adjust the date of all sub-directories under the named directory but not a single one.
I want to adjust a named directory amoungst say a collection of 5.
ie I would require to adjust bak3 but not Bak1, Bak2, Bak4 or Bak5.

I have tried putting these into a subdirectory but hte same issue applies.
I do want to keep all my directories under one main directory to simplify coding etc.

I want to basicaly search for the oldest directory and then do a xcopy on it to update my files. I use this code at present to identify the directory in order of date.....dir/b/ad/tw/o-d bak?
Is there a way of getting around this via another method? Could I write a separate subdirectory under my main Bak1, Bak2 and so on ... directories each time I do a back up? If so how could I get the above command to search for the date of the subdirectory but list still the parent directories in date order according to the subfolder that is the newest?

Any help would go down well.
Cheers,
This one will certainly change the date(s) on any selected folder(s) or file(s)

http://www.softpedia.com/get/File-managers/SetFileDate.shtml

thanks for the help but it needs to be a command driven edit rather than a gui etc.
Cheers.
It HAS to be? How come?

http://www.softtreetech.com/24x7/archive/47.htmYou can change the last modified date to the current date/time by creating and deleting a temp file within the folder.

4497.

Solve : data stripping?

Answer»

Hi all

im TRYING to automate a process, between 2 PC's that use win23k. What i want to do is,

1. log onto PC2 via PC1 using TELNET
2. print data on PC2, logging this into a .txt file on PC1.
3. then strip out only parts of the txt file to create a command file to put this data into PC1.
>PC1 and PC2 are a working pair, so want to batch this job as i have MANY other pairs that need checking and having the same data, just possibly different file sizes and hold timers set.

example print would look something like this

C:\TEMP>aprint -l
TABLE OF DATA

DATA STORE DATA
123 OTHER ftp
File SIZE 1024
holding time 600
Fixed SIZE YES

Statistics since :07/12/2008 00:00:54
Process start :01/26/2009 03:19:27
Volume read (Kb) :8625132
Volume reported (Kb) :8624816
Conn ATTEMPTS :80

4. I just need to be able to strip "1024" & "600" out.
5. then put 1024 & 600 into the following command using VARS...or whatever.

adef -l 1024 -h 600

6. I dont have any other tools, programmes on the PC other stand standard dos commands. - and cant load any other programmes either.

Your help would be appreciated.
Jo.Quote

6. I dont have any other tools, programmes on the PC other stand standard dos commands. - and cant load any other programmes either.

did you really mean standard dos?? or is it win nt cmd.exe (the black box window that some people mistakenly think is dos).

i dont have a solution for standard dos, but the following code is tested on:
C:\>ver
Microsoft Windows XP [Version 5.1.2600]

Code: [Select]@echo off & setlocal

for /f "skip=4 tokens=2,3" %%a in (test.txt) do if not defined vtime set v%%a=%%b
echo adef -l %vsize% -h %vtime%
Quote
1. log onto PC2 via PC1 using telnet

Logging on to a computer using Telnet could potentially be malicious. Reno
did you really mean standard dos?? or is it win nt cmd.exe (the black box window that some people mistakenly think is dos).
> cmd.exe it is.

& many thanks for the help with the code, i will try it out.

BatchFileCommand
Logging on to a computer using Telnet could potentially be malicious.
> These comps are all behind very heavy firewalls, and can only "talk" to each other. Thats why telnet is a viable OPTION, and the only option.

I get a logon prompt thats always the same (we use pragma telnet server) the only thing that would be different is the user input for the username and password. So any help in performing that task would be great.

Many Thanks so far
Dalii dont have telnet access to try.

type telnet -help or telnet /? to see if anything intresting can be found there. and paste the help info here.

also try this code to see if it can pass username to telnet.
echo usernamehere|telnet hostnamehereCode: [Select]echo usernamehere|telnet hostnamehere
Or you can do this:


Code: [Select]echo %username% | telnet hostnamehere

That is a system set variable that automatically puts your user name.lQuote from: dali1972 on March 06, 2009, 10:06:34 AM
6. I dont have any other tools, programmes on the PC other stand standard dos commands. - and cant load any other programmes either.
sorry, but this is a rant. I don't see why you can't load any programs that makes your programming life easier. If you are a programmer doing a batch job like this for your company, you can have your boss approve the use of those tools. doing telnet automation with sucky telnet client from windows just doesn't cut it. What happens after this ?
Code: [Select]echo usernamehere|telnet hostnamehere
you are expected to execute some commands on the other side. The above statement is not enough to do all that. Get a real programming language that have libraries that supports the Telnet protocol with proper error control. your boss should understand you have these restrictions.
4498.

Solve : set info in text file to variable?

Answer»

hi all,

I am trying to get the computer description from active directory. I have it working so far but I would like the results to be USABLE in a variable form. The text file I have the description in looks like the following:

desc
[computer description]
dsget succeeded

I would like to pull just the second line of the text file. Any ideas on how to grab that line no matter how LONG the computer description is?

thanks,
Wayne
C:\>type blanks.txt
" "
444



3333


555



66666



7777


C:\>find "66666" blanks.txt

---------- BLANKS.TXT
66666

C:\>I am trying to put the second line in a variable for use. Also the second line will change every time the query is ran. I do not know what the description will be when it is ran. That is why I am trying to put it in the variable. The description is being accessed from active directory. CODE: [Select]@echo off
for /f "skip=1 tokens=*" %%a in (file.txt) do (
set var=%%a
goto NEXT
)
:NEXT
pausewhen I run this I get the last line of the file. any ideas?Quote from: wbrost on March 12, 2009, 11:11:48 AM

when I run this I get the last line of the file. any ideas?

Devcom's code gets the 2nd line OK for me. However, here's a slightly different way

Code: [Select]@echo off
setlocal enabledelayedexpansion
set /a line=0
for /f "delims==" %%L in (file.txt) do (
set /a line+=1
if !line! EQU 2 set var=%%L
)
echo 2nd line is %var%
wbrost,

I have not written any code since 1992. And the code I wrote was was usually UNIX shell script or C. So forgive my comments if we both don't benefit.

If the file name is different each time, then a command line argument will help. For example:


C:\>2line homewk.txt
file name homewk.txt
2nd line is " Write a batch file that display a welcoming message before displaying your

C:\>type 2line.bat
@echo off
echo file name %1
setlocal enabledelayedexpansion
set /a line=0
for /f "delims==" %%L in (%1) do (
set /a line+=1
if !line! EQU 2 set var=%%L
)
echo 2nd line is %var%
C:\>

p.s It helps me when an example of the output is listed.

Good Luck with you projectthank you to all that helped out. I have made the following to access the Active Directory computer description.

You will need to edit the code to point to your AD.

Code: [Select]@ECHO OFF
CLS
SETLOCAL ENABLEDELAYEDEXPANSION

:LOOP
CLS
ECHO please enter computer name
ECHO.
SET CN=
SET /P CN=Computer Name:

REM TESTS TO SEE IF HOST IS ACTIVE
SET ERRORLEVEL=
PING -n 1 %CN% > nul


REM PING ERRORLEVEL OF 0 MEANS SUCCESS
REM PING ERRORLEVEL OF 1 MEANS THE HOST IS NOT FOUND OR TURNED OFF

IF ERRORLEVEL 1 GOTO fail
IF ERRORLEVEL 0 GOTO ADQUERY

:fail
CLS
ECHO.
ECHO.
ECHO host %CN% non responsive or not found
ECHO please try again
PING -n 1 -w 5000 1.1.1.1 > nul
GOTO LOOP

:ADQUERY
REM command to gather information from AD
dsquery computer [AD OU] -name %CN% | dsget computer -desc > %temp%\computerdesc.txt


REM Will access text file and set the second line to %var%
setlocal enabledelayedexpansion
set /a line=0
for /f "delims==" %%L in (%temp%\computerdesc.txt) do (
set /a line+=1
if !line! EQU 2 set var=%%L
)
CLS
echo.
echo.
echo %var%

DEL /Q %temp%\computerdesc.txt

pause > nul

thank you,
wbrost
4499.

Solve : Delay????

Answer»

all i NEED is a 5 sec delay how do i do thisCode: [Select]PING localhost -n -5 &GT;nulwill that have any effect on my css server THATS runing on the same computer since your pinging?I KNOW nothing about CSS. Sorry.>~sleep.vbs echo wsh.sleep wsh.arguments(0) 'ms
cscript//nologo ~sleep.vbs 5000
if you are worried about pinging "your self" you could always ping a non existent IP with a time out.

Code: [Select]ping -n 1 -w [time out] 1.1.1.1 > nul

the time out will be in milliseconds.

4500.

Solve : Installing the Setup file?

Answer»

Can u please help in installing the setup file in silent mode.

I'm able to start the Installer, but uable to proceed further.

Please help

E.g : PowerISOWhy do you need to do it in Silent Mode?Love that screen name.
MSIEXEC

Microsoft Windows Installer.

Syntax
Install
MSIEXEC /i package options

Uninstall
MSIEXEC /x package options

Advertise to current user
MSIEXEC /ju package options [/t Transform_List | /g LanguageID]

Advertise to all users
MSIEXEC /jm package options [/t Transform_List | /g LanguageID]

Administrative install - install on the network.
MSIEXEC /a package

Apply a patch to an installed Admin image
MSIEXEC /p patchPKG /a package

Options:
/fp fix - replace missing files
/fo fix - replace Older files
/fe fix - replace older or Equal date files
/fd fix - replace Different version files
/fc fix - replace files based on Checksum differences
/fa fix - replace All files
/fu fix - rewrite HKCU registry
/fm fix - rewrite HKLM registry
/fs fix - recreate shortcuts
/fv fix - rewrite local cache from source
/l* Logfile Log Everything (not VERBOSE)
/l*v Logfile Log Everything Verbose
/lv Logfile Log Verbose
/le Logfile Log All error messages
/lw Logfile Log Non-fatal warnings
/li Logfile Log STATUS messages
/la Logfile Log Startup actions
/lr Logfile Log Actions
/LU Logfile Log User requests
/lc Logfile Log User Interface (UI) parameters
/lm Logfile Log memory use
/lp Logfile Log Terminal properties
/l+ Logfile Append to an existing log file.
/l! Logfile Clear an existing log file.
/q , /qn No UI.
/qb Basic UI.
/qb! Basic UI with no cancel button.
/qr Reduced UI. A modal dialog box is displayed at the end of the install.
/qf Full UI. A modal dialog box is displayed at the end of the install.
/qn+ No UI. However, a modal dialog box is displayed at the end of the installation.
/qb+ Basic UI. A modal dialog box is displayed at the end of the installation. If you cancel the installation, a modal dialog box is not displayed.
/qb- Basic UI with no modal dialog boxes.
/y module Register a DLL - only use for registry information that cannot be added USING the registry tables of the .msi file.
/z module UnRegister a DLL - only use for registry information that cannot be removed using the registry tables of the .msi file.

Windows installer versions

Windows NT can support version 1.1 or version 1.2
Windows 2K includes version 1.1
Windows XP Sp1 /Server 2003 include version 2.0
Windows XP SP2 includes version 3.0

Updates to msiexec can be downloaded from MSDN.