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.

1651.

Solve : IBM Aptiva E series?

Answer»

Yes, I am an idiot. I can't get my old computer out of DOS. All it does is give me a key symbol and when I type it gives me a white rectangle. I have an IBM Aptiva e-series 245.And your operating system is :-?

What are you trying to do, SHUTDOWN Dos, return to a Windows OS :-?What is it that you type?  Do you have a rescue DISKETTE?

Alan <>< :-)I believe I am using Windows 98.
I also believe my system is locked.
When I enter any character it just gives me a white rectangle like I should be giving it a password.
After I push enter a few times it will say "Incorrect password specified. System halted."
Yes I am very ignorant when it comes to this stuff.You MIGHT try removing the battery on the motherboard and letting it set for awhile.  That should drain the CMOS battery effectively letting it "forget" the password.  Reinsert the battery and boot up.

Alan <><  After you have drained the CMOS memory using Alan's suggestion then at the C: prompt type CD\Windows and hit enter ...at the C:\Windows prompt type Win and hit enter.

patio.   8-)Thanks for the 'touch-up' patio  

Alan <><  Nothin to it...and you're Welcome !THANK you everyone!! I am back in action!Excellent...we love success stories here.

1652.

Solve : creating a dir?

Answer»

ok here is my problem, i was messin around with my UI shell and i relocated the folder without redefining the path, well now all i can do is get into the msdos through the 98 start up disk that ive GOT...now i figured out how to copy files from one location to another, and all i need to do to fix this issue is to have the blackbox.exe file in the right place, however, i dont have the right folder(i.e. directory) in this place and i cant figure out how to create one

please help(and pardon any spelling, grammical, and punctual errors )C:\>md /?
Creates a directory.

MKDIR [drive:]path
MD [drive:]pathwho ever you are in RL i could kiss you right now THANK YOU (x1,100,000,000,000,002)You're welcome, typing help is handy too.
Quote

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\>help


For more information on a specific command, type HELP command-NAME.
ASSOC    Displays or modifies file extension associations
AT       Schedules commands and programs to run on a computer.
ATTRIB   Displays or changes file attributes.
BREAK    Sets or clears extended CTRL+C checking.
CACLS    Displays or modifies access control lists (ACLs) of files.
CALL     Calls one batch program from another.
CD       Displays the name of or changes the current directory.
CHCP     Displays or sets the active code page number.
CHDIR    Displays the name of or changes the current directory.
CHKDSK   CHECKS a disk and displays a status report.
CHKNTFS  Displays or modifies the checking of disk at boot time.
CLS      Clears the screen.
CMD      Starts a new instance of the Windows 2000 command interpreter.
COLOR    Sets the default console foreground and background colors.
COMP     Compares the contents of two files or sets of files.
COMPACT  Displays or alters the compression of files on NTFS partitions.
CONVERT  Converts FAT volumes to NTFS.  You cannot convert the
         current drive.
COPY     Copies one or more files to another location.
DATE     Displays or sets the date.
DEL      Deletes one or more files.
DIR      Displays a list of files and subdirectories in a directory.
DISKCOMP Compares the contents of two floppy disks.
DISKCOPY Copies the contents of one floppy disk to another.
DOSKEY   Edits command lines, recalls Windows 2000 commands, and creates macros.
ECHO     Displays messages, or turns command echoing on or off.
ENDLOCAL Ends localization of environment changes in a batch file.
ERASE    Deletes one or more files.
EXIT     Quits the CMD.EXE program (command interpreter).
FC       Compares two files or sets of files, and displays the differences
         between them.
FIND     Searches for a text string in a file or files.
FINDSTR  Searches for strings in files.
FOR      Runs a specified command for each file in a SET of files.
FORMAT   Formats a disk for use with Windows 2000.
FTYPE    Displays or modifies file types used in file extension associations.
GOTO     Directs the Windows 2000 command interpreter to a labeled line in a
         batch program.
GRAFTABL Enables Windows 2000 to display an extended character set in graphics
         mode.
HELP     Provides Help information for Windows 2000 commands.
IF       Performs conditional processing in batch programs.
LABEL    Creates, changes, or deletes the volume label of a disk.
MD       Creates a directory.
MKDIR    Creates a directory.
MODE     Configures a system device.
MORE     Displays output one screen at a time.
MOVE     Moves one or more files from one directory to another directory.
PATH     Displays or sets a search path for executable files.
PAUSE    Suspends processing of a batch file and displays a message.
POPD     Restores the previous value of the current directory saved by PUSHD.
PRINT    Prints a text file.
PROMPT   Changes the Windows 2000 command prompt.
PUSHD    Saves the current directory then changes it.
RD       Removes a directory.
RECOVER  Recovers readable information from a bad or defective disk.
REM      Records comments (remarks) in batch files or CONFIG.SYS.
REN      Renames a file or files.
RENAME   Renames a file or files.
REPLACE  Replaces files.
RMDIR    Removes a directory.
SET      Displays, sets, or removes Windows 2000 environment variables.
SETLOCAL Begins localization of environment changes in a batch file.
SHIFT    Shifts the position of replaceable parameters in batch files.
SORT     Sorts input.
START    Starts a separate window to run a specified program or command.
SUBST    Associates a path with a drive letter.
TIME     Displays or sets the system time.
TITLE    Sets the window title for a CMD.EXE session.
TREE     Graphically displays the directory structure of a drive or path.
TYPE     Displays the contents of a text file.
VER      Displays the Windows 2000 version.
VERIFY   Tells Windows 2000 whether to verify that your files are written
         correctly to a disk.
VOL      Displays a disk volume label and serial number.
XCOPY    Copies files and directory trees.
1653.

Solve : Use "More" command with the least control keys?

Answer»

When I type the more>dailylog.txt command, I can begin to type some words.
After finishing a line, I press "enter" KEY once.(this is the first time to use control key.)
And I want to finish composing, I press combination of "Ctrl" and "Z". (the 2nd time to use control key.)
At last, I have to press "enter" AGAIN! (this is the third time to use control key!)

I am lazy    and I just want to press ONLY one "enter" key to finish composing!

I tried to use a BATCH file to solve this problem, but not work properly...... :-?

My implementation:

echo off
date/t >> dailylog.txt
echo.> crlf.dat
time > dailylog.txt
more < crlf.dat >> dailylog.txt

I want to type in " Edit some files.", but I CANNOT input anything!

How can I redirect a string to a text file with ONLY pressing one enter? If "more" cannot do this, are there any other commands can achieve this requirement ?   Thanks heaps!Well, I can remove the need for the ^Z -- this will keep reading lines of text until the line entered is blank, when it will stop looping

Note I havent tested it, but it should work -- in principle

Graham

Code: [Select]echo off
date/t >> dailylog.txt
echo.> crlf.dat
time <crlf.dat | find "curr" >> dailylog.txt

:GetLine
SET /P Line=
If "%Line%"=="" GoTo EndLoop
>> dailylog.txt Echo %Line%
GoTo GetLine
:EndLoop

:: rest of batch
Code: [Select]echo off
date/t >> dailylog.txt
echo.> crlf.dat
time <crlf.dat | find "curr" >> dailylog.txt

:GetLine
Set /P Line=
If "%Line%"=="" GoTo EndLoop
>> dailylog.txt Echo %Line%
GoTo GetLine
:EndLoop

:: rest of batch

Thanks Graham. I have tested your code, but it seems the condition "%Line%"=="" never return true because I have to exit the loop by using Ctrl-C. Can you make any improvements for this code?Try this, slightly amended version, it works

Graham

Code: [Select]echo off
date/t >> dailylog.txt
echo.> crlf.dat
time <crlf.dat | find "curr" >> dailylog.txt

:GetLine
Set Line=
Set /P Line=
If "%Line%"=="" GoTo EndLoop
>> dailylog.txt Echo %Line%
GoTo GetLine
:EndLoop

:: rest of batch


 


Thanks Graham, it does work now with only pressing one more enter key.

Keep it simple Dudes!      

[edit]ECHO OFF
SET Line=%date%  %time%
:GetLine
ECHO.%Line%>>dailylog.txt
SET /p Line=&&GOTO:GetLine
[/edit]DosItHelp - not bad, except you omitted the initialising of the Line variable and the exit if the line is blank after the input
Graham Quote

Keep it simple Dudes!      

[edit]
:GetLine
ECHO.%Line%>>dailylog.txt
SET /p Line=&&GOTO:GetLine
[/edit]


Wooooo , so simple, but so DIFFICULT. I cannot understand this two statements. :-?

so many questions for me?
What does  ECHO.%Line%  mean?
What does  &&  mean?
Why when I give a initial assignment "set Line=", this code does not work properly?
Why when I move GOTO:GetLine to the next line, this code does not work?

Can you give me some explanation on how it works?   Thank you very much! Sure, let's go into detail:

ECHO OFF
SET Line=%date%  %time%


... the Line variable is now initialized with a string containing the current date and time.

:GetLine
ECHO.%Line%>>dailylog.txt


... the first time coming here will append the date and time to the log file,
looping back to here will append the new text entered by the user.

SET /p Line=&&GOTO:GetLine

... this will query the new Line to be added to the log file.  The GOTO will only be executed when some text was entered.  If no text was entered then the GOTO will not be executed, and the loop terminates.

Note that there is difference between single & and a double &&.
Single & will concatenate commands whereas double && causes conditional execution so that the command following the double && will only execute when the command preceeding the double && succeeded.  The set /a command only "succeeds" when text has been entered by the user.
See also http://www.dostips.com/DtCodeSnippets.php#_Toc141112827


Hope this also eliminates jpl's concern.
 

Quote
The GOTO will only be executed when some text was entered
You LIVE and learn; I never thought to try conditional execution .. thank you
GrahamThank you sooo much for details, DosItHelp.   I much appreciate your effort and time. Thanks again.
1654.

Solve : Problem running DOS based pgm?

Answer»

The hard drive on my other comp completely crashed!!! I was running a DOS BASED DBM software package with no problem. Lucky I thought, everything was BACKED up. I put everything over to this computer which runs XP and I'm having a problem. I can run DBX and see the DBF files but when I go to run the DB prgram the initial screen comes up OK but when it comes to the actual working system where different Data Bases link etc. I get an open error on one of the files, DOS error 4 with option of Quit, RETRY or DEFAULT. I went to default a few TIMES and it takes me all over the place and eventually gives me no other option than to QUIT. I have edited Autoexec and Config files based on what I used with WIN98 and I have added PATH to system variables with no luck.

Some of the screens which I think access one of the files seem to work OK.

Is there something I'm missing? Or forgotten, or don't know about.

I have to fix this soon as I have payroll and billing comming up next week and it all relies on this!!!

Is there anyone out there who can help.

By the way the DB program is CLIPPER based.

Thanks
Renrut
Did you edit Autoexec.bat or Autoexec.nt :-?  XP does not use the .bat file - same with Config.sys/Config.ntHi
I edited autoexec.bat and config.sys. Do the same principle apply to .nt etc. I saw somewhere here where there are instructions to find them. I gues I should try that. I will say I am a little intimidated about messing around with .nt files.

Thanks for gettin back.

RenrutHi renrut_wr.  

Have ALREADY replied to your pm but will do so here as well.  Yes, it's ok to edit nt files to suit your purpose but will repeat my belated advice - take backup before editing anything in the Windows\System32 file, and, of course, in other system areas as well (esp. Registry).

Good luck

1655.

Solve : GX1.EXE?

Answer»

Hey Everyone,

After BOOTING from my Win98 CD none of the choices on my DOS menu will bring up four diffeent games UNLESS I exit the batch file and type at the COMMAND prompt (for example)--"GX1" and the GAME starts fully functional with no issues.

Anyone ever hear of GX1.exe?  It is one of four old DOS games that will not run from my DOS batch menu while Galacta.exe and Invaders78.exe or even PACPC2.exe (Pac Man) will.  

I've noticed that some games will run from a batch file while some will not.

Stumped,

Gary

******************************************888Seems to be a CRACK for Galactica...

Sorry no help here. Quote

Seems to be a crack for Galactica...

Sorry no help here.

Patio,

I reworded the question and maybe it makes more sense now.  It does read better.

Thanks for trying.

Gary

*****************************888
1656.

Solve : Time out?

Answer»

I am WRITING a batch scrip that will give the user the option of backing up files and syncing files or both, and i am wanting to set it that it the user hasn't inputted a selection in a determained set of time (30 SECONDS) it will automatically backup the data.

That is the top part of the batch script. the rest of it is just DEFINING where to copy to and sync from. also i am wanting a way that i can get the batch to zip the backup either before it is copied or after then deleting the uncompressed files.

The batch will be RUN on windows xp

thank you for your help. I greatly appreciate it

ECHO off
:start
cls
ECHO.
ECHO 1. Backup Data
ECHO 2. Sync All About Users Data
ECHO 3. Back up and sync
ECHO 4. Exit
ECHO.
set choice=
set /p choice=Choose and option:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto backup
if '%choice%'=='2' goto sync
if '%choice%'=='3' goto both
if '%choice%'=='4' goto exit
ECHO "%choice%" is not valid please try again
ECHO.Hi, KaMaKaZi_KiNg,

Unfortunately, the set /p will wait indefinitely from the user. The only batch function that will wait a while would be a hidden PING command. Unfortunately, that will not have a prompt.

DOS batch files will not, I'm afraid, do this. Now, if you were talking about C++, Visual Basic or some other programming language you'd have a solution, because you can run a timer in a seperate THREAD from the prompt. But this is impossible in the batch pseudo-language.*censored*.. i dont know any programming language so i guess i'll just have to leave it how it is.

can the zip bit be done or is that a c++ or VB job aswell?

also i am wanting to rename the backup folder to have the date and time on the end of the name. (eg. backup_1428_220906)

1657.

Solve : Batch file, help, stoopid people!?

Answer»

It's just so frickin(sorry for thwe bad language) annoying when someone names a post "batch file" or "batch help" or "help" or "batch" ETC! Because then you have no IDEA WHAAT they need help with and most people just ignore it!!!!Most people will probably ignore this poll as well...

PATIO.   8-)Insulting the very people you wish to poll is no way to make friends or influence people.

You seem to have other ideas so perhaps you could post a David Letterman style Top 10 DOS subject lines. This would help the stoopid people who can't seem to come up with ANYTHING more imaginative than "batch file" or "batch help" or "help" or "batch" ETC.

Even more annoying than bad subject lines are bored pollsters.

1658.

Solve : help id dos commands?

Answer»

ok listen
i understand that to build DOS program its not nice to buld in DOS command in C++ and so
so .BAT is the GOOD way am i right?
what i need the program will do..
is DISCONNECT from the INTERNET connection and connect
i have ADSL
is there any way to reconnect the internet through DOS?
and i need the program to repeat itself in a loop
if its not possible in dos so where it is?

1659.

Solve : no data in config.sys file?

Answer»

Hi All!  I have installed FoxPro (for a work from home PROGRAM) when I INSERT the disk that has my assignments on it, I get a message that I need to change the FILE number in config.sys from 30 to 60.

When I go into my config.sys file there is no commands in the file.  I am running Windows XP Home Edition.

Any suggestions?  I appreciate any help I can get...Thanks!!!!WINXP does not use config.sys. It uses config.nt which can be found in the c:\windows\system32 directory.

Open up config.nt (use any editor, but notepad is fine) and either change the EXISTING value or add a files=60 at the end of the file.

 8-)

1660.

Solve : Disabling service in Batch file?

Answer»

Hey guys & girls

I want to disable a lot of SERVICES in a batch file, i want to KNOW how to do that so i can run that batch file and don't edit AL the things in de list of services because that's pretty much work.

Thanks in advance,

Greetz RubenThe  "SC" command [RK] should do it.

hope it helps
uli

1661.

Solve : disable xp services?

Answer»

I need the sintax for a batch to set the disable status to somme services in winxp. I don't want to stop  those services because it takes somme time to execut those commands.By setting the disable status, when my system REBOOTS those services would be stoped. I think that i FOUND de command that can do this "SC" but i need somme help to syntax . Can you help me with an EX. for stopping the messenger service You can just disable them or set them to manual in services.
Start&GT;SETTINGS>Control Panel>Admin Tools>Services.
Tread a little carefully in there.  
If in doubt set them to manual.

1662.

Solve : Redirect outputs in the same line in a text files?

Answer»

When I use >> to redirect the outputs to a text file, it just append the outputs in the next line, but how can I append them in the line where there already exist some words, or just append them following the existing words in the same line?

I think when we redirect an output, we also redirect a crlf, that is equivalant to pressing an enter key. How can we prevent this happen?

Can someone solve this problem? Thanks a lot. DOSNVC,

From the command line you can append to the last line of a text file using:

[edit]set ap=[highlight]str1[/highlight]&set f=[highlight]t.txt[/highlight]&cmd /v:on /c "set c=0&(for /f %a in ('find /v /c ""^"%temp%.\t0815.txt"&move /y "%temp%.\t0815.txt" "!f!"[/edit]
Replace [highlight]str1[/highlight] with the text you want to append.
Replace [highlight]t.txt[/highlight] with the file name you want to append to.

Note:

    [*]The file must exist and contain at least one line.
    [*]The whole thing is one command line.
    [/list]
    If want to add text to a particular line then use this:

    [edit]set ap=[highlight]str1[/highlight]&set c=[highlight]2[/highlight]&set f=[highlight]t.txt[/highlight]&cmd /v:on /c "(for /f "tokens=1,* delims=:" %a in ('findstr /v /n "$$"^"%temp%.\t0815.txt"&move /y "%temp%.\t0815.txt" "!f!"[/edit]
    Replace [highlight]str1[/highlight] with the text you want to append.
    Replace [highlight]2[/highlight] with the line NUMBER you want to append to.
    Replace [highlight]t.txt[/highlight] with the file name you want to append to.

    Is cryptic but works ;) 
    My GOD! This is out of my reach!

    I copy and POST this command in my code, it says syntax error. I think the structure is too complex and not easy to IDENTIFY where the error is. Can you use multiple of lines to revise this command? Thank you very much!DOSNVC,

    Sorry, both code blocks had an addition double quote at the end, which is corrected now.
    The code is meant to be executed directly from the command line.

    In a batch script same can be extracted to:

    [edit]set ap=
    set f=
    set c=
    (for /f "tokens=1,* delims=:" %%a in ('findstr /v /n "$$"^<"%f%"') do (
        if "%%a"=="%c%" (
            ECHO.%%b%ap%
        ) ELSE (
            echo.%%b
        )
    ))>"%temp%.\t0815.txt"
    move /y "%temp%.\t0815.txt" "%f%"[/edit]


    This works but looks pretty ugly in you main script block.
    Optionally you can call an append function like this:

    call:append   StringToAppend   FileName   LineNr

    Place the append function itself at the end of your batch script.
    Copy the append function from here:
    http://www.dostips.com/DtCodeCmdLib.php#append.

    Good luck
    1663.

    Solve : del user profile remotely?

    Answer»

    I have a batch file that I use to delete user profiles from remote PCs. It WORKS great But now I want to modify it so that it can use a  text file called PcsLisl.txt that would contain a list of computers. Sample of file below

    \\PODA02
    \\PODA03
    \\PODA04
    \\PODA1
    \\PODA5
    \\PODB02
    \\PODB03
    \\PODB04
    \\PODB05
    \\PODB1
    \\PODBSW
    \\PODC03

    This is the current batch file below:


    REM echo off

    net use x: "\\podA1\c$"

    x:

    RD "\Documents and Settings\gbertin\" /S

    cd\

    net use x: /delete


    I know that this can be done with the FOR command but I have never used that command before and need help with the syntax. I know there are better ways live using Group Policy but I would really prefer to do it using a batch file remotely thus I can choose which workstations to delete the file from with having to use Active DIRECTORY
    eThis should work. But please try it first WITHOUT deleting anything.

    echo off
    setlocal
    set log=your logfile
    set pclist=PcsLisl.txt

    FOR /f "skip=2 delims=\ " %%v in ('find "POD" %pclist%') do (

          net use x: \\%%v\c$
          call :Sub %%v
          
          
    )

    endlocal
    goto :EOF

    :Sub %%v


    IF %errorlevel% EQU 0 (echo drive c:\ mapped >>%log%
          ) else (
    echo couldn't map drive %errorlevel% >>%log% & GOTO fertig
    )
     
    rd "x:\Documents and Settings\gbertin\" /S          

    :: I don't know the errorlevel from the rd command; sorry
    :: check it also
    : fertig

    net use x: /delete


    :EOF


    I think you don't need to map the drive.
    rd "\\%%v\c$\Documents and Settings\gbertin\" /S

    Should also work.

    hope it helps

    uliThere is a special command in the Ressource kit for deleting profiles.
    "delprof"
    With this command you don't need to map the drive. Just put it in a for loop.

    I fear that only deleting the directory doesn't really delete the profile.

    uli

    1664.

    Solve : Protecting long file names in batch files?

    Answer»

    Hello,

    I need to search through a bunch of inherited data files to determine to what extent a test regimen was completed.  In some of the data files are the file names of test IMAGES, and I need to find those image names to COMPARE with a test plan.  Thus, in my path I've put a batch file containing

    for /r %%f in ("*.nb") do find /i ".jpg" %%f

    The problem, of course, is that the find command is passed file names which the command interpreter, I guess, breaks down into partial strings if the file name has spaces.  I tried some of the options (which I learned about on this forum, thank you!) but was unable to make any progress.

    How can I make this pass the full, long, space-containing file names to the "find" command?  The environment is Win2k, V5.0, SP4, and I'm operating from a DOS window started with cmd.exe, not command.exe.

    Thanks,
    MPWMy guess is that it's the variable value that contains the emebedded spaces not the mask:

    CODE: [SELECT]for /r %%f in (*.nb) do find /i ".jpg" "%%f"

    Good luck. 8-)Sidewinder,
    Thanks for your suggestion.  That's the first thing that occurred to me, and I was sure I had tried it, but apparently not:  it does seem to work.  At least it does recursively search the directories, not breaking the filenames into separate tokens.

    Here's how the line in the batch file ends up:
      for /r %%f in ("*.nb") do find /i ".jpg" "%%f"
    The symbol prevents the initial "for" command being echoed, but each "find" echoes its invocation to the screen, making the output file (I use redirection) contain a lot of excess lines.  For example,

    {really long prompt arising from $p$g}find /i ".jpg" "{really long path}\Experimental Builds.nb"

    ---------- {really long path}\EXPERIMENTAL BUILDS.NB

    This file does not have any lines containing .jpg, but "find" still has to tell me it searched there.

    I can filter those out with a separate batch file, but it's annoying.  I'll see if I can figure that one out myself.  Tried "echo off", same result: it doesn't appear to be passed to subsequent processes.

    Thanks again for your help, and sorry it wasn't more of a challenge.
    MPWNot sure if Win2000 has the FINDSTR command, but this may give you the results you're looking for:

    Code: [Select]for /r %%f in (*.nb) do findstr /m  /i ".jpg" "%%f"

     8-)Thanks again.  Yes, Win2k has findstr, and I've used it sometimes because of its enhanced options.  In this case, it's really the "for" construct and the command SHELL.  It appears each loop of the "for" command is echoed to stdout, or perhaps it's just as though you'd typed in the "find" command for each file in the expanded tree.  No matter, I can figure out some way to do it.  Will let you know what I end up with.
    MPWOK, here's what I finally ended up with.  It completely eliminates the clutter in the command window, and gives me the filenames, which I can then go search (or use as a fileset to feed to another script if I want the individual lines).  I first had hardcoded the strings, but then changed to the command line replaceable parameters.  Thanks for your original clue!
    MPW

    echo off
    if exist rsearch.txt del rsearch.txt
    for /r %%f in ("%1") do findstr /i /m /l "%2" "%%f" >>rsearch.txt
    echo on

    1665.

    Solve : Push a button key without push??

    Answer»

    Hi Guys..

    Can I push a button key without push? I have an APPLICATION running under MS-DOS , when it's starts , I need to push "return" and "F2".  
    In a dos batch file this is not possible , because this HAPPEN only when the application go out.

    Can you help me?...
    ..

    Thanks.-Which MS-Dos Version?
    -Which application?

    UliHi Uli

    Dos version is a boot floppydisk based on windows 98 [4.10.222]...
    The application is for connecting a milling machine , from com1 to rs232.
    This application make use "INDUSTRIAL data link" protocol.

    ThanksHave a string hanging from the cieling with a weight on the end. Have it hanging just over "return" Then have a timer that when GOES of cuts the string!!

    problem solved!

    /meOhhhhhhhhhh.No you can not, dos or batch will not emulate keystrokes. There is a scripthing langage caled autio it that can emulate keystrokes and it is free and easy to learn, of you needx any help with that i will help you.Hi Dakota,
    where I can download this program?

    Thanks Quote

    No you can not, dos or batch will not emulate keystrokes. There is a scripthing langage caled autio it that can emulate keystrokes and it is free and easy to learn, of you needx any help with that i will help you.

    Is it working in M$-Dos? I only know a windows version.

    It is worth a try to send a CARRIAGE return with echo
    scancodes: http://www.torsten-horn.de/techdocs/ascii.htm

    At the win commandline it works with echo(hold alt)13(at the num block).
    Should also work at M$-Dos cause scan codes are same same.

    In a (win) batchscript it is "&echo." in a var to make a cr.

    Is no assembly crack here for a debug solution?

    hope it helps
    uli
     

    1666.

    Solve : input  a name in the same line in CMD Prompt?

    Answer»

    I have composed a batch file. When you double click on it, a COMMAND window prompts up displaying "Your name:"

    Now I want the users type their names in the same line,
    looking like [highlight]Your name: ANDREW[/highlight],
    but my implementation looks like:
    [highlight]Your name:
    Andrew[/highlight]
    The users typed their names in the next line, which is not what I what.

    After typing name and PRESS enter, the user's name should be redirected to a text file. How can I do it? Thanks a lot!
    Try this

    Code: [Select]Set /P MyName=Your name:
    > AnyFile %MyName%

    GrahamGreat!!!
    It DOES work! This is exactly what I want!
    HEAPS of thanks, Graham.

    1667.

    Solve : Batch: Server Copy?

    Answer»

    Hi I was wondering if someone could help me with the code if I am trying to copy a folder and all of it's contents from one server to another folder in another server. OS Windows XP.

    my code...

    echo off
    XCOPY Y:\Dom_SSDBS\LSSPD\787 ENOVIA Tailoring Process C:\Documents and Settings\rw131c\Desktop\testing bat /-y
    pause
    dir c:\windows

    error: invalid number of parameters

    Thanks... Quote

    my code...

    echo off
    xcopy Y:\Dom_SSDBS\LSSPD\787 ENOVIA Tailoring Process C:\Documents and Settings\rw131c\Desktop\testing bat /-y
    pause
    dir c:\windows

    error: invalid number of parameters

    Thanks...


    xcopy "Y:\Dom_SSDBS\LSSPD\787 ENOVIA Tailoring Process"  "C:\Documents and Settings\rw131c\Desktop\testing.bat" /-y

    maybe /y instead of /-y

    hope it helps
    uli
    Yes the quotation MARKS helped the code WORK, but I can't get it to copy folders, and all of it's contents. I added \*.* because nothing was being copied, but only the files are being copied. What is the code for the folders? +dir?

    xcopy "Y:\Dom_SSDBS\LSSPD\787 ENOVIA Tailoring Process\*.*"  "C:\Documents and Settings\rw131c\Desktop\testing bat" /y

    The code above COPIES all the files with out asking for overwrite permission. I need the folders to be copied as WELL. Please help.XCOPY comes with an alphabet soup of switches. Try adding the /s and /e switches. Better yet, xcopy /? from the command prompt will explain all the switches in detail.

    Good luck. 8-)
    1668.

    Solve : administrator?

    Answer»

    wow can i GET administrator user NAME and password for xp  in dos?
    i need these for school computer.
    i have tried net localgroups administrators, but it is just youser name.
    is there any possibility to get it?
    tnx for ANSWERSWHY would you want the Administrator's user name and password:-?  You could try asking the Administrator!!

    If you don't ALREADY have Administrator priveliges then you are probably not entitled to them!!!WINDOWS XP doesn't even come with DOS.  :-?

    1669.

    Solve : is this even possible??

    Answer»

    I want to make a batch file that GETS the ADRESSES of the websites i have open, stores them in a text file, and closes the windows. I want another batch file taht opens the websites LISTED in the text file. If this is possible, it would be great if som1 could help me make the file.

    EDIT: i also want to delete contents of the text file when the second batch file is run

    EDIT2: lol :/ oh well. I know u can open SITES with batch files, and i think u can store them as variables, all i would need is a way to figure out what websites are open.Erm... no. Batch is *not* a programming language. Heck, I am not even sure how to do that in C++. :-/ Quote

    I want to make a batch file that gets the adresses of the websites i have open, stores them in a text file, and closes the windows. I want another batch file taht opens the websites listed in the text file. If this is possible, it would be great if som1 could help me make the file.

    EDIT: i also want to delete contents of the text file when the second batch file is run

    EDIT2: lol :/ oh well. I know u can open sites with batch files, and i think u can store them as variables, all i would need is a way to figure out what websites are open.

    this can be easily done in langauges like Perl/Python etc, but if you want a batch soln, you can try wget.
    The wget command is from the GNU Tools.
    Should be possible with it. Please post your solution when it works. :-)

    uli
    1670.

    Solve : Running *.bat in a batch file?

    Answer»

    Hi everyone,

    I'm trying to write a BATCH file that will be called with the scheduled tasks function of Windows XP.  In this batch file, I want to be able to run any batch file found in a certain directory.  For example:

    call e:\TEST\*.bat

    but for some reason I can't get this to work.  Is there a method of executing multiple batch files without knowing what the names of those files will be?I cannot find any info on using a wildcard with Call.  Have found one site which indicates that the filename is definitely required.

    Here is the C.H. Call site - note that the filename is not bracketed indicating that it is mandatory.

    Good luckYou can't use a wildcard in a call, the cmd processor is just not that sophisticated. You can however create a loop to do a call over the collection of batch files:

    Code: [Select]ECHO off      
    for /f "tokens=* DELIMS=" %%i in ('dir /b e:\test\*.bat') do call "%%i"

    This batch file needs to be in same directory as your batch files. If not, you may need to use the /s switch. You also have some limited options for sorting the files. Check out dir /? for details.

     8-)Excellent!  I was even able to PUT in a provision that after each bat file was run, it would be renamed to .BAK so it would not be run again.  Thanks for the help! Quote

    I was even able to put in a provision that after each bat file was run, it would be renamed to .BAK so it would not be run again.

    but as the FOR cycle steps through all the .bat files in e:\test there should be no risk of running any of them again, if I understand how FOR works.

    How did you manage to rename *.bat to *.bak anyway ?
    I mean, how/where can you do it ?
    After the
    do call "%%i"
    it shouldn't work.
    1671.

    Solve : File Properties using batch?

    Answer»

    anyone know how i can use a batch file to look up the size\free space on a drive??Since I have to GUESS your OS, you have to guess if this will work for you:

    Code: [Select]echo off
    for /f "tokens=3" %%i in ('dir [highlight]c:[/highlight] ^| find /i "free"') do echo %%i

    Feel free to change the drive letter.

     8-)thanks for responding siderwinder, i need to do it both on nt4 and xp, many thanks Quote

    Code: [Select]echo off
    for /f "tokens=3" %%i in ('dir c: ^| find /i "free"') do echo %%i


    it works for me (Windows XP) but only if I write
    for /f "tokens=3" %i in ('dir c: | find /i "free"') do echo %i

    dir c: | find etc. is good
    dir c: ^| find etc. isn't
    what's with the "^|" syntax ?  :-?The caret (^) acts as a escape character when using DOS SPECIAL characters. I couldn't find much documentation on why you need it, just that without it under certain conditons the parser will error out.

    Apparently you need to use it when a DOS special SYMBOL is used in a nested command.

    In the example I gave you: for /f "tokens=3" %%i in ('dir c: ^| find /i "free"') do echo %%i, the pipe (|) is embedded in the FOR command.

    I know, I know, not much of a response, but use it if you get an error by not using it.
    Quote
    The caret (^) acts as a escape character when using DOS special characters.
    Apparently you need to use it when a DOS special symbol is used in a nested command.


    I guess this shows why an expert is called an expert  [smiley=thumbsup.gif]

    It's exactly as you said.
    In a batch file, if I LEAVE the ^ out it breaks, if it's in, the parser itself will take care of it,
    just the opposite at the command line.
    A bit like doubling % in batch isn't it
    I never had any idea it should work this way. Thanks a lot for the info  [smiley=vrolijk_26.gif]  [smiley=beer.gif]
    1672.

    Solve : how to indent output and redirect it to text file?

    Answer»

    I am trying to make the contents of a text FILE look nice, so some lines should be indented following the last LINE. I used the command [highlight]type names.txt  >> list.txt [/highlight] in a batch file, but the output is not what I want.

    The display should look LIKE:
    [highlight]List of the STUDENTS in Year 13:
             Alice
             Helen[/highlight]

    How can I realize this function? Thank you.

                     Quote

    The display should look like:
    List of the students in Year 13:
              Alice
              Helen

    Quote
    type names.txt  >> list.txt

    What display? All you've done is redirected the output to another file. A space is just another character as far as the processor is concerned. What was the alignment in the names.txt file?

    If this goes back to your other posts about more, then ALIGN the names.txt file using the space bar.

    more >> names.txt
    Code: [Select]List of the students in Year 13:
            Alice
            Helen

    Use the spacebar to insert the leading spaces in front of Alice and Helen or better yet use an editor such as EDIT or even EDLIN.

     8-)

    Are you really running MS-DOS or just a look-alike under Windows?
    1673.

    Solve : "SYSERR" parameter?

    Answer»

    Anyone ever use the "SYSERR" parameter in their DOS batch FILE for checking the "return-code"?  If so, can you provide a snippet of the code? I am LOOKING for an aternative to "%ERRORLEVEL%.   Could not find any documentation on SYSERR except as a user written C function. Why do you need an alternative to ERRORLEVEL? What are you trying to do?

     8-)I cannot count on ERRORLEVEL becuase it fails to catch an fileErrorException such as "Un-successful file delete - access denied", and always returns a misleading zero condition code.

    This error situation occurs when trying to delete a file which I don"t have access to; here's the code:
    call C:\WINDOWS\SYSTEM32\CMD.EXE /c DEL D:\myFile01.txt
    Nobody ever accused Microsoft of being consistent, especially with error CODES.

    This might be helpful:

    Code: [Select]if exist D:\myFile01.txt call C:\WINDOWS\SYSTEM32\CMD.EXE /c DEL D:\myFile01.txt

    Quote

    This error situation occurs when trying to delete a file which I don"t have access to;

    Not sure what this means, but if you don't have access to the file, how do you expect to delete it?

     8-)I know this sounds silly; but the "access denied" error situation does occur when a batch cmd file is run for the first time in production, and someone has overlooked granting the APPROPRIATE access to the userAccount.

    I"ll test the "If exist" clause, and see how it behaves in my .bat file.

     


    1674.

    Solve : How to get value in variable from FINDSTR function?

    Answer»

    Hi,

    Can anyone please help me out in this, this task is most important for me, Please accept my thanks in advance and help me RESOLVING this issue.

    Sandy

    Please see the code below, i am trying to search for a particular string in a specific file using FINDSTR function, after that i have to execute a CONDITIONAL task, mean if conditions is true than task will be executed other wise not.

    PLEASE NOTE BELOW CODE IS NOT WORKING, IT IS NOT GETTING VALUE RETURNED BY FINDSTR.
    ===================================================================

    set StatusValue =  FINDSTR StatusValue "Import finished" c:\test2.txt

    echo %StatusValue%

    if not '%StatusValue%' == 'Import finished'(
          echo TEST successfull
          goto END      
           )      ELSE (
          goto FileNotFound
          goto END
    )This must be one of those puzzles that if you stare at long enough you'll go blind. I can't for the life of me see where FINDSTR is actually executed.

    First up: set StatusValue = this statement is declaring a variable NAMED [highlight]StatusValue [/highlight]; note the trailing space. This will never equate to %StatusValue%

    SECOND up: the FINDSTR needs a search string and a filename to search; switches are optional.  You are using too many arguments.

    Third up: single quotes and double quotes while both very useful, are not interchangable.

    If you are trying to see if the string "Import Finished" is found in c:\test2.txt something like this may work:

    Code: [Select]echo off
    findstr /i "Import finished" c:\test2.txt
    if errorlevel 1 echo Test Unsuccessful & goto end
    if errorlevel 0 echo Test Successful & goto end
    :end

    Hope this helps.  8-)
    Thanks a lot it resolved my problem, You are a life saver.

    1675.

    Solve : DOS Programming Language?

    Answer»

    :question
    I have simple question. Where can I leanr more about what code and
    syntax that is valid under DOS? I know I COULD go to the store and buy a book
    I guess, but I was hoping I could find SOMETHING on the web.

    I am trying to learn more about working in DOS, and have found MANY sites
    that list all of the valid command built into DOS, but I do not see much which
    instructs of details the use of syntax/code (ex. tokens, do, %), and code structure.

    Exactly what programming language would this be considered? A form of Basic?

    I've DONE some programming in VB6 so I have a basic understand of programming
    structure. I would like to change that.

    Thanks for any guidance anyone can provideThis site is good - http://www.ss64.com/ follow the link for Windows NT/XP commands - it DEFINES syntax and gives examples.

    If you really WANT to know how to use batch commands, this site is possibly the leading edge for tips and tricks - http://www.macalester.edu/~fines/batch_tricks.htm

    This is another great site http://dostips.cmdtips.com/

    It is not really a programming language, it is a scripting language and is nothing like basic; it is in a class of its own.

    Have fun with it, it can really help you in your work
    Graham
     
    Thanks Graham,
    I will check these out!

    1676.

    Solve : start services?

    Answer»

    i can START PAUSED services in DOS as using "net start" COMMAND (XP_SP2)


    net start messenger
    or
    sc start messenger

     but

    How can i start CLOSED services  in DOS (not paused just closed)

    1677.

    Solve : need help (network dos command)?

    Answer»

    hello..i'm a newbie.i have a question.can i access other pc RESOURCES (ex. CDROM) USING dos command.?I have 2 pc (old) CONNECTED only by printer port(laplink cable) 1pc have the cdrom,the 2nd pc dont have.(you cannot PLACE the cdrom of pc1 to pc2)..the pc2 is formatted (no OS) i want to install WINDOWS 98 but the installation cd is in the cdrom of pc1, how can i install OS using the cdrom of pc1..

    1678.

    Solve : Testing Dir for NO Files?

    Answer»

    I have done a review and search of you system and I can't find an answer that way.  So I will toss out this question to you all myself.

    Utilizing XP Professional (and possible Home version) DOS

    I need to test the subdir to see if there are any files placed in it.  If a file is there, then it would get moved out or zipped up and deleted out of the subdir.  But if there is no file in the subdir then the routine would move onto the next task.

    ie

    if not exist C:\users\Netbak\*.* goto Skip
    move C:\users\Netbak\*.* C:\users\SaveToZip

    I have found when the subdir is empty that I then get an error
    1st the routine does not goto Skip
    So it ends up doing the next line that should have been skipped
    Then I get the move error, that there are no files to move
         The filename, directory name, or volume label syntax is incorrect.
    Might be easier to SPECIFY each file individually instead of using wildcards.

    Code: [SELECT]echo off
    for /f "tokens=* delims=" %%i in ('dir /b /s C:\users\Netbak') do (
        move "%%i" C:\users\SaveToZip
    )

    The code will loop as many times as there are files, including zero times.

     8-)
    I have to use wildcards because I don't really know what type of files I might find in a couple of the dirs that I have to work with.

    Your suggestion worked very nicely in my test program.  I will incorporate it in the main program and see what happens.  

    Thank You Very MUCH!!!Further testing reviels the basically same problem.

    So I will try to expound on the problem (simplistically).

    The routine first goes thru the hard drive various sub dirs to clean out old files to be zipped up into temp archive files. (After a month we have found that if you have not needed the files yet, you are not going to need them because of newer simular files.)
    Anyhow, if the routine doesn't find any files in any of the subdirs. It still gets an error when it trys to zip up the dir where all the files should be placed but is found to be empty.

    So I still have a need to test a dir to see if it has anything in it or if it is empty.

    The following code;
              if not exist C:\users\Temp\*.* goto b5
      will only test test true if the dir does NOT exist
      will test false if the dir DOES exist, empty or not
    Which is where my problem is!
    The dirs exist, I need to test if they are empty or not.

    The suggested routine works with the need to move the files, existing or not, without erroring.  But I still need to test for the zipping routine, to avoid the error.

    Am I looking at this wrong? Or with tunnel vision?

    Waiting for help.I am running in to the exact same problem. Have you got a fix or work around yet?There are probably other ways to do this, but counting the NUMBER of files moved to the zip directory seems simple enough.

    Code: [Select]echo off
    for /f "tokens=* delims=" %%i in ('dir /b /s C:\users\Netbak') do (
        move "%%i" C:\users\SaveToZip
        call set /a count=%%count%%+1
    )
    if %count% GTR 0  ...zip routine goes here

    Not for nothing, but I don't see any logic for aging the files.

     8-)

    On a XP machine I would suggest using Windows Script (VBSCRIPT)

    To test for a dir existing: if exist C:\users\SaveToZip\nul should work.To check FOLDER and sub-folders for existing files try:

    dir /b /s /a-d C:\users\Netbak 2>NUL&&echo.Files exist
    or
    dir /b /s /a-d C:\users\Netbak 2>NUL||echo.No Files

    Note if you have sub-folders but no files it returns "No Files".
    Hope this helps

    1679.

    Solve : change date display format in DOS?

    Answer»

    How can I change the current date format from DD/MM/YYYY to YYYY-MM-DD?
    Note: it is "-", not "/" to connect the figures.Assuming you're not talking about real dos then you can change it in Windows Control Panel Regional Settings and your 'dos prompt' will reflect the changes.What I really want is to get a DATE string in the format of YYYY-MM-DD, and this YYYY-MM-DD string can be redirected to and stored as a text file. Is it possible to change the format with a dos command? Or this task requires a batch file to complete? Thanks. There is no command that came with your OS (whatever it might be) but on some systems you can build one yourself:

    Code: [Select]for /f "tokens=2-4 delims=/ " %i in ('date /t') do echo %k-%i-%j > date.txt

    Note: Example will work at command line; if used in batch file double up on all the % symbols

     8-)

    This must be week FOR Hi, thanks a lot, Sidewinder! I do get a date string "2006-09-12" with a revised version of your command:
    FOR /F "TOKENS=1-3 DELIMS=/ " %I IN ('DATE /T') DO ECHO %K-%J-%I > DATE.TXT

    Now I want to create a folder using the date string as the folder name, SINCE the name rule is 8.3 format, so I need to use 8 digits for the name, better use "06-09-12", how can I chop off "20" in the head of string?

    I have tried to use delims=/0, but not successful, it will appear "6-9-12".Presumably your OS is a state  secret. TRY using the KISS method, drop the hyphens:

    Code: [Select]FOR /F "TOKENS=1-3 DELIMS=/ " %I IN ('DATE /T') DO ECHO %K%J%I > DATE.TXT

    Quote

    ...since the name rule is 8.3 format
    Why?

     8-)
    PUT the date in a variable and substitute it:
    :: --------
    FOR /F "TOKENS=1-3 DELIMS=/ " %I IN ('DATE /T') DO set datum=%K-%J-%I
    set datum=%datum:~2%
    :: ------

    Should give you 06-09-12

    hope it helps
    uli Quote
    Put the date in a variable and substitute it:
    :: --------
    FOR /F "TOKENS=1-3 DELIMS=/ " %I IN ('DATE /T') DO set datum=%K-%J-%I
    set datum=%datum:~2%
    :: ------

    Should give you 06-09-12

    hope it helps
    uli



    It DOES work! Thanks a lot. Quote
    Presumably your OS is a state  secret. Try using the KISS method, drop the hyphens:

    Code: [Select]FOR /F "TOKENS=1-3 DELIMS=/ " %I IN ('DATE /T') DO ECHO %K%J%I > DATE.TXT

    Quote
    ...since the name rule is 8.3 format
    Why?

     8-)


    hehehe,,,,,,,This is my own rule.   Because all my other files and folders are stored in this 8.3 format, and I don't want an exception, just to keep them look nice and neat . Thanks, Sidewinder.Hi, uli_glueck and Sidewinder, thanks for your contributions to this TOPIC. The code provided DOES work!   Now I have an idea on how to deal with the date string.
    1680.

    Solve : Cryptic (to me) dos syntax?

    Answer»

    every now and then I come across batch files EXHIBITING a strange syntax
    as follows :
    ..\..\utilities\mtx hud.mtx K:\Indy\Art\Hud\MTX\*.tga /c /i %1

    what this is for really isn't that important to me (fyi it's coming from one
    rebuild.bat buried deep in a GameData directory after installing Lucasarts'
    Indiana Jones and the Emperor Tomb game).

    What is strange is the
    ..\..\utilities\
    path : what do these "..\..\" really mean ?
    It reminds me of one of those cd.. or cd\ commands, but there's something
    not quite clear here, so I decided I'd BETTER ask for help
    from anyone expert on this.
    Thx in advance.".." means "one level up". For example, if you're in

    C:\Program Files\LucasArts

    and you type at the prompt "cd ..", you'd be in

    C:\Program Files

    OK? Quote

    ".." means "one level up". For example, if you're in

    C:\Program Files\LucasArts

    and you type at the prompt "cd ..", you'd be in

    C:\Program Files

    OK?


    Sure - but the OP indicates that CD, or any other valid COMMAND such as DIR, is not shown in the batch file...    ..\ can be used as the last directory in the Path statement but here :-?  Got me kerfluggled...

    Quote
    OK?

    OK!   As I said though I knew the cd.. syntax, what I wasn't sure of, is
    whether issuing a ".." command LIKE that would be OK'd in a batch file especially at the very
    beginning of a line.
    A sort of shorthand writing, so. And very powerful too  

    I tried and saw that if I am, say in

    C:\PROGRA~1\xerox\nwwia>_

    and type

    ..\..\dosbox-0.65\dosbox.exe

    not only does it work, but what happened is in just one stroke
    I skipped 3 cd commands, BACKED up 2 levels
    and descended 1 side level all in one  

    Great isn't it
    1681.

    Solve : DOS Batch - Remove all Directories with a specific?

    Answer»

    Looking for syntax to remove all folder on a machine with a specified
    NAME structure and a wildcard.

    Ex.

    All folders with the name structure "BACKUP for 12-31-05", "Backup for 07-05-04"

    So any folder with the parameter "Backup for *"

    Is this possible in DOS?
    Is this really DOS or some version of the command shell under Windows? This may work:

    Code: [Select]for /f "tokens=* delims=" %i in ('dir /a:d /b backup*') do rd "%i"
    Note: the above example is from the command line. For a batch file double up on all the % symbols.

     8-)This would be a command shell under windows. This would have to be
    a batch file run on multiple computers.

    By double up do you mean just add another like such:

    for /f "tokens=* delims=" %%i in ('dir /a:d /b backup*') do rd "%%i"

    One more question... where is the drive specified, or is it just specified
    by the working DIRECTORY it is being run under?

    Thanks for your help.You have it right for a batch file. Code was written for the current directory. If you add a path to point to your directory structure, you may have to add the /s switch. Be careful, you may get more than you wish for.

    Code: [Select]for /f "tokens=* delims=" %%i in ('dir /a:d /b /s c:\dir1\dir2\backup*') do rd "%%i"

    PERSONALLY I would change the RD command to ECHO, and test this out before committing to deleting directories.

     8-)

    1682.

    Solve : DOS config sys error loading ghost boot disk?

    Answer»

    I am having trouble getting ghost 8.2 network BOOT up disks to work.
    I have all the correct drivers on the floppy disc, but when it starts booting up
    I get the following ERROR.

    "the configuration specified in your CONFIG.SYS file is too large for memory.
    Remove some drivers , and then try again"

    Can anyone help me fix this problem.

    thanks,
    Monty
    email [email PROTECTED] pleaseInsure that himem.sys and emm386.exe are on the disk. Make the FIRST two lines in config.sys read:
    device=a:\himem.sys
    device=a:\emm386.exe
    This assumes you're booting from floppy drive a:
    If not, CHANGE a: to the appropriate drive letter.

    1683.

    Solve : Logging into Admin Account through DOS Prompt?

    Answer»

    In my Windows XP, I mainly use a non-admin account to do most things, and to protect myself a little, HOWEVER, some batch file commands require admin RIGHTS, so I usually have to log out of my non-admin, and load up the admin. Is there a way that I can just log into admin right through the dos prompt itself?

    su root anyone?  Check the ressource kit for the "su" command. (For NT and W2k its availaible.)
    You have to CREATE an account for the su; it is usable LIKE the unix su.

    hope it helps
    uliProvided the admin account password is not blank, you might be able to use the the runas command. Check runas /? for details.

     8-)

    1684.

    Solve : i need command help?

    Answer»

    this comp I am working on is completely messed up.  I have TRIED to reload windows but when it gets started it freezes up and have to close or ignore that message and it just completely blanks out.  I know i need to do a complete system restore but there is a file that i need to backup in mydocuments THATS extremely important.  I have to do this i assume through DOS because windows will not boot at all.  The A drive is not wanting to write anything what do I do?First thing to do is tell us something about your pc.   For EXAMPLE your OS, hardware configuration, do you have a legitimate copy of your OS cd :-?  Are you trying to boot up from a bootdisk, if so which one.  What is your file system NTFS vs Fat32 vs Fat16 :-?  

    Very hard to advise if we don't know what we're trying to debug.  Give as much info as you can, too little is almost useless, too much is better.



    dusty it is a Compaq prescario 7470  operating on win 98 with fat32 or should I say used to operate on win98 now it does good to go to dos
    Quote

    First thing to do is tell us something about your pc.   For example your OS, [highlight]hardware configuration, do you have a legitimate copy of your OS cd :-?  Are you trying to boot up from a bootdisk, if so which one. [/highlight] What is your file system NTFS vs Fat32 vs Fat16 :-?  


    Please answer the highlighted questions

    Can you boot from a floppy? If not, boot from the CD. You might have to go into bios and change the boot order. Booting from the floppy defaults to 'with cdrom support' and the CD has that as option 2.i've tried booting from the cd and it will not boot the only thing i can try to get the cd to do is to REINSTALL windows and not even a minute after setup is running it gives me an illegal operation message and crashes.When you boot from the CD select option 2. If you don't select an option it defaults to running setup.
    1685.

    Solve : connecting monitors?

    Answer»

    Help please,

    I have PURCHASED a PC toTV wireless SENDER and it needs to be connected to the PC THRU the normal VGA monitor connection, however, my monitor USES a DVI connector and although the graphics card has both connectors when I utilize the VGA for the PC Sender it does not SEEM to have an output available.

    Can anyone advise how to ensure that the graphics card outputs on both connections?

    Phil

    1686.

    Solve : Batch file not executing in batch mode??

    Answer»

    I have a batch file that executes the same command several times and redirects the output to a text file.  This used to work flawlessly.  Now, after the first time it executes, it says that the file is in use by another process.  I ran the batch file without redirecting the output, and it works.  So it seems to be narrowed down to the ">" operator.  Why is this holding my file open?  And how do I fix it?

    EXAMPLE:
    foo.exe > bar.txt              <--This one works
    foo.exe >> bar.txt
    foo.exe >> bar.txt
    foo.exe >> bar.txt
    foo.exe >> bar.txt
    foo.exe >> bar.txt            <--This one also works; all the ones in between have the errorAt first glance nothing seems to be wrong.

    What OS are you using? What program does FOO.EXE represent? Is FOO homegrown or part of a commercial product or downloaded from the net?

    More info needed.  8-)

    After 25 years, it probably safe to say that Microsoft's redirection code is reasonably stable.The OS is XP Pro.  Foo.exe represents a program which retrieves information from a proprietary external device, and prints it to the standard output.  To my knowledge, it does not touch any files.

    My current solution is to sleep for a few milliseconds between each call, but with enough iterations, it's costing a lot of time.My suggestion would have been to sleep the batch file between program calls as I suspect this is a timing problem.

    You mentioned that this used to work. What changed? OS? Code change to FOO?

    My best guess is that FOO is not using the the DOS functions for it's output. Also I am only aware that redirection was for output to the console not the printer.

    Maybe someone will happen by with some other ideas.  Hmm.  It used to work, and then we ghosted the box to factory settings.  I think your best guess is right.  Foo.exe was originally written for UNIX and then ported over to WINDOWS.  Looking at the code, it looks like it relies on some UNIX libraries which I don't have access to, but its output is through PRINTF, which would be the console, right?

    Regardless, shouldn't a batch file wait until the process returns before continuing on to the next command?

    Thanks for your help.   Quote

    Regardless, shouldn't a batch file wait until the process returns before continuing on to the next command?

    In theory yes. It seems this redirected output file has no connection to FOO and it's Windows thats opening the redirected file because of the reference on the program call and it's Windows that's closing it, but doesn't get to it right away. This would account for the file being open when the next FOO starts.

    Just a thought. 8-)Would the Conditional Processing Symbols & or && be of use :-?

    See here.

    In the end, it was explorer.exe that had the file open.  If there's a window open in the background with the containing folder, it seems Windows keeps checking on the file each time it's updated, so it takes control over the file.  With all Explorer Windows closed, it works again.

    Thanks for all your help
    1687.

    Solve : How to enable or disable xp firewall from the command line??

    Answer»

    I recently remote installed Symantec Endpoint virus defense software on a bunch of computers on the same subnet and just found out that installing it didn't automatically disable the Windows firewall on the workstations. (I used to use McAfee in the past, it always disabled the windows firewall automatically.)

    Do you guys know how can I query the status of the firewall remotely using some command line script and turn the firewall off if I have to?Why do you WANT to turn off the Firewall?Symantec Techsupport told me (although I am not sure how reliable they are and how well know their own product) that if the "Network threat protection" part of Endpoint is installed, you can turn the windows firewall off.

    Since it is installed on all workstations, that's why I was considering turning off the Windows firewall based on the assumption that two firewall fighting for the same resources could potentially slow the system.

    (McAfee techsupport was always top notch, I was assuming the same for Symantec.)

    Geza
    I found the SOLUTION:

    Code: [Select]psexec \\computername netsh firewall set opmode DISABLE
    where psexec is one of sysinternals cool utilitites.You can just use netsh.exe. I wrote this some time ago. Might be useful

    Code: [Select] echo off
    echo getting firewall state........
    echo.
    netsh firewall show state | FIND "Operational mode"
    echo.

    set /p state="0=disable 1=enable ? "

    if "%state%"=="1" goto enable
    if "%state%"=="0" goto disable

    :enable
    netsh firewall set opmode ENABLE &GT; nul
    goto done

    :disable
    netsh firewall set opmode DISABLE > nul
    goto done

    :done
      echo.
      echo getting firewall state........
      echo.
    netsh firewall show state | find "Operational mode"
    Thanks for the complete script, since I want to run it remotely on workstations I could run it by setting up remotely a Scheduled task  for this purpose, which I know how.
    Thanks!

    P.s.: I tried to use the "netsh -r computername" variation before but it always gave me command not found errors even though I am admin on both local and remote machines.if you want to set firewall state remotely I guess you will need to strip out the prompt to choose a firewall state setting & just choose to set to a known stateYes, I could do that, or I could run your original script redirecting the output to a commonly accessible log file, so that I can see the result later.

    Since your script runs both scenario, I'd have to modify it to do nothing on one of them.Maybe I'm missing something, but as it stands, my script starts by discovering the current firewall state and then issues a prompt for the user to either type a 1 or a 0 and press ENTER. Surely if it were run remotely it would wait forever unless a person happened to be sitting there at the time to do this?

    Nope, you were not missing anything, I was.

    I didn't recognize the prompt in the code, I thought, that this was just a theoritical code for both scenarios, when it is disabled, it will enable it and vica-versa, sorry about it, my fault.

    1688.

    Solve : >> write command help needed?

    Answer»

    how would i code this to give "HELLOWORLD.txt" specific ATTRIBUTES such as hidden or read only?

    Code: [Select]echo off
    >"c:\documents and settings\%user%\desktop\HELLOWORLD.txt" echo this is LINE ONE
    >>"c:\documents and settings\%user%\desktop\HELLOWORLD.txt" echo this is line two
    at the moment all i know is how to write stuff from batch, but not how to change the attributes of the files i write.  can somebody show me how?You use the attrib command, and you can pass it up to 4 parameters which can be + or - r, a, s or h for readonly, archive, SYSTEM, or hidden.

    thus attrib +r helloworld.txt makes that file read only and attrib +r +a -s -h helloworld.txt sets the readonly and archive bits, and unsets the system and hidden bits

    1689.

    Solve : Problem with printing multiple pdf-files via batch file?

    Answer»

    For work I need to print around 360 different pdf-files. the printing is done via a batch file, containing the following code:

    ECHO OFF

    if %1 == WORD GOTO WORD

    if %1 == EXCEL GOTO EXCEL

    if %1 == PDF GOTO PDF

    echo No valid document specified to print
    GOTO END

    :WORD
    echo Printing with Word
    "c:\Program Files\Microsoft Office\Office\WinWord" %2

    GOTO END

    :EXCEL
    echo Printing with Excel
    "c:\Program Files\Microsoft Office\Office\EXCEL" %2 /mAirmadprint

    GOTO END

    :PDF
    echo Printing with Acrobat Reader
    "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe" /t %2
    GOTO END

    :END
    CLS


    Now the problem is that every pdf-file that opens to be printed, doesn't automatically close ANYMORE, which it normally needs to do thanks to /t. So I have to manually close every pdf-flie that needs to be printed.
    Is it a problem of my code or with acrobat, that the pdf-files aren't closed automatically?

    I'm using Windows XP professional SP2 and acrobat reader 7.0.8. Keep in mind that I can't update the programs, since this is a company computer.

    Thanks in advanced.
    You have left out some parameters. See below

    http://support.adobe.com/devsup/devsup.nsf/docs/51412.htm

    Thanks for your reply and I have found the solution.
    Apparently there was nothing WRONG with the code, those extra parameters weren't necessary at all. The solution is that you already need to open a acrobat reader window before you start printing and then you will obtain a continuous loop of opening, printing and CLOSING the MULTIPLE pdf-files. Very simple, but ALSO very weird.

    But still many thanks for your help!

    1690.

    Solve : how to read the number of files in a folder?

    Answer»

    hello
    If I want to import 10 files in a folder, how to write a batch SCRIPT in order to import those 10 files? I mean how to read the number of files in that folder and write a loop for doing that?

    thanks!!I am not sure exactly what you are asking, but I right click on item, click properities and click on general tab to see how many folder and files.in a batch:
    Code: [Select]for %%P in (*) do <command>
    I mean if there are 5 files in a folder, the dos batch command can return 5. It knows how to count the number of files in a folder

    Thanks!Method 1

    Code: [Select]echo off
    setlocal enabledelayedexpansion
    set /a files=0
    for /F %%A in ('dir /b /a-d') do (
        set /a files=!files!+1
        )
    echo There are %files% in this folder.
    method 2

    Code: [Select]for /f "tokens=1 delims= " %%A in ('dir /a-d ^| find "File(s)"') do echo %%A files thanks!actually in method 2 you don't need the "tokens=" stuff, this will do

    Code: [Select]for /f %%A in ('dir /a-d ^| find "File(s)"') do echo %%A files
    or if you want the number in a variable

    Code: [Select]for /f %%A in ('dir /a-d ^| find "File(s)"') do set /a files=%%A>nul
    echo %files%
    thanks a lot for yr both help!Then how to make a loop command for doing 7 TIMES in batch? Like other programming:
    for i < 7 then do (process), i++

    can batch command make it?

    thanks Quote from: garyypk on JULY 21, 2008, 01:26:56 AM

    Then how to make a loop command for doing 7 times in batch? Like other programming:
    for i < 7 then do (process), i++

    can batch command make it?

    thanks

    You use the FOR command with the /L switch

    FOR /L %%[single letter a-z,A-Z] IN (start,step,end) DO command

    e.g.

    Code: [Select]FOR /L %%i IN (1,1,7) DO echo %%i
    or you can have more than one line in the loop using parentheses

    Code: [Select]FOR /L %%i IN (1,1,7) DO (
         echo This is loop number %%i
         echo %time%
         )
    or

    Code: [Select]set start=3
    set step=2
    set limit=27
    echo Here are some odd numbers...
    FOR /L %%i IN (%start%,%step%,%limit%) DO (
         echo %%i
         )
    to see full details type FOR /? at the prompt.

    If you are used to other languages, you may find that you cannot set and read variables INSIDE the loop as you could in other languages, as cmd.exe expands all variables at runtime, and variables contained in parenthetical expressions like these are blank at runtime.

    Code: [Select]IF "%variable1%=="%variable2%" (
        set message=EQUAL
        echo %message%
        )

    FOR /L %%i IN (1,1,7) DO (
         if "%%i"=="5" set message=FIVE
        echo %message%
         )
    In those two examples, %message% will be blank inside the parentheses [but not afterwards]. You need to use delayed expansion.

    Enable it like so

    setlocal enabledelayedexpansion

    and

    the variables use ! instead of %

    so these would work

    Code: [Select]setlocal enabledelayedexpansion
    IF "%variable1%=="%variable2%" (
        set message=EQUAL
        echo !message!
        )

    setlocal enabledelayedexpansion
    FOR /L %%i IN (1,1,7) DO (
         if "%%i"=="5" set message=FIVE
        echo !message!
         )

    1691.

    Solve : net send isnt working??

    Answer» NET send 0.0.0.0 "msg"


    why does it return a error, the message alias COULD not be found on the NETWORK?If I remember correctly one or two things have to be set correctly:

    1. the service "Messenger" has to be RUNNING on both the sender and the receiver computer

    2. File and printer sharing has to be enabled in the firewall setttings of the receiver computer. (I am not sure about the sender computer).
    1692.

    Solve : Is there a way to loop through a set of commands and send an email after each?

    Answer» HELLO All,
    I have this batch file with the following commands. All commands are executed in sequential order from the "push" directory.  This batch file is called in another batch file. I need to send out an email after each "call" command completed. I used the "GOTO" command to jump to the ":MailSend" section  and send out the email. However, I  don't know how to get  back to the "pushd" directory and execute the next "call" command.

    I would really appreciate your help.   

    Also, if anyone can help me construct  a "FOR" loop to iterate to the "call" commands instead of having to write them 3 times in the file. For example, I LIST the first  "call" command three times  because I want to run it 3 times. I would like to only write it once and loop 3 times or more .

    I look forward to getting reply from anyone who can assist with these.

    Thanks....

    ECHO ON

    pushd D:\Program Files\XXX\zzzShared\plugins\com.yy.aa.test.lt.cmdlineexecute_7.2.0.v200803051948


    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt"
    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt"
    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt"

    echo Three 15 minutes for 15 users  runs completed.


    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig1S.txt"
    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig1S.txt"

    echo Two 2 hours for 40 users runs completed.


    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfigMS.txt"
    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfigMS.txt"

    echo Two 2 hours run with 4 stages completed.


    call cmdline -configfile "%USERPROFILE%\\dirX\SchedConfigLR.txt"

    echo Twelve hours long duration for 40 users run completed.


    echo A total of 8 runs completed.


    popd

    echo DONE !!!


    :MailSend
    popd
    mailsend1.15b5.exe -smtp server  -l "emailaddressfile.txt" -f fromtoemail -sub "Subject" < "msgfilel.txt"


    :End
    popd
    ECHO Run #1 completed.

    i dunno if this will work but you can make another file with
    Code: [SELECT]mailsend1.15b5.exe -smtp server  -l "emailaddressfile.txt" -f fromtoemail -sub "Subject" < "msgfilel.txt"

    and in your code add

    Code: [Select]call thisfile.bat
    and for for loop

    Code: [Select]for /L %%a in (1,1,3) do (
    call cmdline -configfile "%USERPROFILE%\dirx\SchedConfig.txt"
    if %%a equ 3 goto A
    )Hello devcom,
    Thanks for the quick response.  You're awesome!!!!!!!!!!!!!!!!!!!!
    I took your suggestions and modified my script, it worked beautifully.

    Added the email code to a file call "MailSend.bat" and call it in the script

    Code: [Select]mailsend1.15b5.exe -smtp servername  -l ".\XXDIR\EmailAddressfile.txt" -f fromemailaddress -sub "subject text" < ".\XXDIR\mesgfile.txt"
    pushd D:\Program Files\XX
    Pushd is included in the "Mailsend.bat" because I need it to switch to this directory to execute the next "call" command after sending the email .

    For the "FOR" loop, I divided all the "call" STATEMENTS into group (i.e A, B, C, D). and called "MailSend.bat" within the loop.

    Code: [Select]:A
    for /L %%a in (1,1,3) do (
    call cmdline -configfile "%USERPROFILE%\XX\SchedConfig.txt"
    popd
    call ".\MailSend.bat"
    echo A 15 minutes run for 15 users and 1 stage completed.
    if %%a equ 3 goto B
    )
    popd is included because I need to to switch to  mailsend's directory before calling  "MailSend.bat"

    Thanks again devcom
    Would you mind reviewing other batch scripts for me and make suggestions where I can improve and make them more robust? Glad i could help
    Quote
    Would you mind reviewing other batch scripts for me and make suggestions where I can improve and make them more robust?

    ok just PM me
    1693.

    Solve : Can FOR command use with range??

    Answer»

    Hi,

    Is it possible to use FOR command with range SELECTION

    -  I have computer names range from A001 to A0010 and B001 to B0020.

    -  If computer name is between A001 to A0010, it will SET the computer with autologin account A and autologin account B for range between B001 to B0020.

    Thanks.   Yes this is possible. Please DESCRIBE your requirement more fully.
    I am building PC image and setup login script that check computer name (%COMPUTERNAME%) and setup the autologin account based on the computer name.  The computer name will be within specified range such as from a001 to a005 and b001 to b0010. 

    I think something like:

    FOR /F %COMPUTERNAME% SET AUTOLOGIN-A

    I just don't know how to use FOR command with range.  I probably can use FOR with GOTO but I don't WANT to type all computer names.  I read that FOR command can use token range but there is limitation of having only 26 lines?

    Thanks for your help.

    please describe example of a computer name and desired autologin name for that computer name.workstation computer name group:

    W00001
    W00002
    W00003

    it will set with autologin account:  C-A-WKS

    laptop computer name group:

    L00001
    L00002
    L00003

    it will set with autologin account: C-A-LTP
    What about the numbers?Do you mean the computer numbers?  the number will be INCREMENT by 1 for each group so for workstation group number will be W00001, W00002, W00003 up to W00020 while for laptop will be L00001, L00002 up to L00010. Code: [Select]echo off
    setlocal enabledelayedexpansion
    for %%a in ( W L ) do (
       for /L %%b in (1,1,10) do (
       if %%b gtr 9 (set pot=000) else (set pot=0000)
          if %%a equ W (%%a!pot!%%b C-A-WKS***) else (%%a!pot!%%b C-A-LTP***)
    ))


    ***dunno about autologin command

    dunno if this will work

    1694.

    Solve : Delete files not only in Root but in Subfolders too?

    Answer»

    Ok im TRYING to make a batch program that will delete BAK and TMP FILES throught my HD. but im stuck on one thing. Deleting the folders in the subdirectories too. how can i do this?

    Thanks in Advance
    ,Nickecho off
    set path=c:\folderwithfiles
    for /f "tokens=1*" %%a in ('dir /a %path%\*.bak /b /s') do del /q/f "%%a" Quote from: diablo416 on July 21, 2008, 08:39:47 AM

    echo off
    set path=c:\folderwithfiles
    for /f "tokens=1*" %%a in ('dir /a %path%\*.bak /b /s') do del /q/f "%%a"

    While the solution posted works for most files, filenames with embedded spaces will be bypassed. A more global solution might be:

    Code: [Select]echo off
    for %%x in (tmp bak) do (
    for /f "tokens=*" %%a in ('dir /a c:\temp\*.%%x /b /s') do echo del /q/f "%%a"
    )
    )

    Using path as a variable will change the system path until the command window is closed. Better to use another variable name or hardcode the directory.

    The del command has a /s switch for subdirectories. Use at your own risk.

    Just my 2¢ 

    I dislike posting DESTRUCTIVE batch code, so I added an extra echo prior to the del command. Once you are happy with the preview, you can remove it.Sidewinder,

    May I ask how do you highlight and frame the code part of your messages?
    I looked at all toolbar options but I couldn't found any RELATED command.

    Geza
    For the code box use the # BBC tag.

    For the bold highlight, use the "B" BBC tag

    The icons are located under the subject line when replying to a post.

     

    I'm sure SOMEONE else might explain it better, with pictures even. Code: [Select]I got it! Thanks!thanks diablo and sidewinder

    it works
    1695.

    Solve : Command Line command for manipulating word file?????

    Answer»

    Dear reader,
    Is there any command line command to manipulate the word document.
    For example: Modifying the Header content in the word document or adding some reference no on top of each and every page.

    Thank you,
    Ramesh Shrestha

    P.S.:Forgive me if this is not right place for this question. Quote

    Is there any command line command to manipulate the word document.

    Batch code can open a document. End of STORY. Any of the scripting languages that are COM aware can manipulate the document.

    Example to add header to first page of document:
    Code: [Select]Const wdHeaderFirstPage = 2

    Set objWord = CreateObject("Word.Application")
    objWord.Visible = True

    Set objDoc = objWord.Documents.Add()

    With objDoc
        .PageSetup.DifferentFirstPageHeaderFooter = True
        .Sections(1).Headers(wdHeaderFirstPage) _
            .Range.InsertBefore _
            "Written By Sidewinder"
    End With

    objDoc.SaveAs "C:\Temp\Test.doc"
    objWord.Quit

    Save SCRIPT with a VBS extension and run from a command prompt as cscript scriptname.vbs

    More information can be found here.

    Good luck.  Thank you Sidewinder

    It does what i want to do. But sometimes it replaces all header if there is the header in all three (left,center and right) alignment.

    Is it also possible in case of footer having page number in it? Should maintain the alignment of the page number.

    Thank you
    Ramesh Shrestha
    Quote
    It does what i want to do. But sometimes it replaces all header if there is the header in all three (left,center and right) alignment.

    If there is already text in the header, you'll need to capture it, align your new text with the existing text, then push everything back into the header.

    I added to the existing snippet for a page number footer:

    Code: [Select]Set objWord = CreateObject("Word.Application")
    objWord.Visible = True

    Set objDoc = objWord.Documents.Add()

    With objDoc
      .PageSetup.DifferentFirstPageHeaderFooter = True
      .Sections(1).Headers(2).Range.InsertBefore "Written By Sidewinder"
    End With

    Set objRange = objDoc.Sections(1).Footers(2).Range
    Set objTemplate = objDoc.AttachedTemplate
    objTemplate.AutoTextEntries("Page X of Y").Insert objRange

    objDoc.SaveAs "C:\Temp\Test.doc"
    'objWord.Quit

    Page number is formatted 1 of N.

    Hint: Scripting Word can be difficult; try using the Word GUI and record a macro of what you're attempting to do. Viewing the resulting VBA can usually point you in the right direction.

    Good luck 

    thank you Sidewinder for the reply

    It will be helpful if you provide me the vbscript for capturing the header and footer content.

    Thank you
    Ramesh Shrestha Quote
    It will be helpful if you provide me the vbscript for capturing the header and footer content.

    I'm sure it would be.

    What have you DONE to capture the header and footer? Checking Google might have turned up this article.

    Have you played with the posted code? Most of the logic was there, a tweak here, a tweak there, and you'd have found a solution:

    Code: [Select]Set objWord = CreateObject("Word.Application")
    objWord.Visible = True

    Set objDoc = objWord.Documents.Open("c:\temp\test.doc")
    sHeader = objDoc.Sections(1).Headers(2).Range.Text
    sFooter = objDoc.Sections(1).Footers(2).Range.Text
    WScript.Echo sheader, vbCrLf, sfooter

    objWord.Quit

    Did you even try using the Word GUI? Like I mentioned, recorded macros can be somewhat dense, but with a little effort they can be very educational.

      Quote from: Sidewinder on July 21, 2008, 03:54:09 AM
    Quote
    It will be helpful if you provide me the vbscript for capturing the header and footer content.

    I'm sure it would be.

    What have you done to capture the header and footer? Checking Google might have turned up this article.

    Have you played with the posted code? Most of the logic was there, a tweak here, a tweak there, and you'd have found a solution:

    Code: [Select]Set objWord = CreateObject("Word.Application")
    objWord.Visible = True

    Set objDoc = objWord.Documents.Open("c:\temp\test.doc")
    sHeader = objDoc.Sections(1).Headers(2).Range.Text
    sFooter = objDoc.Sections(1).Footers(2).Range.Text
    WScript.Echo sheader, vbCrLf, sfooter

    objWord.Quit

    Did you even try using the Word GUI? Like I mentioned, recorded macros can be somewhat dense, but with a little effort they can be very educational.

     

    Hi Sidewinder,
    Is there a way to manipulate the Excel file through this just like word?
    Yes. Any program product that comes with a COM server can be scripted with a COM aware script language (REXX, VBScript, Python, ETC). Just about any Microsoft application from Access to the Zune can be scripted.

    Surprisingly (or maybe not), simple Microsoft APPS like notepad cannot be scripted other than sending keystrokes to the window.

    There is even a ActiveX (COM) object for Mozilla

    Much of the documentation can be found on MSDN and having a editor with intellisense can be very helpful.

    1696.

    Solve : Have to be in C:\Windows\System32 to run files in that folder?

    Answer»

    ...and I thought that SINCE that is in the System Path, I could run files in C:\Windows\System32 from anywhere?   

    More specifically - I can run any program in C:\Windows\System32 from the Windows Run box.  But if I'm in cmd.exe at some other directory - say C:\Windows - and try to run a program that is in C:\Windows\System32 (and does work in cmd.exe), it will say something of the sort "'edlin' is not recognized as an internal or external command, operale program, or batch file".  Yet, "C:\WINDOWS\system32" is in the path, and edlin.exe works when when I'm in C:\Windows\System32.

    Is it possible to get cmd.exe to run commands that aren't built-in to it from any directory, or is this not possible in cmd.exe?

    OS:  Windows XP SP2, version 5.1.2600.Check your path again. Type PATH at the prompt and post what you get.

    The normal behaviour for cmd.exe is to search for executables first in the current directory and then in each folder listed in the PATH environment variable. Is anything getting changed in autoexec.nt?

    If you type SET at the command prompt you should see a list of all the environment variables. Are these like so?

    ComSpec=C:\WINDOWS\system32\cmd.exe
    Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    windir=C:\WINDOWS

    Another possibilty is a malware infection...
    Quote from: Dias de verano on July 21, 2008, 12:23:45 AM

    Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem; <may be much more, but the first 2 in blue should be at the beginning

    That's it!     Java had pre-empted Windows at the beginning of my path, and once I moved it back in the queue and restarted, it worked just like I thought it should!  Thanks!   This happened to me, and I SUSPECT a number of other people. For some reason I'm not sure of, the java install sometimes  ADDS the Java binaries folders to the beginning of the PATH system variable, instead of appending them to the end as they should be. Furthermore it does it badly so that the PATH becomes malformed.

    As you can see, the PATH system variable is a semicolon-separated list of folder paths. For commands external to cmd.exe, the system searches each folder in the PATH system variable in turn. If the list becomes DAMAGED in some way (e.g. a missing semicolon), before it gets to "C:\WINDOWS\system32;C:\WINDOWS;"  then the system just gives up & you get the "not recognized as an internal or external command" message. That's why these folders should be at the start. That way, the system finds the commands fast, early in the search.

    An unfortunate side effect of this method hunting along the PATH variable is that by adding a folder to the beginning of the PATH you can intentionally or accidentally pre-empt an external command with another identically named .exe, since the system executes the first one that it finds.
    1697.

    Solve : Need help with a bat menu?

    Answer»

    I am new to this, and saw there are some batch menu's.

    The thing was it just had a menu and no function to it.

    I was hoping to see if someone can help me with a menu using a bat file.

    Menu
    1. Select A
    2. Select B
    3. Select C
    4. Select D
    5. EXIT

    Then after clicking an option...It would bring up ANOTHER menu on what you'd like to do to it. ie: copy, zip, delete, etc...


    Like I said, I am new to this and would appreciate anyones help.


       -Thx in advanceLike I always say:
    "USE GOOGLE BEFORE POSTING!"
    try this.

    Code: [Select]echo off
    cls
    :menu
    echo This is a Batch Menu
    echo ==============
    echo [1] Option One
    echo [2] Option Two
    echo [3] Option Three
    echo.
    set /p choice=1, 2, or 3?
    if 'choice'=='1' goto one
    if 'choice'=='2' goto two
    if 'choice'=='3' goto three
    goto menu

    :one
    <your code here>

    :two
    <your code here>

    :three
    <your code here>

    that is a simple menu but you can add on more options.thank you for the template of the menu.
    I was working off another template but was GIVING me issues.
    For some reason, I cannot get the exit command to work with this one.

    I'm still in the process of coding things, but do you know if I select an option that isn't there, it will return or make me choose a selection on the screen?

    Thank you for your help.

    This is what I have so far:


    echo off
    cls
    :menu
    echo Select Option
    echo ==============
    echo [1] July 4th Banner
    echo [2] Flash Drive Banner
    echo [3] Christmas Banner
    echo [4] New Years Banner
    echo [Q] Exit/Quite
    echo.
    set /p choice=
    echo.
    if 'choice'=='1' goto one
    if 'choice'=='2' goto two
    if 'choice'=='3' goto three
    if 'choice'=='4' goto four
    if 'choice'=='Q' goto exit
    goto menu

       :one
       echo off
       cls
       :menu
       echo Select Option For July 4th Banner
       echo ==================================
       echo [5] Copy
       echo [6] Paste
       echo [7] Zip
       echo [8] Execute batch file
       echo

    • Main Menu

       echo.
       set /p choice=
       if 'choice'=='5' goto five
       if 'choice'=='6' goto six
       if 'choice'=='7' goto seven
       if 'choice'=='8' goto eight
       if 'choice'=='0' goto zero
       echo.
       goto menu

          :five
          

          :six
          

          :seven
          

          :eight
          

          :zero
          goto menu


             :two
             echo off
             cls
             :menu
             echo Select Option For Flash Drive Banner
             echo ====================================
             echo [9] Copy
             echo [10] Paste
             echo [11] Zip
             echo [12] Execute batch file
             echo
    • Main Menu

             echo.
             set /p choice=
             if 'choice'=='9' goto nine
             if 'choice'=='10' goto ten
             if 'choice'=='11' goto eleven
             if 'choice'=='12' goto twelve
             if 'choice'=='0' goto zero
             echo.
             goto menu

                :nine
                

                :ten
                

                :eleven
                

                :twelve
                

                :zero
                goto menu


                      :three
                      echo off
                      cls
                      :menu
                      echo Select Option For Christmas Banner
                      echo ==================================
                      echo [13] Copy
                      echo [14] Paste
                      echo [15] Zip
                      echo [16] Execute batch file
                      echo
    • Main Menu

                      echo.
                      set /p choice=
                      if 'choice'=='13' goto thirteen
                      if 'choice'=='14' goto fourteen
                      if 'choice'=='15' goto fifteen
                      if 'choice'=='16' goto SIXTEEN
                      if 'choice'=='0' goto zero
                      echo.
                      goto menu

                         :thirteen
                         

                         :fourteen
                         

                         :fifteen
                         

                         :sixteen
                         

                         :zero
                         goto menu

                               :four
                               echo off
                               cls
                               :menu
                               echo Select Option For New Years Banner
                               echo ==================================
                               echo [17] Copy
                               echo [18] Paste
                               echo [19] Zip
                               echo [20] Execute batch file
                               echo
    • Main Menu

                               echo.
                               set /p choice=
                               if 'choice'=='17' goto seventeen
                               if 'choice'=='18' goto eighteen
                               if 'choice'=='19' goto nineteen
                               if 'choice'=='20' goto twenty
                               if 'choice'=='0' goto zero
                               echo.
                               goto menu

                                  :seventeen
                                  

                                  :eighteen
                                  

                                  :nineteen
                                  

                                  :twenty
                                  

                                  :zero
          goto menu

                                           :exit                        exit Quote from: ontheroad on July 31, 2008, 11:02:49 AM
    For some reason, I cannot get the exit command to work with this one.
                                           :exit                        exit

    You must not have anything else on a label line apart from the label.hmm...i tried what you wrote and it still won't exit.


    thx thowhy not do
    Code: [Select]if 'choice'=='Q' exit?
    Quote
    hmm...i tried what you wrote and it still won't exit.
    you wrote
    Code: [Select]:exit
    exitand it does not work ?

    EDIT:
    try that signs for menus
    Code: [Select]echo.ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
    echo.ş
    echo.ş
    echo.ČÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍI tried your "if choice" and it did not work for me.

    :exit
    exit

    ^that did not work for me either...

    I do not understand why.

    I do appreciate you guys trying to help...i'm just stuck try Code: [Select]if /I '%choice%' equ 'Q' exitwhat os you have ?You aren't using variables properly. Clue: what is this? %YES, that worked.

    Thank you for taking your time and assisting me.

    Greatly appreciate it. Quote from: Dias de verano on July 31, 2008, 12:14:21 PM
    You aren't using variables properly. Clue: what is this? %

    My bad  Quote from: macdad- on July 31, 2008, 03:45:55 PM
    Quote from: Dias de verano on July 31, 2008, 12:14:21 PM
    You aren't using variables properly. Clue: what is this? %

    My bad 

    I am surprised at you, macdad. With a SIG like yours as well.  ok ok. i just missed the %s and went with it. and yes i  think that its a bit to over done(my sig)
    1698.

    Solve : My C: prompt?

    Answer»

    I feel like I have alot of problems with the C: prompt in itself.  Alot of times, it won't show files that do certainly exist and I have to go through a number of steps just to get the dir / function to show that the file does exist. 

    Is there some type of program available to me to run a diagnostics test on the C: prompt alone?

    Thanks
    DianePlease define what problem you are having, it may just be a matter of syntax.

    What "steps" are they?
    This is a snippet, which is in correct Perl form

    #!\usr\bin\perl -w
    open (MYTEXT, "halloween.txt") || die "Cannot open halloween.txt: $!\n";
    print ;
    close MYTEXT;


    but when I go to run the program, the warning SYSTEM (I'm sorry for forgetting the name of the stupid thing (it's in Perl)  responds "backslash found where operator expected.  Missing operator before \?" and the operator and backslash ARE BOTH THERE AND WHERE THEY'RE SUPPOSED TO BE.  That's why I'm wondering if I have some type of problem with the C: prompt.

    Not only that, but many times I will try to open a file from a specific directory and the C: prompt responds with "the file does not exist" even though it does and I have to cd over and over again, and sometimes even have to quit the C: prompt altogether, then reopen it, to be able to locate the file that had just previously "not existed."  Those are the steps I was trying to refer to (having to close and reopen the C:prompt and/or changing the directories several times until C:prompt accepts that it exists and is in the directory.

    Other than that, I have opened the C:prompt SEVERAL times and used dir to list out the directory's files and the file that DOES EXIST in Windows will not appear in the list until I do one of those 2 options I've already described.

    Please help.
    Thanks
    Diane



    Quote from: dimilinowski on July 30, 2008, 03:20:14 AM

    I feel like I have alot of problems with the C: prompt in itself.  Alot of times, it won't show files that do certainly exist and I have to go through a number of steps just to get the dir / function to show that the file does exist. 

    Could you answer this question I asked?

    Quote from: Dias de verano
    What "steps" are they?

    Quote
    many times I will try to open a file from a specific directory and the C: prompt responds with "the file does not exist" even though it does

    Tell us precisely what you are doing.  Give the file name and the directory name and show exactly what you are entering at the COMMAND prompt.

    Hey Baby ...!!
    I have the same problem..
     It's hard to show you exactly what I'm doing because it doesn't always do it.  I just checked it again, to see if it worked or not, and it did (figures)... but, this is pretty much it...

    C:\Documents and Settings\Compaq_Owner\Perl\us.jpg and the C:prompt would respond that that file did not exist or that the path was not specified.  Right now it works.



    Otherwise, trying to change the name of the directory Documents and Settings by running the code:

    REN Documents and Settings Diane

    does not work and responds the system cannot find the file specified.



    Trying to implement a new instance of C: prompt without having to exit, I haven't been able to figure out yet, even though I've read all of the help commands available (not really the same issue, though).  I have to exit or close out of the C: prompt alot of times just to cd to another directory--it just won't do it.

    These are the first things on my list, I guess.

    Thank you
    Diane

    Quote
    REN Documents and Settings Diane does not work and responds the system cannot find the file specified.

    Yes, folder/file names which include spaces should be enclosed in "" otherwise the system will look for a one word folder name, in this case Documents.  However, the D & S folder is widely used by the system and if you manage to rename it the system will not be able to find it until you reset necessary Environment Variables, does your level of knowledge allow you to do this?

    Quote
    Trying to implement a new instance of C: prompt without having to exit, I haven't been able to figure out yet,
    While at the Command Prompt enter "Start cmd" (without the "") another Command Prompt window will open.

    Quote
    I have to exit or close out of the C: prompt alot of times just to cd to another directory--it just won't do it.
    Can't advise you on that problem until you tell us exactly what your default directory is and what you are entering at the Command Prompt and give a list of any error messages when this happens. First thing, I can't figure out how to use the freaky quote button.  Every time I highlight something then click "quote" the program quotes EVERYTHING!!!  Please help!!!

    Also, "does your level of knowledge allow you to do this?"  No, thank you for giving me a heads up.


    "Can't advise you on that problem until you tell us exactly what your default directory is and what you are entering at the Command Prompt and give a list of any error messages when this happens." 
        My default directory is C:\Documents and Settings\Compaq_Owner>
        otherwise, I will compile the list of error messages next time they occur.  Thanks.


    Is it safe to ren Compaq_Owner, then?

    Thank you
    Diane


    Quote
    First thing, I can't figure out how to use the freaky quote button.  Every time I highlight something then click "quote" the program quotes EVERYTHING!!!  Please help!!!
    Hilight what you want to quote and copy it to the clipboard (click edit>copy).  Go to the Post reply form and click on the quote BBC tag (second from right) then paste the quote between the tags (click edit>paste). 

    Quote
    Is it safe to ren Compaq_Owner, then?
    The following is quoted from this site with slight alteration:

    Quote
    When you create a user account, Windows XP creates and populates a subfolder of the C:\Documents and Settings folder WHOSE name is the account name. In your case, you'll find a folder named C:\Documents and Settings\Compaq-Owner.

    If you change the username using the User Accounts applet in Control Panel, Windows will display the changed name in some places, but it will not rename the underlying folder that contains the account's data and files (and, no, you can't rename that folder). It actually says right in the User Accounts applet: "This name will appear on the welcome screen and the start menu." What it doesn't spell out is that the (new) name will NOT be used in numerous other situations.

    If you want the computer to refer to you as Diane in all situations, you'll have to create a new user account with that name. You'll probably want to make it an Administrator account. Transfer all your files and settings to the Diane account and LOG in using that account. Use that account for a while. When you're very, very sure you've transferred everything successfully, you can consider deleting the Compaq-Owner account.

    That puts it much better than I could.  The Compaq-Owner account and folder would probably have been created during the initial Setup process.

    This is part of what I posted earlier Quote
    However, the D & S folder is widely used by the system and if you manage to rename it the system will not be able to find it

    To get to the command prompt windows are you starting Cmd.exe or Command.com?
    1699.

    Solve : SET will not work, variable keeps its old value?

    Answer»

    The script will be executed via command prompt on XP.

    The problem is the variable ORIG_FILENAME keeps its old value and won't be updated. The value should come out of a file which with be READ using the FOR command.

    This is the code:

    Code: [Select]
    echo START FINDSTR

      findstr /m "%%b" C:\Temp\gasdats\*.* > tmp_filename.txt && (

        echo "%%ORIGFILE_NAME%% (for)" %ORIG_FILENAME%

        for /f "tokens=4-13 delims=\_" %%k in (tmp_filename.txt) do SET ORIG_FILENAME=%%k_%%l_%%m_%%n_%%o__%%p_%%q_%%r_%%s

        echo "%%ORIGFILE_NAME%% (after)" %ORIG_FILENAME%
       

        echo ^<td^>%ORIG_FILENAME%^</td^> >> report_gasdats_%UNIQUE%.html
        echo ^<td^> >> report_gasdats_%UNIQUE%.html

        echo "DO SQLQUERY WITH %%ORIG_FILENAME%%" %ORIG_FILENAME%


        sqlplus -s /nolog query2.sql %ORIG_FILENAME% >> report_gasdats_%UNIQUE%.html

        echo ^</td^> >> report_gasdats_%UNIQUE%.html

      ) || (


        echo ^<td^>NEE^</td^>^<td^>-^</td^> >> report_gasdats_%UNIQUE%.html
        echo ^<td^>-^</td^>
      )

      echo EIND FINDSTR



    And in the logging where we can see the variable ORIG_FILENAME keeps its old value CATS_RECVD_2008_07_29__14_43_01_667.dat .cmpr.DA. The logging says the SET command has updated ORIG_FILENAME to CATS_RECVD_2008_07_29__15_02_26_621.dat .


    Code: [Select]
    START FINDSTR
    "%ORIGFILE_NAME% (for)" CATS_RECVD_2008_07_29__14_43_01_667.dat.cmpr.DA

    C:\Temp>set ORIG_FILENAME=CATS_RECVD_2008_07_29__15_02_26_621.dat
    "%ORIGFILE_NAME% (after)" CATS_RECVD_2008_07_29__14_43_01_667.dat.cmpr.DA
    "DO SQLQUERY WITH %ORIG_FILENAME%" CATS_RECVD_2008_07_29__14_43_01_667.dat.cmpr.DA
    EIND FINDSTR


    Can somebody help me with this?1.

    setlocal enabledelayedexpansion

    2.
    VARIABLES which are SET inside (
    parenthetical expressions
    )

    need to be shown with ! instead of % symbols

    3. Google for delayed expansion


    Thnx! That's it!

    I was using systemvars instead of local ones.

    1700.

    Solve : renaming a directory?

    Answer»

    I want to rename a directory without using Windows to do it. 
    I assume it goes like:

    ren Compaq_Owner Diane

    and that's it!  Am I right?

    THANKS alot
    DianeGo ahead and try it - works for me (XP Home)It says:

    "The system cannot find the file specified."


    Thanks
    Diane
    Are you doing this from the FOLDER above Compaq_Owner? I get the impression you may not be aware of the idea of changing directories.
    This post shows that the directory Compaq_Owner is a sub-directory of Documents and Settings so to do anything with it you have to complete the path like Documents and Settings\Compaq_Owner or, as Dias suggests change your default directory to Documents and Settings.

    My default directory is Documents and Settings with Compaq_Owner as a subdirectory. 

    Like earlier, you pointed out to me probably it's not a good idea to change the Documents and Settings directory name.  Is changing Compaq_Owner a better bet in changing?  I hate having to type so many letters in to change a directory is what the problem is. 

    Thanks
    DianeHave you tried command completion? Type cd c:\docu and then press the tab KEY. See what happens.

    Quote from: dimilinowski on July 31, 2008, 05:44:03 AM

    My default directory is Documents and Settings with Compaq_Owner as a subdirectory. 

    Like earlier, you pointed out to me probably it's not a good idea to change the Documents and Settings directory name.  Is changing Compaq_Owner a better bet in changing?  I hate having to type so many letters in to change a directory is what the problem is. 

    I've just re-read the quoted post and if your problem is typing so many letters to CD that can easily be sorted.  You could just type one letter to CD to a specific directory\subdirectory\subdirectoy\subdirectory\filename...  You could also open the Command Prompt window by using a desktop shortcut...  Interested Whoa - please back off !!!
    Assuming you are using Windows XP or Vista this is a mine field.

    Please use the DOS command SET.
    This will show a list of environmental variables.
    Included should be :-
    USERPROFILE=C:\Documents and Settings\Compaq_Owner

    I do not know how Windows does it, but when it starts and you log on, it determines your user profile, and your emails etc. are kept private in the above folder and are private from those of other user profiles.

    An awful lot of Windows hinges upon USERPROFILE.
    Change any PART of the name "C:\Documents and Settings\Compaq_Owner" and you will lose your emails etc., and you may find you have lost Windows altogether - but at least you will get experience of booting into the BIOS !!!

    Do you really have to type any letters to change directory ?  I use
    Start => Run... => Open =>
    I then type "CMD" and I get an imitation DOS / Command Shell, and automatically it shows me a DOS prompt
    C:\Documents and Settings\Dad>
    (Because my DAUGHTER owned this computer when a "Dad" profile was added for me.)
    From there I have immediate access to "My Documents" and everything beyond, without ever having to type "C:\Documents and Settings\Dad".

    An alternative to Start => Run... => Open => is a desktop shortcut, which can be aimed anywhere, including :-
    "C:\Documents and Settings\Compaq_Owner"

    Regards
    Alan