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.

551.

Solve : Help making a bat file to telnet into a server.?

Answer»

Hi I am new at this and I just want to know how to set up a .BAT file that will open a telnet session, logon with user name and password. Then at the prompt I would like to exacute the following command trackinv. this is an exe file. Once this file has run I would like to copy the saved date from the server DIRECTORY to my local pc.

Is there any WAY to do this with a bat file and could you please give me the command lines to use.
 I think Putty will do it easily.  Putty is a freeware and very powerful Telnet client.  

http://the.earth.li/~sgtatham/putty/0.56/htmldoc/Chapter3.html#S3.7

If you READ all the instructions about how to use automated logins/passwords and scripts with Putty and still need help let me know?  -  JOE

552.

Solve : DOS Batch File Parameters?

Answer»

Having TROUBLE referencing parameter values in Called Batch File: Anyone have a SOLUTION?

::Batch File 1
For %%p IN (c:\crala-data\trans*.txt) DO Call pocvrun.BAT %%p
::Called Batch File
erase f:\fmscrala\fms\home\upsidepo.txt
copy %%p f:\fmscrala\fms\home\upsidepo.txt

DOS throws error - does not recognize %%p in 2nd file
You may have to use a subroutine to set an environmental variable to the value p, then call the second BAT file. Your command shell version may not pass dynamic variables between shells, but the ENVIRONMENT is spawned to daughter shells. Or you could call the variable as %1 instead of %%p in the second file, as it has been entered as the first parameter of the file command.

553.

Solve : managing files run on computer?

Answer»

managing files that runs on my computer.
How can I MANAGE which PROGRAM or services runs on my computer? I know there is a dos command that let you control of this issue.if anybody KNOWS what that command is please let me know.If you are RUNNING this in XP, you use MSCONFIG and SERVICES.MSC from the RUN dialogue, not DOS, to manage services and residents.Thank you so much
this is exactly what I was looking for.

554.

Solve : How to insert programer's notes in dos?

Answer»

Can someone tell me how to place PROGRAM NOTES into my .bat file?  As in text that's there so that people can get an explination, but won't run.Hi!

By USING the REM command:

REM comment

That's It!

555.

Solve : Floppy Space?

Answer»

okay. i formatted the floppy disk into a boot diskette and i ATTEMPTED to move AMIFLASH and the *.rom into it so i could update my bios.  but, now here is where the problem comes in.  the floppy does not have enough space! what should i do?

- RyanAdditional Info:

OS- WINXPPROSP2
Floppy- 1.44MB
Bleh Blah Blah...
Burn it on to cd/rw r disk..why are you updating the bios.. what instructions where given to you by the motherboard MAKERS..Create SIMPLE boot disk.  You need a DOS boot disk and nothing more.  Flash FILES are not that BIG and will fit if you create the proper boot disk.You could go somewhere like www.bootdisks.com and get a Win98SE-based boot floppy image that should work for this.

556.

Solve : How to compare two....?

Answer»

I'm TRYING to compare two check files I made in my batch FILE for differences, and then output the results to a file. Also I need to specify that line numbers are used in the COMPARISON. Any info is appreciated  this maybe WORTH a visit>http://www.robvanderwoude.com/index.html

557.

Solve : Sum of all the numbers in a file using Batch?

Answer»

Hello all,

I am a newbie to the batch scripting and I need some suggestions to get my batch file code as minimum as possible.

I have a text file names "runs.log" which contains some numbers, like this:

0
12
634
194
1781
63


What I need is the batch SCRIPT will open the file and summarize all the numbers and give me the result.

I am trying to use the FOLLOWING code, but its not working


for /F %%a in (runs.log) do (
   set /P MR=   set /a DAILY=%%a+%MR%\
   echo %DAILY%>MONTHLY_RUN.tmp
)

Thanks to any kind of helpThere are a few things I can see here. First, your code seems to be doing more than just giving you the result, which BEGS the question "Are you gathering a daily runs.log and adding it to a monthly rather than just gathering a daily total?" To do what you originally asked for which is to summarize what is in the runs.log file. try this:

Code: [Select]for /f %%a in (runs.log) do (set /a total+=%%a)
That will give you a total of your runs.log, which, if that is your daily total, can then be added to your monthly total and the log. I'm curious as to how this all interplays with eachother. To me it seems the runs.log keeps some sort of running tally of instances, and then you are trying to add the daily total to your monthly total and keep a log of how things are progressing. If that is in fact the case, try this:

Code: [Select]echo off
for /f %%A in (MONTHLY_RUN.log) do (set MR=%%A)
for /f %%B in (runs.log) do (set /a total+=%%B)
set /a DAILY=%MR%+%total%
echo %DAILY%>>MONTHLY_RUN.log

This grabs the PREVIOUS total from MONTHLY_RUN.log, adds the total from runs.log, and puts a new line with the new total back into MONTHLY_RUN.log. If that isn't what you are trying to do, then disregard. Thank you very much  Raven19528
it really works.. you saved my day

558.

Solve : Trouble setting BATCH default...?

Answer»

So, I accidentally set the batch files to open with Notepad++ by default. I NEED them to open regularly, and I CANNOT FIGURE out how to reset it without resetting all defaults. I need everything to stay the same on my computer as-is, except I need the batch files to open regularly. Please help!Open the cmd prompt, and try ENTERING the following:

Code: [Select]ftype batfile
When I enter it on my system (Win7 32-bit) I GET the following:

Code: [Select]batfile="%1" %*
If yours is different, try typing typing out:

Code: [Select]ftype batfile="%1" %*
And see if your bat files WORK then.Thanks, but I just restored my system to 3 hours earlier, right before I accidentally changed the default. Thanks for reading and helping!

559.

Solve : Reinstalling Windows Me from Disc in DOS Mode?

Answer»

I am TRYING to RESTORE a computer as it was new.  I have run the restore disc and I have received the following message:
Drive M:= Driver IDECD000 UNIT 0
WMM32.VXD is required to run windows.

If this file is not in your PATH, you may need to reinstall Windows.

C:\>

I have download Windows Me (InstMsia.exe).

What COMMAND do I need to type to reinstall Windows ME.i would reboot the pc....and hit the del /crtl key on boot bios ....and alter the boot sequence to set up defaults save and exit...so it BOOTS form the recovery disk...which will format your drive...are you in msdos or windows at the moment...the command from msdos to boot is x:\setup whatever your cdrom drive letter is..

560.

Solve : mac address????

Answer»

I was just wondering if it is possible for me to change the Mac address of my COMPUTER.  http://students.washington.edu/natetrue/macshift/ or this>http://www.soft32.com/download_64505.htmlyo a MILLION thanks, you help me in a tremendous WAY. as I know it is imposible

561.

Solve : Avoid Abort, Retry, Fail on CD "if exist&quot?

Answer»

I want to test if a file exists (by using "IF EXIST" or some other alternate) on a data CD without geting the "Abort, Retry, Fail" message in case I forgot to insert a CD into the CD-drive. Is there a way to do this?

I guess what I'm really asking "Is there a way to test if a CD has been inserted into a CD-drive?".I don't think so, unless there is a command.com switch that can be set to run in silient mode..   a disk error is a major show stopper for any os.  You may be able to find an external utility that you could call that would finger the drive by going around the os and leaving a error code that you could process with your batch.Thanks. I was affraid there was no easy solution.I happened to come across a guy whos got tons of dos utilities.. maybe you can find what you need there.
http://www.opus.co.tt/dave/indexall.htmHere's more:  http://www.oldfiles.org.uk/powerload/index.htm
From scruge: This is a great site: for dos utilities and other info. http://www.opus.co.tt/dave/indexall.htm

There are lots of neat things. To answer my current issue, your suggestion had a link to http://home7.inet.tele.dk/batfiles/
And there under FAQ1 link I found to batch files that check for valid drives (item 43 and 44) that I was able to tweak to meet my needs. The key was the use of ctty nul|con , command.com using the "/f" option piped to find and choice.

Thanks to all who offered suggestions.

I have revisited this issue. Read on for a solution:

After using the suggestions (and web sites listed) in this forum, I have attached a simple batch file (ifExist.bat) that safely test for the existance of any file (with or without a full PATH), drive, or folder. Here is an example of how to "call" the batch file from within another batch file:

...
call IfExist myfile rc
if %rc% == 0 echo File 'myfile' FOUND
if not %rc% == 0 echo File 'myfile' NOT FOUND
...


------------------------------ BATCH FILE ----------------------------------
:: IfExist.bat
::
:: PURPOSE: Equivalent to the DOS 'IF EXIST ...command.
::  Runs on Windows 98SE and XP.
::
::  IfExist.bat safely tests for the existance of any file (or drive)
::  on any device (Floppy, HD, CD, DVD, ...) without fear of getting
::  the dreaded DOS  'Abort, Retry, Fail?' error message. This
::  error message can occur in DOS if the device (e.g., Floppy)
::  is not present.
::
:: SYNTAX:    IfExist [drive][folder][file] var
::          drive   - drive (e.g., a:, b:, ..., Y:, Z:)
::          folder  - folder
::          file       - file name
::          var      - name of environmental variable to
::                  hold the return code (e.g., rc)
::
:: On return, IfExist.bat SETS the return code (var) to:
::  0 - if 'exist'
::  1 - if 'non-exist'
::
:: LAST MODIFIED: 11/3/04

echo off

if %2x == X goto err1

::Init return code to 'non-exist'
set %2=1

::Use ctty nul (disconnect from the standard output). This
:: has the effect of hidding error messages in DOS.
:: %OS% is null for DOS not null for XP (not perfect).
:: ( XP does not support ctty; fortuneatelyt XP doesn't produce
::  the error messages we want to hide)
if %OS%x == x ctty nul

:: Use COMSPEC and DIR to find this file.
::
::Use command.com with the un-publish /f option to force
:: selecting "fail" if an abort-retry-fail error occurs.
%COMSPEC% /F/C DIR %1 | find /i "file(s)" > nul
if not errorlevel 1 if errorlevel 0 set %2=0

::Use ctty con to unhide error messages in DOS.
if %OS%x == x ctty con

goto END

:err1
echo.
echo   ---- SYNTAX: %0 [drive][folder][file] var
echo   --- ENTERED: %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
echo         ERROR: Missing var (name of environmental variable to
echo                hold the return code (e.g., rc). Return codes of
echo                0 or 1 means 'exist' or 'non exist', respectively.
echo      EXAMPLES: %0 f1 rc
echo                %0 K: answer
echo                %0 \bin answer
goto END

:END

Dear Sir,
I would like to setup win XP using a batch file that contians the serial No. of the setup and regional settings of Egypt . It is easy to do that for Win Me & Win 98.
Regards,
M.ShakerDear Sir,
I would like to setup win XP using a batch file that contians the serial No. of the setup and regional settings of Egypt . It is easy to do that for Win Me & Win 98.
Regards,
M.ShakerI do not have the answer to your question.

To get maximum exposure, you may want to open a separate question rather than include your issue as part of this thread.

GeorgeMr. M.Shaker

I do not have the answer to your question.

To get maximum exposure, you may want to open a separate question rather than include your issue as part of this thread.

GeorgeI have the same problem.

I found this,
http://www.robvanderwoude.com/files/driverdydos.txt

But I get an error message.

Anyone see a problem with this?
C:\COMMAND.COM /F /C DIR R: 1> NUL 2> C:\CDROM.TXT

It says TOO MANY PARAMETRES -1

It checks to see if there is a CDROM in the R: drive, if there isn't it will create a file CALLED CDROM.TXT on the C: drive.No matter if there is a CD rom in the drive or not...it still makes the CDROM.TXT file.

Something must be wrong...anyone see it?

562.

Solve : Embedded File Emergency!?

Answer»

[glb][/glb]
I am TRYING to 'embed' a text file with several LINES in a DOS batch file so that it can 'extract' it.
I've tried
[glb]ECHO This is a test>C:\TEXT.TXT[/glb][glb]ECHO Things and Stuff>C:\TEXT.TXT[/glb]
And when I open the [glb]C:\TEXT.TXT[/glb] file, it contains this:
[glb]Things and Stuff[/glb]
Can you help me figure out how I can get the file to read this?:
[glb]This is a test[/glb][glb]Things and Stuff[/glb]Not sure if this is what you want or if it will work but try

ECHO This is a test >C:\TEXT.TXT
ECHO Things and Stuff >>C:\TEXT.TXT

(Note the two >> on the second line)

GOOD luck

Quote

Not sure if this is what you want or if it will work but try

ECHO This is a test >C:\TEXT.TXT
ECHO Things and Stuff >>C:\TEXT.TXT

(Note the two >> on the second line)

Good luck



Thank you very much. I knew there would be a way for entering multiple lines of text!

[glb]MAY GOD BLESS YOU VERY MUCH![/glb]
563.

Solve : Trying to launch a file through .cmd on remote PC?

Answer»

echo off
cls
echo Add Printer \\%2\%3 on %1
echo _______________________________________ _____
echo.

if {%1}=={} GOTO HowTo
if {%2}=={} goto HowTo

CALL
>>\\%1\c$\temp\printer.vbs ECHO '-------------------------------------------
>>\\%1\c$\temp\printer.vbs ECHO ' Printer Install for network printer:
>>\\%1\c$\temp\printer.vbs ECHO ' %2
>>\\%1\c$\temp\printer.vbs ECHO '-------------------------------------------
>>\\%1\c$\temp\printer.vbs ECHO Dim net
>>\\%1\c$\temp\printer.vbs ECHO Set net = CreateObject("WScript.Network")
>>\\%1\c$\temp\printer.vbs ECHO net.AddWindowsPrinterConnection "%2"
>>\\%1\c$\temp\printer.vbs ECHO '-------------------------------------------


psexec -i -d -s \\%1 printer.vbs


echo Printer %2 has been successfully added on %1.

Goto End

:HowTo
echo Adds a printer on the target workstation
echo.
echo Usage: Printer [COMPUTERNAME] [\\Server\Printer]
echo.

:End
pauseI am trying to launch a file that is created with my .CMD file but pcexec says it cannot find the specified file:-
I need this file to open on the remote system and not on mine.

Here is the code for my .cmd file:-
------------------------------------------------------------------------

Can ANYBODY TELL me how to launch the printer.vbs file so that it opens on a remote workstation and not on mine???

Info>http://web.mit.edu/pismere/admin/nt4remot.htm

564.

Solve : Running exe without prompts?

Answer»

Hi There

If i want to use a batch file to run a piece of software, i NEED to press "Install" during the installation process. What is the switch i use (or how do i do it) so that the software installs AUTOMATICALLY RATHER than prompting for you to press install. {I have so far got the batch file to call the software.exe and it comes up and says press install (the default selection) to complete}

Many Thanks

RupertIf the piece of software you are trying to run is a dos exe, you will need to do some research on it. If it is a Win32 exe, use a program like Resource Hacker to get rid of the prompt dialog(if present).

You can get Resource Hacker from http://www.users.on.net/johnson/resourcehacker/

565.

Solve : How do I create a batch file??

Answer»

How do I create a batch file that dose the following
-Switch current directory to A:\U
   use the cd command. Make sure to note the file structure on that drive is.
-Display directory contents.
   Use the DIR command
-Switch back to root directory
   Use CD command with the appropriate parametersWe do not do homework.
The commands are basically the same as you would type by hand.
Use Notepad to write the file, but save it with the extension BAT and exit Notepad.
Wondering if it is okay to "hijack" this thread in order to explain some of the differences there are in batch as opposed to entering the commands in manually? If that's not okay, please let me know and/or delete this post.

Some differences between batch files and entering commands manually include the utilization of double percents in the FOR command. I.e.
FOR /F "delims=" %A in (myfile.txt) do set unit=%A in command prompt or DOS would change to
FOR /F "delims=" %%A in (myfile.txt) do set unit=%%A in batch.

That's the only one I can come up with now at this hour, but maybe some others have some more differences between command prompt/DOS and batch. Note thought that DOS and command prompt are very different, where DOS is an actual operating system and command prompt is more of a kernel within an operating system (that terminology may not be right.)I know that DOS as well as Batch Language has changed since I first started learning Dos about 30 years ago, but even then there were commands for batch files outside of DOS.

I'm in a small paradox right now, that a batch file which works fine when run within Windows, but when run from a DOS boot disk, it crashes.  Just another oddity of the venerable Batch File.

So, just about the time you think you have DOS and batch files all figured out, Voila, it deals you aces and eights.

I wish I totally understood that reference to the For command in a previous post.  But alas, I don't.
Too bad too, because that's the line that crashes.

  QUOTE from: TheShadow on October 12, 2011, 06:21:01 PM

Just another oddity of the venerable Batch File

It's not an "another oddity", it's just that you don't understand why it happens.
If you work as a system administrator, understanding batch is very important. Otherwise,  hobbyists should consider learning more about other FORMS of windows scripting options.  VbSscript or PowerShell are two. Meanwhile, Salmon Trout is the resident expert on batch. What he says is just the way it is.

Question: Are there really educators out there promoting the study of batch as a introductory programming language?
Quote from: Geek-9pm on October 15, 2011, 11:20:11 AM
Salmon Trout is the resident expert on batch. What he says is just the way it is.

... I wish!
Quote from: Salmon Trout on October 15, 2011, 11:22:03 AM
... I wish!

Modest as you are...i'd say your one of the best ones...The paradox is I have mostly moved on to other scripting tools for my everyday tasks - Powershell mainly.
The thing is, programming is quite simply just translating. Knowing the batch language, or any programming language for that matter, is not something that is easily forgotton. So even though you have moved on to bigger and better languages (which is pretty much any other programming language) your expertise in batch is still APPRECIATED and needed for those who are learning the language, or learning to program. Thank you.

To the OP:
Why wouldn't you just do a dir a:\u and save yourself the directory changing trouble? Quote from: Raven19528 on October 15, 2011, 02:00:16 PM
Why wouldn't you just do a dir a:\u and save yourself the directory changing trouble?

Study the wording. The question is clearly a school assignment.
So far, the only place where teaching DOS in a Computer Class -
has been is the article:
Quote
Computer Education in Nigerian Secondary Schools
But I will keep looking, Somewhere there is a teacher telling students to learn batch programming. He must be told he has given the children a handicap.

They use batch and QBasic in lots of countries. India notably.
Quote from: Salmon Trout on October 15, 2011, 02:50:18 PM
They use batch and QBasic in lots of countries. India notably.
Thanks for mentioning that. So do I. But if I say her  that they laugh at me. BTW, one of the best books on QB in found in a used book pile in La Paz, Bolivia from a street vendor. And it was in Spanish, of course.

I recently had a small problem where I used Qbasic and Batch to rename some files for me.  All files in a directory  with _+_ near the start of the name would be truncated to remove that part. So I wrote a little code using INSTR and RIGHT$ to chop the names and wrote it out as a batch file to do a bulk rename. Not elegant, but quick. And Qbasic has a debug feature and lets you know if the syntax is wrong. But keep it a secret.
Do you use QB64?
Quote from: Geek-9pm on October 15, 2011, 04:22:30 PM
Do you use QB64?

No. I downloaded it out of curiosity, but I found the user interface a nightmare of retro ugliness. I seem to remember it CRASHED. If I want to do anything in that line of country, I'll use FreeBasic.

566.

Solve : Explanation of advanced command?

Answer»

I've been reading old threads to figure out how to do something. Whilst there I came across an answer I don't fully understand and would love to know the full explanation.

The problem I was reading was for  replacing file paths (e.g. C:\filename or D:\filename) with \\Server\filename in text file fulllist.txt.
Salmon trout came up with this code:
Code: [Select]for /f "delims=" %%A in (fulllist.txt) do echo \\Server\%%~pnxA
It is the final %%~pnxA which I'm perplexed on. I'm guessing the surrounding "%%" and "A" is the variable %%A, as previously used.
i) Is the tilde for removing surrounding double quotes (I can't see any) or soemthing to do with the PATH name?
ii) What are the pnx parameters? I have no idea on these.
 
Thanks in advance for enlightening me!

BTW, the original thread was called "Replace the particular string using Dos batch program", started 24th October 2010 by csselva.The below explanation is straight from the FOR /? command:

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:

    %~I         - expands %I removing any surrounding quotes (")
    %~FI        - expands %I to a fully qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file
    %~$PATH:I   - searches the directories listed in the PATH
                   environment variable and expands %I to the
                   fully qualified name of the first one found.
                   If the environment variable name is not
                   defined or the file is not found by the
                   search, then this modifier expands to the
                   empty string

The modifiers can be COMBINED to get compound results:

    %~dpI       - expands %I to a drive letter and path only
    %~nxI       - expands %I to a file name and extension only
    %~fsI       - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
                   environment variable for %I and expands to the
                   drive letter and path of the first one found.
    %~ftzaI     - expands %I to a DIR like output line

In the above examples %I and PATH can be REPLACED by other valid
values.  The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.

Hopefully that helps explain both questions. Please let us know if not.Thanks.   Thought I'd see them before in the past but having one of those brain block moments!!

567.

Solve : Comparing content of a variable with string literal?

Answer»

I need to do an If statement based on a variable being EQUAL to a string literal.

Here's my code:

SET MYNAME=%USERPROFILE%

IF %USERPROFILE%=="c:\documents and settings\XJHS037" (GOTO YES) ELSE (GOTO NO)
...

I'm sure the answer is simple but I can't get it to work.  Can someone help?

Thanks

JeffIt is simple, like you thought. You need to remember to have quotes around the userprofile variable.

if "%userprofile%"=="c:\documents and settings\XJHS037"

One thing I am noticing, it looks like you are running on an XP machine. I didn't think that cmd prompt had the %userprofile% variable until Vista. I could be wrong though. Try doing an echo %userprofile% and see what you get.AWESOME!  It worked!  Thanks very much Raven.  Yes I do have an XP but the userprofile variable does work.  I'm very much a beginner and my FULL code was simple:

echo off

ECHO.
ECHO.
ECHO.

SET MYNAME=%USERPROFILE%

if /I "%USERPROFILE%"=="C:\documents and settings\XJHS037" (GOTO YES) ELSE (GOTO NO)

:YES
ECHO %MYNAME%
ECHO WAHOO!
GOTO END

:NO
ECHO %MYNAME%
ECHO AWSHUCKS
GOTO END

:END
ECHO.
ECHO.
ECHO.

PAUSE


When I run the batch I do get "C:\documents and settings\XJHS037" from the echo

Thanks againA couple of points...

1. Some people think it is a good idea to get in the habit of always quoting variables in IF tests, because if one of the variables is empty (for example if the user just pressed ENTER in reponse to the SET /P in the following script) then without any quotes the script will crash with an error.

If you just press ENTER at the set /p prompt in this script it will crash with "echo was unexpected at this time." It won't get to the "echo finished" line.

Code: [Select]echo off
set var1=cat
set var2=
set /p var2="Think of an animal: "
if %var2%==%var1% echo Correct!
echo finished

This one won't crash.

Code: [Select]echo off
set var1=cat
set var2=
set /p var2="Think of an animal: "
if "%var2%"=="%var1%" echo Correct!
echo finished

2. They don't have to be quotes. They can be any characters that don't have a special meaning in batch, as long as they are the same both sides

e.g.

if (%var2%)==(%var1%) echo Correct!
if [%var2%]==[%var1%] echo Correct!
if {%var2%}=={%var1%} echo Correct!
if ABC%var2%def==abc%var1%def echo Correct!



Quote from: Raven19528 on October 18, 2011, 12:41:10 PM

I didn't think that cmd prompt had the %userprofile% variable until Vista.
%userprofile% was introduced in NT4.Thanks again to both of you!  Trout - your suggestion makes sense and I've amended my script.  GREAT Stuff!
568.

Solve : Help with renaming?

Answer»

Hi. I've RECENTLY experimented with multiple ways of renaming image files using the REN command, but I can't seem to get the result I want. For example, I have abc01.jpg abc02.jpg and abc03.jpg, and I want to erase all the "abc" from each image, leaving me with 01.jpg 02.jpg and 03.jpg. I tried using wildcards * but it only gives me 0bc01.jpg 0bc02.jpg and 0bc03.jpg. Can anyone help?I see "David Murphy" is viewing this.... watch out for trolls!

Use a free utility such as Bulk Rename Utility from http://www.bulkrenameutility.co.uk/Download.php It is available in 32 bit (BRC32.exe) and 64 bit (BRC64.exe) versions.

Then you would just type BRC64 /pattern:abc*.jpg /removefirstn:3 /EXECUTE

Honestly, it's not worth anybody bashing out a script just for a one-off task like that, it just leads to troll activity, that is if you aren't David Murphy yourself anyway.

What code do you have so far? Also, is the "abc" you are trying to remove all standard length? I.e. Are all the file names Pic01.jpg, Pic02.jpg etc., or are they different but with the numbers at the end (Picnic01.jpg, Water02.jpg etc.?) Lastly, do you want the renaming to be fully automated, or would you like to have a little more control over the process while it is happening? Quote from: Salmon Trout on October 16, 2011, 09:02:34 AM

Honestly, it's not worth anybody bashing out a script just for a one-off task like that, it just leads to troll activity, that is if you aren't David Murphy yourself anyway.

Darn, I already had. Well, not really for this particularly, but a renaming script that allows the user to bulk rename files either with sequential numbering scheme or with standard naming scheme and ability to edit the "non-standard" part of the name. But that's because I have way too much time on my hands and programming is a relaxing activity to me. (And I think I need to see somebody about that.) Quote from: Raven19528 on October 16, 2011, 02:05:02 PM
Darn, I already had. Well, not really for this particularly, but a renaming script that allows the user to bulk rename files either with sequential numbering scheme or with standard naming scheme and ability to edit the "non-standard" part of the name. But that's because I have way too much time on my hands and programming is a relaxing activity to me. (And I think I need to see somebody about that.)

Go on, post it, it would be interesting. I was going to myself but I saw at the top of the page a hint that that a certain banned troll had possibly signed up under a new name and was viewing the topic. He has a habit of creating multiple user accounts and using one to ask a question and another to "answer" it, often hilariously badly. So some real scripts would be very helpful.


I haven't gone back to this code to consolidate and streamline it at all, but it does allow for a lot of flexibility with the renaming scheme.

Code: [Select]echo off
setlocal enabledelayedexpansion
title Renamer v1.1
mode con: cols=61 lines=15
set origdir=%~dp0
set numnam=0

call :targets
cls
call :startstring
cls
call :endstring
cls

:renaming
for /f "delims=" %%F in ('dir /s /b %tarstr%') do (
  cls
  set OldFilePathAndName=%%~dpnxF
  set OldName=%%~nF
  set OldFilePath=%%~pF
  set Extension=%%~xF
  set FileDate=%%~tF
  call :SetOldFilePath
  cls
  echo !OldName!!Extension! in !OldFilePath! folder
  echo.
  set /p Continue=Edit this filename {y,n}
  if /i "!Continue!"=="y" (
    call :EditNameSubroutine
  )
)

cls
echo You changed the name of !numnam! files
echo You can view the names that were changed
echo in the Renamelog.txt file located at
echo %origdir%
echo.
echo Thank you for using Renamer v1.1
echo.
ping 1.1.1.1 -n 1 -W 10000>nul
goto eof


:targets
:loop
cls
echo Is the directory path in the targetdirectory.txt file?
set /p yn1={y,n}
cls

if /i "%yn1%"=="y" (
  set /p tardir=<targetdirectory.txt
) else (
  echo Type full path of target directory
  set /p tardir=
)
if exist %tardir% (
  cd %tardir%
) else (
  echo Target does not exist
  echo PLEASE try again
  ping 1.1.1.1 -n:1 -w:3000>nul
  goto loop
)

echo Is there a target string you want to enter?
set /p yn2={y,n}
if /i "%yn2%"=="y" (
  echo.
  echo Type target string for renaming
  set /p tarstr=[Target]
  set tarstr="*!tarstr!*"
  cls
  goto addtarstrques
) else (
  set tarstr=*
  goto eof
)

:addstring
cls
set /p addstr=[Target]
set addstr="*%addstr%*"
set tarstr=%addstr% %tarstr%
echo Searching for strings: %tarstr%
:addtarstrques
echo.
echo Is there an additional string you wish to look for?
set /p yn3={y,n}
if /i "%yn3%"=="y" goto addstring
goto eof


:startstring
:startloop
cls
echo Is there a standard starting string
echo to the naming convention?
set /p yn4={y,n}
if /i "%yn4%"=="y" (
  cls
  echo Enter standard start string 
  echo [Include an ending space if desired]
  echo.
  set /p startstr=
) else (
  set startstr=
  goto eof
)
echo The current start string is "%startstr%"
echo Is this okay?
set /p yn5={y,n}
if /i "%yn5%"=="n" (
  set startstr=
  goto startloop
)
goto eof


:endstring
cls
echo Is there a standard ending string to the naming convention?
set /p yn5={y,n}
if /i "%yn5%"=="n" (
  set endstr=
  goto eof 
)
cls
echo Would you like the end string to
echo include the date the file was created
set /p DateEnd=[y,n]
cls
if /i "%DateEnd%"=="y" call :DateEndFormatting
cls
echo Would you like the end string to include
echo today's date
set /p yn6={y,n}
cls
echo Enter standard end string
echo [Include spaces if desired]
set /p origendstr=
if /i "%yn6%"=="y" call :DateTodayFormatting
if "%DateEnd%"=="y" set origendstr=%origendstr%[date created]
echo The current end string is "%origendstr%"
echo Is this okay?
set /p yn7={y,n}
if /i "%yn7%"=="n" (
  set origendstr=
  goto endstring
)
if /i "%DateEnd%"=="y" set origendstr=%origendstr:~0,-14%
goto eof


:DateEndFormatting
echo In what format would you like the
echo date to appear:
echo.
echo 1. dd Mmm yy
echo.
echo 2. yyyymmdd
echo.
echo 3. Mmm dd, yyyy
echo.
echo 4. mm/dd/yy
echo.
echo 5. More...
echo.
set /p DateEndForm=Selection {1-5}-
if "%DateEndForm%"=="5" goto more
goto dateendskip
:more
cls
echo 6. dd Mmm yyyy
echo.
echo 7. yy/mm/dd
echo.
echo 8. mm/dd/yyyy
echo.
echo 9. yymmdd
echo.
set /p DateEndForm=Selection {6-9}-
:dateendskip
goto eof


:DateTodayFormatting
echo In what format would you like the
echo date to appear:
echo.
echo 1. dd Mmm yy
echo.
echo 2. yyyymmdd
echo.
echo 3. Mmm dd, yyyy
echo.
echo 4. mm/dd/yy
echo.
echo 5. More...
echo.
set /p DateTodayForm=Selection {1-5}-
if "%DateTodayForm%"=="5" goto more
goto settodayform
:more
cls
echo 6. dd Mmm yyyy
echo.
echo 7. yy/mm/dd
echo.
echo 8. mm/dd/yyyy
echo.
echo 9. yymmdd
echo.
set /p DateTodayForm=Selection {6-9}-
:settodayform
if "%date:~4,2%"=="01" set todaymonth=Jan
if "%date:~4,2%"=="02" set todaymonth=Feb
if "%date:~4,2%"=="03" set todaymonth=Mar
if "%date:~4,2%"=="04" set todaymonth=Apr
if "%date:~4,2%"=="05" set todaymonth=May
if "%date:~4,2%"=="06" set todaymonth=Jun
if "%date:~4,2%"=="07" set todaymonth=Jul
if "%date:~4,2%"=="08" set todaymonth=Aug
if "%date:~4,2%"=="09" set todaymonth=Sep
if "%date:~4,2%"=="10" set todaymonth=Oct
if "%date:~4,2%"=="11" set todaymonth=Nov
if "%date:~4,2%"=="12" set todaymonth=Dec
if "%DateTodayForm%"=="1" set origendstr=%origendstr%%date:~7,2% %todaymonth% %date:~12%
if "%DateTodayForm%"=="2" set origendstr=%origendstr%%date:~10%%date:~4,2%%date:~7,2%
if "%DateTodayForm%"=="3" set origendstr=%origendstr%%todaymonth% %date:~7,2%, %date:~10%
if "%DateTodayForm%"=="4" set origendstr=%origendstr%%date:~4,6%%date:~12%
if "%DateTodayForm%"=="6" set origendstr=%origendstr%%date:~7,2% %todaymonth% %date:~10%
if "%DateTodayForm%"=="7" set origendstr=%origendstr%%date:~12%/%date:~4,5%
if "%DateTodayForm%"=="8" set origendstr=%origendstr%%date:~4%
if "%DateTodayForm%"=="9" set origendstr=%origendstr%%date:~12,2%%date:~4,2%%date:~7,2%
goto eof


:DateEndSet
if "!FileDate:~0,2!"=="01" set month=Jan
if "!FileDate:~0,2!"=="02" set month=Feb
if "!FileDate:~0,2!"=="03" set month=Mar
if "!FileDate:~0,2!"=="04" set month=Apr
if "!FileDate:~0,2!"=="05" set month=May
if "!FileDate:~0,2!"=="06" set month=Jun
if "!FileDate:~0,2!"=="07" set month=Jul
if "!FileDate:~0,2!"=="08" set month=Aug
if "!FileDate:~0,2!"=="09" set month=Sep
if "!FileDate:~0,2!"=="10" set month=Oct
if "!FileDate:~0,2!"=="11" set month=Nov
if "!FileDate:~0,2!"=="12" set month=Dec
if "%DateEndForm%"=="1" set endstr=%origendstr%!FileDate:~3,2! !month! !FileDate:~8,2!
if "%DateEndForm%"=="2" set endstr=%origendstr%!FileDate:~6,4!!FileDate:~0,2!!FileDate:~3,2!
if "%DateEndForm%"=="3" set endstr=%origendstr%!month! !FileDate:~3,2!, !FileDate:~6,2!
if "%DateEndForm%"=="4" set endstr=%origendstr%!FileDate:~0,6!!FileDate:~8,2!
if "%DateEndForm%"=="6" set endstr=%origendstr%!FileDate:~3,2! !month! !FileDate:~6,2!
if "%DateEndForm%"=="7" set endstr=%origendstr%!FileDate:~8,2!!FileDate:~0,5!
if "%DateEndForm%"=="8" set endstr=%origendstr%!FileDate:~0,10!
if "%DateEndForm%"=="9" set endstr=%origendstr%!FileDate:~8,2!!FileDate:~0,2!!FileDate:~3,2!
goto eof


:SetOldFilePath
set OldFilePath=!OldFilePath:~-25,-1!
:filepathloop
echo !OldFilePath! | find "\" >nul
if errorlevel 1 goto eof
set OldFilePath=!OldFilePath:~1!
goto filepathloop


:setcaps
set NewName=!NewName:A=a!
set NewName=!NewName:B=b!
set NewName=!NewName:C=c!
set NewName=!NewName:D=d!
set NewName=!NewName:E=e!
set NewName=!NewName:F=f!
set NewName=!NewName:G=g!
set NewName=!NewName:H=h!
set NewName=!NewName:I=i!
set NewName=!NewName:J=j!
set NewName=!NewName:K=k!
set NewName=!NewName:L=l!
set NewName=!NewName:M=m!
set NewName=!NewName:N=n!
set NewName=!NewName:O=o!
set NewName=!NewName:P=p!
set NewName=!NewName:Q=q!
set NewName=!NewName:R=r!
set NewName=!NewName:S=s!
set NewName=!NewName:T=t!
set NewName=!NewName:U=u!
set NewName=!NewName:V=v!
set NewName=!NewName:W=w!
set NewName=!NewName:X=x!
set NewName=!NewName:Y=y!
set NewName=!NewName:Z=z!
:caps
cls
echo !NewName!
echo.
set /p caps=How many capital letters?
if "!caps!"=="0" goto eof
for /l %%i in (1,1,!caps!) do (
  cls
  echo Capital LETTER %%i
  echo !NewName!
  echo 012345678911111111112222222222333333333344444444445555555555
  echo           01234567890123456789012345678901234567890123456789
  set /p capoff=At Position-
  set /a endcap=!capoff!+1
  call set before=%%NewName:~0,!capoff!%%
  call set capletter=%%NewName:~!capoff!,1%%
  call set after=%%NewName:~!endcap!%%

  set capletter=!capletter:a=A!
  set capletter=!capletter:b=B!
  set capletter=!capletter:c=C!
  set capletter=!capletter:d=D!
  set capletter=!capletter:e=E!
  set capletter=!capletter:f=F!
  set capletter=!capletter:g=G!
  set capletter=!capletter:h=H!
  set capletter=!capletter:i=I!
  set capletter=!capletter:j=J!
  set capletter=!capletter:k=K!
  set capletter=!capletter:l=L!
  set capletter=!capletter:m=M!
  set capletter=!capletter:n=N!
  set capletter=!capletter:o=O!
  set capletter=!capletter:p=P!
  set capletter=!capletter:q=Q!
  set capletter=!capletter:r=R!
  set capletter=!capletter:s=S!
  set capletter=!capletter:t=T!
  set capletter=!capletter:u=U!
  set capletter=!capletter:v=V!
  set capletter=!capletter:w=W!
  set capletter=!capletter:x=X!
  set capletter=!capletter:y=Y!
  set capletter=!capletter:z=Z!

  set NewName=!before!!capletter!!after!
)
cls
echo !NewName!
echo.
echo Are there any additional caps needed?
set /p yn14={y,n}
if /i "%yn14%"=="y" goto caps
goto eof


:EditNameSubroutine
:editname
cls
echo !OldName!
echo 012345678911111111112222222222333333333344444444445555555555
echo           01234567890123456789012345678901234567890123456789
echo.
set /p NameStart=Enter Start Position-
set /p NameEnd=Enter End Position-
set /a NameLength=1+!NameEnd!-!NameStart!

if /i "%DateEnd%"=="y" call :DateEndSet else set endstr=%origendstr%

call set NewName=%%OldName:~!NameStart!,!NameLength!%%

cls
echo !NewName!
echo Would you like to make changes to this part
echo {Start and end strings will be added later}
echo.
set /p yn10={y,n}
if /i "!yn10!"=="y" (
  call :setcaps

  cls
  echo !NewName!
  echo.
  echo Would you like to insert anything into the name
  set /p yn8={y,n}
  if /i "!yn8!"=="y" call :insertsubroutine

  cls
  echo !NewName!
  echo.
  echo Would you like to remove anything from the name
  set /p yn12={y,n}
  if /i "!yn12!"=="y" call :removesubroutine
)
cls
echo !NewName!
echo.
echo Do you need to make any other changes?
echo.
set /p yn15={y,n}
if "%yn15%"=="y" goto editname

set NewName=!startstr!!NewName!!endstr!!Extension!

cls
echo.
echo !NewName!
echo.
echo Is this correct
set /p yn9={y,n}
if /i "!yn9!"=="y" (
  echo !NewName! from !OldName!!Extension! >>%origdir%\Renamelog.txt
  ren "!OldFilePathAndName!" "!NewName!"
  set /a numnam=!numnam!+1
) else (
  cls
  echo Would you like to try again
  echo.
  set /p yn12={y,n}
  if /i "!yn12!"=="y" goto editname
)
goto eof

:insertsubroutine
:insertsub
cls
echo  !NewName!
echo 012345678911111111112222222222333333333344444444445555555555
echo           01234567890123456789012345678901234567890123456789
echo To the **right** of what position would
echo you like to insert the string?
set /p strpos=Right of Position-
echo What would you like to insert
set /p stradd=[String]
call set NewName=%%NewName:~0,!strpos!%%!stradd!%%NewName:~!strpos!%%
cls
echo !NewName!
echo.
echo Is there anything else that needs to be added
set /p yn11={y,n}
if /i "!yn11!"=="y" goto insertsub
goto eof


:removesubroutine
:removesub
cls
echo  !NewName!
echo 012345678911111111112222222222333333333344444444445555555555
echo           01234567890123456789012345678901234567890123456789
echo What are the start and end positions
echo of the string to be removed?
echo.
echo Note that the start position should be
echo the last character that you want to stay
echo and the end position the last character
echo you want deleted
echo.
set /p remstpos=Start Position-
set /p remenpos=End Position-
call set NewName=%%NewName:~0,!remstpos!%%%%NewName:~!remenpos!%%
cls
echo !NewName!
echo.
echo Do you need to remove anything else
set /p yn13={y,n}
if /i "!yn13!"=="y" goto removesub
goto eofOf course that one is very long and complex to help allow for a lot of different USES with renaming. For what you are trying to do, try this:

Code: [Select]echo off
setlocal enabledelayedexpansion
set seq=1

for /f "delims=" %%a in ('dir *.png /s /b') do (
  set newname=0!seq!.png
  set newname=!newname:~-6!
  ren %%a !newname!
  set seq+=1
)
This only allows for 100 files to be renamed this way in a single directory, if you are wanting to have more, just change the number of zeros in the first "set newname" command and change the number in the second newname command.
569.

Solve : Dos executables?

Answer»

is there a program that will convert .cpp files into .exe files?
does anybody know a scorce of a website where i can dowload something in that idea for free (yes, possibly illegal)
i dont have kaZAA
and i wont get it.
is there a line in c++ that will make a PROG run 0N dos?
please explain. is this is a question meant for the "computer programming" FORUM then i will also POST it there.Thats normally a source CODE file. Have you tried using a compiler?

570.

Solve : create a list of files?

Answer»

Folder InPut on desktop is having 3 files..   

File 1.doc
File 2.doc
File 3.doc

Now I want to create a batch file on desktop which CREATES list of all files as file.txt on desktop

So file.txt should contain...

File 1.doc
File 2.doc
File 3.doc

Please help (needed only short names) CODE: [Select]echo off
chdir %userprofile%\Desktop\InPut
dir >..\File.txt
exit
Quote from: bobsklarservices on October 21, 2011, 09:26:08 AM

Code: [Select]echo off
chdir %userprofile%\Desktop\InPut
dir >..\File.txt
exit

That will give you a full directory output, but I don't think that is what the OP is looking for. Try adding /b the dir command to shorten things up. Also, not all batchers are going to know where "..\File.txt" is going to show up, so make it a little more obvious:

dir /b > %userprofile%\desktop\File.txt Quote from: Raven19528 on October 24, 2011, 10:56:39 AM
not all batchers are going to know where "..\File.txt" is going to show up

They will soon (if they are the sort who are worth helping!) and especially if you tell them that two DOTS and a slash like this ..\ means "the directory one level up from where you are" and that you can stack them to go all the way up the tree.
I knew exactly what the code I posted would do. But thank you for clarifying it for me. While I may be pretty INTELLIGENT, I don't necessarily communicate WELL.
571.

Solve : net send.... help!?

Answer» HI
   my friend thought it would be funny to run a batch FILE to net send me loads of messages, but made his batch file so that the messages were under a false name. he refuses to TELL me what the code was to MAKE it anonymous. i already KNOW how to make a batch file that sends loads of net send messages....... but how do i make them anonymous? any help is much appreciated!chuck fadanoid.....with friends like that ...who needs enemies .....lol.
With all due respect , why would we tell you how to create spam or unwanted messages.....

Sorry ....

dl65
572.

Solve : function keys don't seem to be handshaking on new computer running DOS program?

Answer»

I have an old 386 computer that runs a DOS program for a test machine I have.  I had the hard drive CLONED over to a newer machine with PS/2 keyboard CONNECTIONS..  Everything seems to work fine except there is one program that I need to run to download some software to my test machine and it requires the use of the function keys.  When I use the F2 key on the new cloned computer it returns an error " VAL string isn't a proper number"

The old 386 machine WORKS fine.  Is there something on the newer machine that isn't HANDSHAKING properly with the test machine?

Is there anything I can change?   The cloned software on the drives seems identical.  I've eliminated the leyboard being the problem as I can use both the old AT 5 pin or the newer PS/2 keyboard with my old 386 machine and they both work fine.If it happens on both KEYBOARDS it's either the App itself...or the language layout/setting on the keyboard.

Does Shift F2 help ? ?

573.

Solve : Capture error/and output of commands to log file?

Answer»

I'd like to be able to capture all error output generated from a dos batch file (regardless of error generated)
  i.e.

if errorlevel --1 goto error

:Error
capture error and pipe to error log file

Appreciate insightWell the easiest way to make sure to capture it all is to put

>>errorlog.txt

at the end of every line that you believe an error could be generated from. What commands in the batch file are you wanting to know about the errors for? Many times, you can write a batch file that can accomodate any errors that may arise with proper planning and the correct knowledge. If possible, post the file here and we can all analyze it and let you know where errors are likely to occur and what to do about them, and how to code it.Hi there, and thanks for the reply.  Here is my basic batch file which in turn call several other subroutines as part of a system environment refresh:

REM CPY Daily Refresh job-created Sept11

echo on
:Step 1--Call StopAppBat_Server.bat to shutdown PS environment
C:
CD c:\scripts\hr83cpy
ECHO Shutting Down App Batch Server
CALL StopAppBat_Server.bat
if %errorlevel%==1 goto ERROR



:Step 2--use osql to kill any active user sessions
CD c:\scripts\HR83CPY
osql -S Server1 -E -i c:\scripts\hr83cpy\uspkill.txt  >>c:\scripts\hr83cpy\hr83cpy_refresh.txt
echo User sessions have been terminated!

osql -S Server1 -E -i c:\scripts\hr83cpy\uspkill.txt  >>c:\scripts\hr83cpy\hr83cpy_refresh.txt
echo User sessions have been terminated!
if %errorlevel%==1 goto ERROR


:Step 3--check for existence and time stamp of backup file
CD c:\scripts\HR83CPY
osql -S Server1 -E -Q "exec master..uspVerifyBackupFiles '\\svmpsdb01\backup$\HR83PRD_Full_LiteSpeed.BAK', 4, 12"  >>c:\scripts\HR83CPY\hr83cpy_refresh.txt
if %errorlevel%==1 goto ERROR



:Step 4--use isql command to kick off refresh executing refresh script
CD c:\scripts\hr83cpy
echo Refreshing Database
isql -S Server1 -E -i c:\scripts\hr83cpy\hr83cpy-Restore.sql -o >>c:\scripts\hr83cpy\hr83cpy_refresh.txt
if %errorlevel%==1 goto ERROR


:Step 4--Restart PS environment
REM c:
REM CD c:\scripts\hr83cpy
echo Restarting App And Batch Server
CALL Start_Tuxedo_Domain.bat
if %errorlevel%==1 goto ERROR


:Step 5--Send Refresh log
CD C:\Scripts\hr83cpy
echo Sending Refresh log file
CALL Refresh_Log.cmd
if %errorlevel%==1 goto ERROR

:Step 6 Move and rename log file
CD C:\Scripts\hr83cpy
move c:\scripts\hr83cpy\HR83CPY_refresh.txt c:\scripts\hr83cpy\logs\HR83CPY_refresh.txt
CALL file-rename.bat
if %errorlevel%==1 goto ERROR

:END

:ERROR
if %errorlevel%==1 CALL ERROR_EMAIL.bat


Please take a look.  Your suggestions are appreciated.
PeterSo form what I can tell, you want the entire program to run all the way through, and any errors that are generated to trigger the ERROR_EMAIL.bat. This isn't difficult, though does require some additional code.

Code: [Select]echo on
set errorcheck=0

:Step 1--Call StopAppBat_Server.bat to shutdown PS environment
C:
CD c:\scripts\hr83cpy
ECHO Shutting Down App Batch Server
CALL StopAppBat_Server.bat>temp.txt
if errorlevel 1 (
  set /p log=<temp.txt
  echo %log% >>errorlog.txt
  set errorcheck=1
  del temp.txt
) else del temp.txt

:Step 2--use osql to kill any active user sessions
CD c:\scripts\HR83CPY
osql -S Server1 -E -i c:\scripts\hr83cpy\uspkill.txt  >temp.txt
echo User sessions have been terminated!
set /p log=<temp.txt
if errorlevel 1 (
  echo %log% >>errorlog.txt
  set errorcheck=1
  del temp.txt
) else (
  echo %log% >>c:\scripts\hr83cpy\hr83cpy_refresh.txt
  del temp.txt
)

:Step 3--check for existence and time stamp of backup file
CD c:\scripts\HR83CPY
osql -S Server1 -E -Q "exec master..uspVerifyBackupFiles '\\svmpsdb01\backup$\HR83PRD_Full_LiteSpeed.BAK', 4, 12"  >temp.txt
if errorlevel 1 (
  echo %log% >>errorlog.txt
  set errorcheck=1
  del temp.txt
) else (
  echo %log% >>c:\scripts\hr83cpy\hr83cpy_refresh.txt
  del temp.txt
)

:Step 4--use isql command to kick off refresh executing refresh script
CD c:\scripts\hr83cpy
echo Refreshing Database
isql -S Server1 -E -i c:\scripts\hr83cpy\hr83cpy-Restore.sql -o >temp.txt
if errorlevel 1 (
  echo %log% >>errorlog.txt
  set errorcheck=1
  del temp.txt
) else (
  echo %log% >>c:\scripts\hr83cpy\hr83cpy_refresh.txt
  del temp.txt
)

:Step 5--Restart PS environment
REM c:
REM CD c:\scripts\hr83cpy
echo Restarting App And Batch Server
CALL Start_Tuxedo_Domain.bat >temp.txt
if errorlevel 1 (
  set /p log=<temp.txt
  echo %log% >>errorlog.txt
  set errorcheck=1
  del temp.txt
) else del temp.txt

:Step 6--Send Refresh log
CD C:\Scripts\hr83cpy
echo Sending Refresh log file
CALL Refresh_Log.cmd >temp.txt
if errorlevel 1 (
  set /p log=<temp.txt
  echo %log% >>errorlog.txt
  set errorcheck=1
  del temp.txt
) else del temp.txt

:Step 7 Move and rename log file
CD C:\Scripts\hr83cpy
move c:\scripts\hr83cpy\HR83CPY_refresh.txt c:\scripts\hr83cpy\logs\HR83CPY_refresh.txt
CALL file-rename.bat >temp.bat
if errorlevel 1 (
  set /p log=<temp.txt
  echo %log% >>errorlog.txt
  set errorcheck=1
  del temp.txt
) else del temp.txt

if "%errorcheck%"=="1" call ERROR_EMAIL.bat
:END
You will have some problems when using the call command if the other programs require additional inputs or output anything. If that is the case with any of the called programs, you will NEED to exchange the
set /p log=<temp.txt
with
for /f "delims=" %%A in (temp.txt) do set log=%%A
which will then capture the list line of the file (which is where any error message should be.) Please post if you run into anything that you don't know what to make of it, and we can try to see if there is something else we can do. Like I stated, it's the fact that this program is calling other programs that is causing the biggest issue. Is there anyway you could include them within this one program? Or are they used by other programs as well?Thanks for your reply and modified script provided.

Right now I am trying out the script as posted.  I did run into one issue where I had the wrong database Server (Step 3&4), and it did write the error message to errorlog.txt.  That is fine, but ideally would like ERROR_EMAIL.bat to email me this when the issue had occured, somehow it didn't get triggered.

ERROR_EMAIL.bat :
echo off
postie -host:mailserver -to:[email protected] -from:[email protected] -s:"Refresh Error" -msg:"Check logs, EP88RPT Refresh failed**log file attached" -a:"C:\scripts\EP88RPT\errorlog.txt"

Also I did try to run the script bundled together with most of the sub routines as shown below (without the modified error logic):
echo on
:Step 1--Call StopAppBat_Server.bat to shutdown PS environment


:Step1
:CREATE batch_stop_log.txt file with current date and time
echo off
if not [%1]==[] goto start
set var=%date% %time%
set var=%var:/=-%
>"EP88RPT_refresh.txt" echo %var%
cmd /c %0 start >>"EP88RPT_refresh.txt"
goto :EOF
:start

:Step 2a
:Set Environment variables, shut down Application Server, delete :cache, and logs directory and recreate logs directory. 
SET APPSERVER=EP88RPT
SET DATABASE=EP88RPT
echo Shutting down %DATABASE% Application Server...
echo.
ECHO Shutting down Application Server
d:
CHDIR D:\psoft\%APPSERVER%\appserv
psadmin -c shutdown! -d %DATABASE%
psadmin -c shutdown! -d %DATABASE%
psadmin -c shutdown! -d %DATABASE%
psadmin -c shutdown! -d %DATABASE%
if %errorlevel%==1 goto ERROR
ECHO DELETING System Cache
rmdir /S /Q D:\psoft\%APPSERVER%\appserv\%DATABASE%\CACHE
if %errorlevel%==1 goto ERROR
ECHO Deleted App Server logs
rmdir /S /Q D:\psoft\%APPSERVER%\appserv\%DATABASE%\LOGS
if %errorlevel%==1 goto ERROR
mkdir D:\psoft\%APPSERVER%\appserv\%DATABASE%\LOGS
if %errorlevel%==1 goto ERROR


:Step 2b
:Set Environment variables, shut down Process Scheduler Server, delete cache, :and drop logs directory and recreate logs directory. 

:start
SET PROCESS_SCHEDULER=EP88RPT
SET DATABASE=EP88RPT
echo Shutting down %DATABASE% Process Scheduler...
echo.
d:
CHDIR D:\psoft\%PROCESS_SCHEDULER%\appserv
psadmin.exe -p stop -d %DATABASE%
psadmin.exe -p stop -d %DATABASE%
psadmin.exe -p stop -d %DATABASE%
psadmin.exe -p stop -d %DATABASE%
if %errorlevel%==1 goto ERROR

echo Deleting System Cache
rmdir /S /Q D:\psoft\%PROCESS_SCHEDULER%\appserv\prcs\%DATABASE%\CACHE
if %errorlevel%==1 goto ERROR

echo %DATABASE% Batch Cache Deleted
rmdir /S /Q D:\psoft\%PROCESS_SCHEDULER%\appserv\prcs\%DATABASE%\LOGS\
if %errorlevel%==1 goto ERROR

mkdir D:\psoft\%PROCESS_SCHEDULER%\appserv\prcs\%DATABASE%\LOGS\
if %errorlevel%==1 goto ERROR

ECHO %DATABASE% Deleted Process Schedulers Logs
ECHO Delete Log_Output files
rmdir /S /Q D:\psoft\%PROCESS_SCHEDULER%\appserv\prcs\%DATABASE%\log_output
ECHO Log_output deleted!
pause

:Step 3--use osql to kill any active user sessions
c:
CD c:\scripts\ep88rpt
osql -S Server1 sa -P password -i c:\scripts\ep88rpt\uspkill.txt  >>c:\scripts\ep88rpt\ep88rpt_refresh.txt
echo User sessions have been terminated!
if %errorlevel%==1 goto ERROR
pause
c:
CD c:\scripts\ep88rpt
osql -S Server1 -U sa -P password -i c:\scripts\ep88rpt\uspkill.txt  >>c:\scripts\ep88rpt\ep88rpt_refresh.txt
echo User sessions have been terminated!
if %errorlevel%==1 goto ERROR
pause


:Step 4--check for existence and time stamp of backup file
c:
CD c:\scripts\ep88rpt
osql -S Server1 -U sa -P password -Q "exec master..uspVerifyBackupFiles '\\svmpsdb03\backup$\PA880PRD_Full_LiteSpeed.BAK', 4, 12"  >>c:\Scripts\ep88rpt\ep88rpt_refresh.txt
if %errorlevel%==1 goto ERROR


:Step 5--use isql command to kick off refresh executing refresh script
c:
CD c:\scripts\ep88rpt
echo Refreshing Database
isql -S Server1 -U sa -P password -i c:\scripts\ep88rpt\ep88rpt-Restore.sql -o >>c:\scripts\ep88rpt\ep88rpt_refresh.txt
if %errorlevel%==1 goto ERROR


:Step 6--Restart PS environment
:Create batch_stop_log.txt file with current date and time
echo off
if not [%1]==[] goto start
set var=%date% %time%
set var=%var:/=-%
>>"EP88RPT_refresh.txt" echo %var%
cmd /c %0 start >>"EP88RPT_refresh.txt"
goto :EOF
:start
:Set Environment variables, boot Application Server
SET APPSERVER=EP88RPT
SET DATABASE=EP88RPT
echo Booting up %APPSERVER% Application Server...
echo.
ECHO Booting up Application Server
d:
CHDIR D:\psoft\%APPSERVER%\appserv
psadmin -c boot -d %DATABASE%
if %errorlevel%==1 goto ERROR

ECHO Application Server has started!



:ECHO Booting up Process Scheduler
d:
CHDIR D:\psoft\%APPSERVER%\appserv
psadmin.exe -p start -d %DATABASE%
if %errorlevel%==1 goto ERROR

ECHO PRocess Scheduler has started!


:Step 7--Send Refresh log
c:
CD C:\Scripts\ep88rpt
echo Sending Refresh log file
echo off
postie -host:mailserver -to:[email protected] -from:[email protected] -s:"EP88RPT has been refreshed" -msg:"EP88RPT has been refreshed**log file attached" -a:"C:\scripts\ep88rpt\EP88RPT_refresh.txt"

:Step 8 Move and rename log file
c:
CD C:\Scripts\ep88rpt
move c:\scripts\ep88rpt\ep88rpt_refresh.txt c:\scripts\ep88rpt\logs\ep88rpt_refresh.txt
echo off
CD logs

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "EP88RPT_refresh.txt" EP88RPT_refresh_%%e-%%f-%%g.txt

:END

:ERROR
if %errorlevel%==1 CALL ERROR_EMAIL.bat

REM ECHO Error Log Open >C:\Scripts\ep88rpt\ERR.LOG
REM ECHO Error 1 >>C:\Scripts\ep88rpt\ERR.LOG
REM CALL ERROR_EMAIL.bat


When executing this script together it fails at step 3
I get "The process cannot access the file because it is being used by another process."

So 2 things that would be great.  First if the script will email me on error with the error log file, and second if we go with just the one large main script can we make it work based on the error I got in the above paragraph?

Much appreciated for your help/insight.

In order to address your first issue regarding the ERROR_EMAIL.bat, I would suggest either checking your syntax on postie, or possibly using a different program to accomplish the task. You might also look at using CD to ensure you are in the correct directory when the program runs.

On your second issue, this error is common and is usually rectified by using taskkill to make sure the task is not running prior to trying to running the osql line.

In your script, to save some time and carriage returns, try using the CD /D when changing directories and don't worry about the seperate drive letter change. Also, I see a lot of repetitiveness in the file. Is this needed? When four lines say exactly the same thing ( psadmin -c shutdown! -d %DATABASE% ) what is the purpose behind it? Are they performing different functions?Hey there...

Thanks for all your help so far.  I did make an error on the isq/osq syntax and managed to run the script ok.  What I did NOTICE was when I ran step 2/3/4 (sql tasks) they would not echo over the output to the EP88RPT_refresh.txt.  When  I ran step 2, the task was echoed into the temp.txt, but not added to the EP88RPT_refresh.txt.  This is the typical reply from sql when runnning step 2 "1> 2> Killing Users
-----------------
Done" 

Here's part of the screen when I ran just this step from the command prompt on 2 lines I got:

C:\Scripts\EP88RPT>set /p log= 02> was unexpected at this time.

C:\Scripts\EP88RPT>  echo 1> 2> Killing Users >>errorlog.txt

Similar issue with step 3 where the output was written to temp.txt and not added to EP88RPT_refresh.txt.
C:\Scripts\EP88RPT>osql -S ZVMPSESQL03 -U sa -P 29HollyBurn$ -Q "exec master..u
pVerifyBackupFiles '\\svmpsdb01\backup$\HR83PRD_Full_LiteSpeed.BAK', 4, 12"   1
temp.txt
2> was unexpected at this time.

C:\Scripts\EP88RPT>  echo 1> 2> Killing Users >>errorlog.txt

One additional note on your question for the 4 times using the psadmin; its to isure the environment is complely shutdown as there can be issues with some threads remaining open.

Hope this helps.  Getting closer.
Did not know that the output would use those redirect ">"s. Also, looking back over the script I posted, I'm seeing that I did not add the set /p log=<temp.txt line before the errorlevel check. Looks like I missed it in step 3 and 4.

To take care of the issue with redirection characters, I would suggest parsing the output. REPLACE the set /p log=<temp.txt line on steps that involve the sql commands with:
Code: [Select]for /f "tokens=1,2* delims=>" %%A in (temp.txt) do (set log=%%A %%B %%C)
This should take out all of the redirection symbols that are causing problems. This is of course assuming that the output is fairly standard and only has two >'s that show up. Please let me know if the output from the sql commands has varying numbers of > output, as that will take a different type of coding to get through.Thanks for this, I have been pretty busy and hope to try this out near the end of the week.  Let you know how it goes.

574.

Solve : how to use expression in for loop?

Answer»

Hi Guys,

I have the below script. My aim is to add 1 to variable count in each ITERATION of the for loop. So, if temp.txt has 10 LINES, count will be 10 finally.

set count=1

for /f "eol=v" %%f in (temp.txt) do (
   set /A count = %count% + 1
   echo %count%
)

But I always get count value is 1. I know the statement "set /A count = %count% + 1" is not correct but don't know how to FIX it.

Anybody can help me on this?Try this:

Code: [Select]echo off
cls
setlocal enabledelayedexpansion

for /f "eol=v" %%f in (temp.txt) do (
   set /A count +=1
   echo !count!
) Quote from: crest.boy on October 17, 2011, 02:06:36 AM

I know the statement "set /A count = %count% + 1" is not correct but don't know how to fix it.

set /A count=%count%+1
set /A count+=1

are equivalent but in a loop you need to USE delayed expansion (exclamation marks instead of percent signs) in the long form

set /A count=!count!+1

(best to omit spaces)



 (google for zillions of explanations)
Quote from: Salmon Trout on October 17, 2011, 08:22:20 AM
set /A count=%count%+1
set /A count+=1

are equivalent but in a loop you need to use delayed expansion (exclamation marks instead of percent signs) in the long form

set /A count=!count!+1


Set /A count=count+1 is also equivalent both inside and outside of a loop, delayed expansion not necessary for a Set /A command LINE..

A little demo:

Code: [Select]echo off
setlocal
cls

for /l %%1 in (1,1,20) do (
    set /a count=count+1
    set /a cntr=cntr+1
    set /a number=count+cntr
    )
    set /a number=number+100
    echo Number=%number%

Quote from: Dusty on October 19, 2011, 12:57:35 AM
Set /A count=count+1 is also equivalent both inside and outside of a loop, delayed expansion not necessary for a Set /A command line..

Right. You can use both the long and short form set /a notations in a loop without delayed expansion, and the final value after the loop is exited will be correct, but delayed expansion is definitely necessary if you want to, er, expand the variable inside the loop.
575.

Solve : Function Keys AT type keyboard vs PS2 keyboard?

Answer»

I have an older piece of test equipment that runs a program out of DOS originally loaded on an AT type PC.  I had a clone made of the harddrive on a newer machine that uses a PS2 KEYBOARD instead of the OLD AT (large round 5 pin keyboard connector) keyboard.  Everything seems to work fine except the F1 - F6 keys do not function with the PS2 keyboard.  Is there a fix or workaround?Just a thought - have you tried using the old keyboard with an adapter?  I know that has worked for us in the past here at work on some of our DOS machines.I just tried using the old AT style keyboard + adaptor to PS2 no luck.  That was definately worth a try. I wonder if it COULD be anything to do with the way the GRAPHICS are displayed?

576.

Solve : Window positioning?

Answer»

Is there anyway to have a batch FILE start another and have that window open at a specific point on the screen. I'm trying to have a batch file open three others, one as a banner at the top of the screen and the other two on either side of the screen. In the START options, it MENTIONS you can start a program minimized or maximized, but it says nothing about positioning on the screen. Is it something I can write into the other batch files? Is it possible to do within batch?

Thanks for the help.There is no built in way to set a COMMAND window size and position on the screen as you describe. There is a utility called CMDOW which you can download which allows a batch script to set its own size and position. (and a lot of other things as well)

http://www.commandline.co.uk/cmdow/


I also found this article explaining how to do so by MODIFYING the registry, but it looks like it is a lot more time and labor intensive. However it does allow this to happen solely within batch, in case any others are LOOKING for it.

http://forums.techguy.org/software-development/898653-resize-move-batch-window.html

577.

Solve : Seaching for documents by an owner?

Answer»

Hi there,
I have a customer that is looking for all the documents he has created on a particular network drive.  I was thinking of creating a batch file that would query the network drive and retrieve this INFORMATION for me . Any ideas on this sytax? or any advice on how this would be done would be appreciated.Maybe use FC or COMP with a file containing his NAME as the comparioson template, or use a text SEARCH TOOL?

578.

Solve : Using find to Search files in Different directories for a string?

Answer»

Hello I have a windows directory structure that contains some logs I want to search. With in the logs folder there is user1...user2... sub folders. I would like to point to the top level "logs" folder and have the .bat file search the subfolders automatically. Right now I have to point to the user folder. Here is the code I have

Code: [Select]echo off
echo.
set /p thesearchfolder= "Folder to search for data (Drag folder into window): "
find "Error" %thesearchfolder%\*.txt > "%TEMP%\errorlog.txt"


echo "%TEMP%\errorlog.txt"
notepad "%TEMP%\errorlog.txt"

Any help great appreciated.Others will probably come up with better answers but you could do something like this.
a) use dir with /s and redirect output to a text file. This gives you a list of all files in all subfolders.
b) use a for loop and use find on each file read from the text file.Thanks for the reply emanresu

How would they look in terms of code. I tried this but it didnt work

Code: [Select]for /d %f in (%thesearchfolder%\*) do find "Error" %f\*.txt > "%TEMP%\errorlog.txt"
Guess I'd write something like this (untested!)...

Code: [Select]dir /w /s  %thesearchfolder%\*.txt  >  tempdir.txt

for /f "skip=5 tokens=1,2,3" %%f in (tempdir.txt) do find "Error" %%g.%%h >> %TEMP%\errorlog.txt
emanresu is on the right track with his suggestions. Your output errorlog.txt file should also be more helpful when errors are found, so I've taken some artistic license and MODIFIED the code a touch. See if it works for you.

Code: [Select]echo off
set /p thesearchfolder="Folder to search for data (Drag folder into window): "

for /f "delims=" %%A in ('dir %thesearchfolder% /s /b') do (
  echo %%A >> %TEMP%\errorlog.txt
  findstr /i /n "Error" %%A >> %TEMP%\errorlog.txt
  if errorlevel 1 (echo 0 errors found >> %TEMP%\errorlog.txt)
)

echo %TEMP%\errorlog.txt
start %TEMP%\errorlog.txt
  Have modified my, still untested, code above. However, Raven has given a much more elegant solution.   HAY Raven Thanks a lot for the nice solution one last question on the "findstr" It turns out the actual error string I want to search for is
"Error bad" I tried to add option to the findstr command so that it would search for "Error bad" as a literal sting. However, the command finds every line that contain "Error" or "bad" opposed to "Error bad"

This is what I tried
Code: [Select]findstr /i /n /C:"\<Error Bad\>" %%A >> %TEMP%\errorlog.txt

Not sure what I am doing worngTry:
Code: [Select]findstr /i /n /c:"Error Bad"
I'm not sure if you are wanting the slashes and carets, but try just the words and you should grab the right stuff. You may want to try a setlocal enableextensions at the beginning of the code if you are still running into trouble and see if that helps anything.My text file contains lines that have "Error bad" and lines that contain "Error good"

I tried using the command

Code: [Select]findstr /i /n /c:"Error Bad"

For some reason it give me the "Error bad" and "Error good"
It is perform in OR on the words for some reason.

I also put
Code: [Select]setlocal enableextensions
at the topFor some odd reason I have to change the name of the file I was writing to. Not sure why.

Opposed to errorlog.txt i have to use

errorlogX.txt each time I run. where X=1,2,3....

A little bit of a pain but I can LIVE with it.
Anyway around having to modify the code name for each run? So long as you don't move the batch file around much, the following will ALLOW for a simple file to keep your instance count and accomplish the numbering you are looking to do.

Code: [Select]set /p seq=<seq.log
set /a seq+=1
echo %seq%>seq.log

Now modify all of of your errorlog.txt files to errorlog%seq%.txt.

Also, before running the first time, open a cmd prompt, change to the directory your batch file is in and type the following echo 0>seq.log

On your second issue, try running your findstr command from the command prompt and see what you get. I did so and I got only Error Bad lines from a test file I set up. So the command should be working, and without seeing it I wouldn't know of any reason why it would be giving you the error. Did you remember to save the .bat file after made the changes and before you ran it? Seems simple, but it has happened to me more often than I care to admit.

579.

Solve : Batch works, but token arguement looks wrong??

Answer»

So I put together this batch with some help from google, and I changed it to GET the output I wanted which was the 3 letter Day instead of 10/25/2011. I REPLACED the "tokens=*" with "tokens=3" and end up with what I want, BUT I dont think I am using this token arguement correctly as for even placing values of 1 and 8 in 3's place I still get the same result. I am guessing that I am misinterpreting the token arguement even though I am getting the result I want. I assumed that the token arguement was to specify how many character places on the line or range to read in on the line. So when i put in 1, I expected to see just a T for Tue and when using 8 I expected to see Tue 10/2. I FEEL I am way off on my understanding of the token arguement and someone here will point out where I am wrong so I can learn the correct method and what is happening with the token= statement here to allow for the result I want, when just about any number gives same results. I could have just run with this batch since it works, but I dont like running a BOTCHED batch. I'd rather have it batched correctly and learn from my mistakes even though I am getting the results I want. This is probably the very first post here asking for help for a batch that works, but is probably way wrong..lol 


Code: [Select]ECHO OFF
FOR /F "tokens=3" %%A IN ('DATE/T') DO FOR %%B IN (%%A) DO SET Today=%%B
ECHO %Today% >Day.txtYour tokens= actually isn't setting anything to do with the tokens, but rather how many there are. Your delims= would actually be what seperates the tokens. Since it isn't specified, delims= assumes any space to be a delimiter, which is why it doesn't matter in your example what number you put in tokens=. In your example, if you were to say tokens=1, then you would only be designating that there is one token, so the first delimiter encountered would determine the token and the rest of the line would be dismissed. Doing something like tokens=1* says that the first delimiter encountered determines the first token and the rest of the line is assigned to the second token, regardless of delimiters.

So using your date /t example (which today outputs "Tue 10/25/2011"), using "tokens=1" designates %A as the three letter day (because there is a space after the day) and nothing else is assigned. Using "tokens=1*" designates %A as the three letter day, again, but assigns the rest of the line to %B. You can manipulate this a little by assigning different delimiters. For example, "tokens=1 delims=/" would assign everything up to the first "/" as %A token. Now, if you were to use "tokens=1* delims=/" then "Tue 10" would be assigned to %A, and "25/2011" would be assigned to %B (notice that even though a delimiter is in the string, because we designated the "*" it takes everything else and assigns it to the second token.) In this example, "tokens=2 delims=/" would assign "Tue 10" to %A and assign "25" to %B and dismiss everything else. You can use these two parameters to parse out lines fairly intricately.

The other parameter that can be set is the "eol" parameter, which allows you to designate an end of line parameter in case you are wanting to ignore everything after a certain character(s). Using "eol=/ tokens=1*" would assign “Tue” to %A and “10” to %B. Everything after the “/” would be dismissed.

So hopefully that explains what you are looking for. If you are still confused, please say what you are confused on and I will try to explain it better. Quote

Your tokens= actually isn't setting anything to do with the tokens, but rather how many there are

Not quite. tokens=3 does not define 3 tokens, it defines 1 token. The tokens clause defines which values in the parsed string are addressable.  The parsing (based on the delims clause) is done ahead of the tokens/value assignments.

Code: [Select]for /f  %i in ("one two three four five six seven") do echo %i

The default for tokens is 1 and delims is space or tab. The above snippet will assign %i to a value of one

Code: [Select]for /f  "tokens=3,5,7" %i in ("one two three four five six seven") do echo %i %j %k

Now the fun begins. Only the third, fifth and seventh values in the parsed string are defined as addressable by the tokens clause. The %i token is explicitly defined and subsequent tokens will be assigned sequentially. The delimiter is still a space, so the tokens values shake out as %i is three, %j is five and %k is seven.

You can also use ranges in the tokens clause and even mixed them will single positional values:

Code: [Select]for /f  "tokens=2-4,6" %i in ("one two three four five six seven") do echo %i %j %k %l

The above snippet will assign %i to two, %j to three, %k to four and %l to six

There are other variations. The for statement can muck up the readability of a batch file, but is also a workhorse among the few batch instructions available.

 

The snippets above are design for command prompt execution. Double up the percent symbols for use in batch FILES.
580.

Solve : deleting files with spaces in between the name?

Answer»

hi, i have a problem

suppose i have a file called " TEXT document.TXT"
how do i delete from dos.
the problem is the space between text and document.

i have tried del text\ document.txt ( as in unix ) but it doesn`t work

any help?

THANKS in advance
Include <path><FILENAME> in quotation marks or use the DOS 8.3 format and substitute a question mark for the space.del "text document.txt"
del textdo~1.txt


both work.

If I had a SHORT name file like s t.txt (s, space, t, dot, txt) I could use

del s%20t.txt

but the name still has to fit in the 8.3 format unless you use "doublequotes".

581.

Solve : SET variable substitution problem?

Answer»

Hi,
I'm writing a script to update MS Office path in multiple batch files. My FIRST part finds the files containing the required string...
Code: [Select]setlocal enabledelayedexpansion
if exist ztmplist.txt DEL ztmplist.txt
if exist templist.txt del templist.txt
cd testbatch
rem dir /w *.bat >..\ztmplist.txt
find /I /C "C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE11" *.bat | find /V ": 0" | find "----------" >..\ztmplist.txt
rem pause
for /f "delims=" %%x in (..\ztmplist.txt) do (
    set echLine=%%x
    set echLine=%echLine:~0,-3%
    echo !echLine!>>..\templist.txt
)
Now, ztmplist.txt contains
---------- SCRIPTEXTRACTGLOBAL.BAT: 1

but templist.txt only contains
~0,-3

What I was attempting to do was remove the ": n" (where n could be any number) from the end of the line. Can anyone see where I've gone wrong?

ThanksThink I've got it. Need to change final set to
Code: [Select]set echLine=!echLine:~0,-3!

YES, works now. Also changed so drops PRECEDING hyphens:
Code: [Select]setlocal enabledelayedexpansion
if exist ztmplist.txt del ztmplist.txt
if exist templist.txt del templist.txt
cd testbatch
rem dir /w *.bat >..\ztmplist.txt
find /I /C "C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE11" *.bat | find /V ": 0" | find "----------" >..\ztmplist.txt

for /f "delims=" %%x in (..\ztmplist.txt) do (
   set echLine=%%x
   set echLine=!echLine:~11,-3!
   echo !echLine!>>..\templist.txt
)

582.

Solve : Command (.cmd) file help?

Answer»

I have recent been teaching myself how to create command files and am in of need some expert assistance.
My problem is that I am trying to come up with a simple way to add a missing sting to the end of the 'PATH' key at:-
HKLM\System\CurrentControlSet\Control\Session Manager\Environment\Path

Without replacing what is already there as this can vary on a number of different WORKSTATIONS on the network.

This is what I have come up with so far to check the 'Path' key:-
------------------------------------------------------------------------

echo off
cls

if {%1}=={} GOTO Syntax

reg query "HKLM\System\CurrentControlSet\Control\Session Manager\Environment\Path" \\%1
echo.

Goto End

:Syntax
echo Displays a listing of the REGISTRY key which contains
echo the data value for the Path setting.
echo.

echo Usage: CHECKPATH [computername]
echo.
goto End

:End
------------------------------------------------------------------------

and that's all good.
Now what I need to know is how add ;C:\APPS\IBLOCAL\BIN; without replacing whats already in there.
i.e using the reg update string.

Can any body help me?path=c:\winnt\;c:\
prompt=$p$g
path=%path%;c:\winnt\system32\msresourcekit\;
set temp=c:\winnt\temp
ver


Above shows example of appending to environment with PATH commandThanks for the reply, but it's not REALLY what I am after.
I want to apply this so it works when I use it to update a remote workstation.
I know how to update one LOCALLY just not remotely.

Is there a way to use the pathman.exe command to do this remotely. e.g.

pathman /as ;C:\APPS\IBLOCAL\BIN;

Can I somehow get this above command to launch on a remote workstation?It's all good. I managed to find a way myself.
reg update "HKLM\System\CurrentControlSet\Control\Session Manager\Environment\Path=%PATH%;C:\APPS\IBLOCAL\BIN;" \\%1

This works on remote workstations.
Thanks anyway...

583.

Solve : Check for running process?

Answer»

I am looking for a way to check for a running PROCESS  specifically msiexec and then when it completes to run ANOTHER program...   I have a start I THINK that I got from a script to start a process if not running but I don't quite understand what its doing.... heres what I have now....  

:TOP
for /f "usebackq tokens=1" %%a in (`pslist ^| FIND /i /B "msiexec"`) Do SET ProcessRunning=%%a
If "%processrunning%" == "msiexec" Goto TOP
:End

584.

Solve : [Request] Wallpaper change script?

Answer»

Hello,

I have an issue with dreamscene on win7 that blurs the text below all icons/shortcuts on the desktop. In order to fix it, I need to change the wallpaper to a SOLID black background, then reselect the original wallpaper - every time the computer is restarted.

I was hoping that it was possible to accomplish this via a vbs SCRIPT or bat file, but I don't have the know-how to accomplish this. If someone would be KIND enough to create this simple script, it would be greatly appreciated.

Basic flow of script required :

Code: [Select]Start
Create var to store location of original wallpaper
change wallpaper to solid black color
set wallpaper to original using var
end
Again, I would greatly appreciate anyone who woulod be kind enough to help. Im sure this would be a very simple thing for someone with experience in DOS/VBS scripting

Thanks!
NNJZ

P.S. Im running Win 7 home prem x64Did you already try a Google?
It seems that it should be easy, but its not. A registry key has to be changed. One reference says the change does not go into effect until the user logs in again.

Why not try ton solve the original problem?
Have you already searched the web SITE for dreamscene?
http://dreamscene.org/
Set wallpaper to a Windows bitmap file (can't use other file types)

(You don't have to use a file called Wallpaper.bmp in the C:\ folder, that is just an example to show the usage.)

Code: [Select]reg add "hkcu\control panel\desktop" /v wallpaper /t REG_SZ /d "C:\Wallpaper.bmp" /f
Set wallpaper to none

Code: [Select]reg add "hkcu\control panel\desktop" /v wallpaper /t REG_SZ /d "" /f
make change happen at once

Code: [Select]RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

Quote from: Salmon Trout on October 28, 2011, 09:58:53 AM

Set wallpaper to a Windows bitmap file (can't use other file types)

I meant you can only set wallpaper to .bmp by this command line method; you can use other image file types via the Windows display settings GUI.
Quote from: Salmon Trout on October 28, 2011, 04:56:03 PM
I meant you can only set wallpaper to .bmp by this command line method; you can use other image file types via the Windows display settings GUI.

Hmm. Then I don't think it would help then, if I can't automatically change the wallpaper back. Being a video file, This wouldn't help much.

Thanks for the help
585.

Solve : imbricated variables?

Answer»

I try to resolve imbricated variables :

set a=temp
set b=%a%

I'd LIKE te resolve something like %%B%% (I use this in a for loop because I have a set different variables)

but ECHO %%B%% just SAYS %a%

I try to PUT this this way

for %%i in (%%B%%) do ( .....

how can DOS solve "a" USING the "b" variable as input ?


a little error

I meant

set b=a
and I'd like to resolve

so %b% = a
and I'd like te resolve %%b%% = %a% = temp

sorry for the error

586.

Solve : The god of dos?

Answer»

you have been norminating by yours truly as the god of dos...godos....i cant see why people are still wasting their time using it...??echo offSorry, not a God!  just an old rusty fart PASSING through.

Actually i haven't used dos much the past 5 yrs.  but I've got a special project going now making a bootable crash recovery-setup cd, which has revitalized my interest in dos.  Interestingly enough I just came across some real mode drivers for USB which I can't wait to try out.  Unfortunately they were written in Japanese.  I may post a link in hopes of finding someone to help me with getting them running.

I'd like to commend you on having an excellent reference section on dos.

scruge Quote

...I just came across some real mode drivers for USB which I can't wait to try out.  Unfortunately they were written in Japanese....


http://www.oldfiles.streamlinetrial.co.uk/powerload/yes.htm

They work, I use them all the time.
usbaspi.sys
di1000dd.sys
fantastic, those are the ones I found from Panasonic.  Whats amazing is I found another set in of all things NTFS.com free ntfsreader.exe  disk..  And just 2 minutes ago I found 2 more sets including 1394 at http://www.opus.co.tt/dave/indexall.htm

Now if I can find a good fat/ntfs dos based file browser I'll be able to put this project to bed. Quote
...Now if I can find a good fat/ntfs dos based file browser I'll be able to put this project to bed...

How about XTree Pro Gold?  Load NTFSDOS and then Xtree.

There's more than one usbaspi around.  The usbaspi on the linked website did not work.  The one that worked for me was this zip file:  mhairu.zip  With a DOS boot disk, it's worked on 4-6 different computers, with my external USB 2.5 notebook drive w/ME-910 case.  Case is combo USB2.0 and Firewire.

Is that the old Central Point software xtree?   I may have that laying around some place.  Does it HANDLE LFNs?  

I'm really fired up now knowing those usb drivers work. That really opens alot of doors.  With hdds getting so cheap now days I'm trying to get away from the frizbies.

Funny you should mention the notebook hdd.. I just bought an usb enclosure for an old 2.5 20gb that had been laying around here for over a year. It really has come in handy on occation. Quote

1.  Is that the old Central Point software xtree?   I may have that laying around some place.  

2.  Does it handle LFNs?  

3.  I just bought an usb enclosure for an old 2.5 20gb that had been laying around here for over a year.


1.  I don't believe it was Central Point, but that's the one.  I think Central Point was PCTools.

2.  No.  16-bit only.  Ever hear of Ztree?  http://www.ztree.com/
I still use Xtree when I boot to DOS.  I keep a copy on all bootable partitions.  It still works.  A good reason to keep all partitions FAT32.

3.  Lots of problems with USB enclosures powered from USB bus.  Sometimes it works, sometimes it won't.  Worked better from Win2k than WinXP.  Drive startup current exceeds Bus spec.  External power supplies are REQUIRED for reliability.  Mine has 5V power plug for PS2.  I'm told, the older 2.5" drives have less of a problem.  Haven't had problem running self-powered from DOS.
1. Boy now we are really dating ourselves.. pctools that really goes back a ways, ah copy2pc

2. I looked at ztree earlier and kept looking because he only had os2 and win. I needed dos.

3. This little enclosure I bought had 2 usb connectors to double up on the power.. so far I haven't had any trouble at all.  However I did notice after going with the xp sp2 downgrade that all my external usb and 1394 drives got a lot slower even though most early reports were that it only effected some 800mbps 1394.  As a result I haven't booted to xp in a couple of months. Fortunately I only applied it to a 3 PCs.. which is one of the main reasons I wanted to get this setup-recovery cd DONE so I could test it when I re-imaged these machines back to sp1.

I'm KIND of stuck with NTFS.  I do a lot of home video editing and the 15-25gb file sizes are a pain with a fat32 drive.  Plus I've got over 1.5tb of video I maintain which is about 120 hours of raw dv.  I'm in the market for a good hardware transcoder dv > mpeg..  I figure theres got to be a good one out there somewhere being the Sony dvd camcorder has been out for sometime now.

Well, you guys keep up the good work and I certainly appreciate all the help.  

scruge Quote
1. ...I did notice after going with the xp sp2 downgrade that all my external usb and 1394 drives got a lot slower... I wanted to get this setup-recovery cd done so I could test it when I re-imaged these machines back to sp1.

I'm kind of stuck with NTFS....


I had a crash on one of my computers.  It was NTFS, when I went to restore, it refused to get all the way through, some kind of NTFS error message.  Never had a problem with FAT32.  I have imaged backup'd to CD-RW's and hard drives.  I've got a parallel to SCSI converter cable and 3 external SCSI drives in a separate powered enclosure (formerly a Bernoulli Box).  Also have an H45 portable powered enclosure (8GB) w/ parallel and PC Card cables.  Parallel port backups run at about the same speed at USB1.1 backups.  I don't backup to CD's anymore.  I can backup an entire bootable partition to a 2GB SCSI drive, and you can walk away and not feed it CD's.
Well, just for the sake of argument , Unless you are never going to be working with legacy systems I think it is important to have a general Knowldge of DOS. I say this because I find myself using it every time I install netware.  Are you the 1086 version or the 1089 version...(book._
587.

Solve : DOS USB Drivers?

Answer»

Computer Commando..

I got a question for you..

I managed to get those drivers from the link you provided, but i can't get any of the parameters to work.
 "/w /v /e"   usbaspi.sys reports they are invalid.   I got these files via the hyperlink text they had setup in the example..   I also tried the Panasonic link they had and found the same files but with different sizes and dates.  Tried those as well.. with no luck.  

So as it stands right now i've got the usbaspi.sys 43,528 and the di1000dd.sys 16,368 working without any options.  I'd like to see if I can't get them running at USB 2 speeds if POSSIBLE.  

Got any ideas?More links:

http://www.bootdisk.com/usb.htm

http://www.computing.net/dos/wwwboard/forum/13845.html

http://www.computing.net/dos/wwwboard/forum/13679.html

http://www.everythingusb.com/

device=USBASPI.SYS /v /w works for me.  My usbaspi is 39kB.  I think mine is the Panasonic.  I never got USB2.0 working.  I was using it for image backups and none of the computers had USB2.0.  I may TRY it again.  This computer (PIII-450) has a USB2.0 PCI add-in card.  Requires going offline and booting to Win98-DOS.

UPDATE:  /e switch works.  Tested in DOS transfer of 270MB file, took 90 sec, therefore, 24 Mbits/sec.  This is speed through USB2.0 add-in card and USB2.0 hub.  Double USB1.1 (12Mbps), but not quite 480Mbps.

You will never see the 480Mbps speed or anywhere near it.
http://www.everythingusb.com/forums/showthread.php?s=&threadid=5324yep theres alot of info out there.  I even found an english translation for the Motto Hairu drivers..

I think what has happened is the instructions and drivers have gotten mixed up..  ex your webpage regarding the usb drivers has the instructions for the 38k usbaspi.sys version but the dl link provides the 43k usbaspi.sys version..  None of the switches "/v /w /e" work with the 43k version..  

I did manage to figure a few things out.. the 43k version will detect a pci usb2 card if you disable your mb's usb first.  Also was able to get the Iomega aspi1394.sys drivers to work with a 1394 pci card.

I'm still testing various configurations. I'll let you know my findings.. If you come across ANYTHING of interest let me know..
Again thanks for the helpI ACTUALLY got an email today from this guy:  http://www.oldfiles.streamlinetrial.co.uk/powerload/yes.htm
I had sent some comments many months ago about his link versions not working for me.

BTW, you were right about Xtree being acquired by Central Point, here's an interesting read:  http://www.jeffreycjohnson.com/http://www.freedos.org/freedos/news/newsitem/149.html

588.

Solve : after quick recover windows me, scanreg wont work?

Answer»

I used quick RESTORE cd and I get a message to SCANREG because my registry is messed up.  When I try to scanreg it will not WORK. does anyone know what to do. Windows will not start in safe MODE either. I tryed to format and I get a message that needed parymeters are missing.  load  a winme boot disk
a:\cd windows enter
c:\scanreg/restore and chose the last good file...THANK YOU SO VERY MUCH/ I AM VERY HAPPY TO FIND THIS SITE  DONNA

589.

Solve : Can you use the Net Send to an IP address over...?

Answer» HEY,
  I am wondering If you can SEND a message, like with NET send or something,  accross the internet to a SPECIFIC IP.  Another thing, this is a REALLY stupid question but I was wondering how you find the IP on a computer.Jack Forrest....To SEE you ip address .......click start / run.....type CMD ans press enter ......when the new window opens ...type ipconfig and enter ......your ip address will be there.

Hope this helps

d65
590.

Solve : alert?

Answer»

i was wondering if it is possible to make a poppup
alert in DOS like the javascript alert
http://www.pageresource.com/jscript/jalert.htm

so that if i WRITE a batch file and onpen an alert will open
is that possible?You can have a batch file DELIVER a text file in response to an error:

if errorlevel 1 type error.txt

If you include the character 07h in the text file you GET a BEEP from the PC speaker.

591.

Solve : Print Image(GIF) files through DOS?

Answer» HI all,

Can any body tell me how can we take the print out of gif (format) files in DOS .

reply asap.

Regards,
ASHWIN Mittal.Do you mean, you want to print a gif (format) file from DOS?  If yes, then my ANSWER is there is no way.Do a google SEARCH. There are some older (DOS only) programs that will allow viewing and printing of .gif images.
592.

Solve : change back to win95?

Answer»

My COMPUTER OPENED in DOS and I don't know the command to GET it to change back to the windows95 desktop.  How do I fix it so that it doesn't open in dos again?winGracias

593.

Solve : Renaming Computer Name using .bat file?

Answer»

Hey Everyone,

I am having a problem RENAMING the Computer Name using a bat file I have worked up.  What this does is goes out and finds the ServiceTag number from the BIOS and puts it into a variable which is suppose to turn around and rename the Computer Name.  It's not working correctly, doesn't rename it. 

Here is what I have so far.

Code: [Select]echo off
setlocal enabledelayedexpansion
set line=1
for /f "delims=" %%A in ('wmic csproduct Get identifyingnumber') do (
if !line! equ 2 set idnumber=%%A
set /a line+=1
)
set idnumber=%idnumber: =%

REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d %idnumber% /f


Any help would be greatly appreciatedAre you running the batch file as an administrator? Simple, but I can't see anything wrong with the code that would cause that.I am.  I thought maybe it needs to be rebooted after the program runs, so I have added a reboot command, but still nothing.  This is being tested on a WINDOWS 7 Pro x64 machine.Alright Everyone,

I have come up with a solution to my .bat file.  I won't use it.  I will use a .vbs file instead.  This only works with computers not joined to a domain.  Works great though.  Here is the code:

Code: [Select]WScript.Echo "Before selecting the OK button, please save any" & _
" documents that need to be saved."

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

For Each objSMBIOS in objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
' The below variable will be used in the next For Each statement.
Dim Name
Name = objSMBIOS.SerialNumber

Next

Set objWMIService = GetObject("Winmgmts:root\cimv2")

' This section renames the computer.
For Each objComputer in _
    objWMIService.InstancesOf("Win32_ComputerSystem")

        Result = objComputer.rename(Name)
        If Result <> 0 Then
           WScript.Echo "Rename failed. Error = " & Err.Number
        Else
           WScript.Echo "Rename successful." & _
               "  Your machine will reboot after clicking the OK button.  Once again, make sure you have saved any documents before clicking OK.  NOTE: IF YOU CLICK THE 'X' AT THE TOP RIGHT CORNER OF THE WINDOW, IT WILL REBOOT THE COMPUTER AS WELL."
        End If

Next
'Reboots the computer.
Set OpSysSet = GetObject("winmgmts:{authenticationlevel=Pkt," _     
& "(Shutdown)}").ExecQuery("select * from Win32_OperatingSystem where "_     
& "Primary=true")
for each OpSys in OpSysSet     
retVal = OpSys.Reboot()
next
Thanks for all your help guys.

594.

Solve : boot partition?

Answer»

I have an old HARDRIVE and i want to use it. I formated it and then used killdisk on it. after that i tried to install windows 98se through DOS. I got a message "cannot create a temporary directory. if you have HPFS or NTFS installed on your hard drive you will need to create an MS-DOS boot partition to setup windows".

Can anyone tell me what it MEANS and what to do?   :-/SORTED Killdisk "Erases partitions, LOGICAL drives and even not used disk space".  Use fdisk to create partitions, then format.You don't have to create an MS-DOS boot partition to install Windows 2000 or Windows XP if you have a bootable CD drive and go into the BIOS to set up your PC to boot the CD drive first.

Then you can have a completely blank hard drive and the Windows installer will partition and format it for you.

595.

Solve : Simple batch-file help?

Answer»

Hello everyone,

I am not much of a PC crack, but today decided to give a batch-file a go.

My goal is the following: every day I boot my PC at work and open the exact same tools in the exact same order. (OUTLOOK, Firefox, Internet Explorer + internal tools)
I wanted to create a batch file that runs the tools in that order.
Since each tool needs quite some time to open, I wanted to add a pause between the different .EXE executions, and this is where I fail.

So far I am at this:

Echo off
echo Goodmorning, have a NICE day.
START /MAX firefox.exe
TYPE NUL | choice /c:delay /td,35>NUL
START /MAX iexplore.exe


What it does is RUNNING Firefox and IE at the exact same time, with no 35 second delay.
I tried some other commands I found, but this SEEMS the closest.

Win XP is the OS btw, in case this matters here.

Thank you very much in advance,
PositivezThe Choice command is not available in XP, suggest you download it.

Thank you very much.
Will see if the system admin allows the installation :/

Cheers!
Positivez

596.

Solve : Startup programs?

Answer»

I would LIKE to know if there is a WAY to startup apps that I use without having to open. For example, once I boot up my system, the apps startup automatically using a batch file. Everytime that I tried just to load them using a batch file, the first app STARTS but waits until it is closed until the next app starts. I want to have them continuously startup without having to close.
ThanksIsn't that what the Startup Folder is for?  If DOS,you can only run 1 program at a time.

597.

Solve : Permissions in Windows 7?

Answer»

Hello all,

I am trying to create a batch file for windows 7 that will essentially change the permissions of a folder from a read-only to full control, execute some commands and then revert the folder BACK to read only. Any ideas???Why do you want to do this?

We are integrating with a company in california, and we are trying to make this as easy as possible for them to setup our software. So we need to modify the hosts file to let them connect to our ip address in order to use the software that we are providing. (its online based) If these ip addresses are not in there they cannot use our programs.So you are operating as a software professional and yet you need to ask on a forum such as this?
No need to be a smart, I am not a software professional, and I never once said I was, I am entry level new guy here who just wanted to bounce off ideas. I am at the bottom of the totem pole given this task. If you don't have anything helpful then just ignore this post and move on.  You can utilize the icacls command in dos to modify permissions in folders.

Try typing icacls /? at the command prompt for some information on the command. You are going to need admin privileges to modify any settings with the icacls command, so you will likely need to coordinate with the IT department in the other organization to help with that.

What you are describing here sounds like a fairly big project, and as far as suggestions go, I would start by suggesting you look into a different PROGRAMMING language than batch for this. There are a few reasons, but I'll give you two big ones up front.

1. Other programming languages offer a lot more flexible and better suited methods of accomplishing tasks. You can try VBScript for one suggestion, but if at all possible, try to steer clear of batch.

2. Batch gives a very... unprofessional feeling. I have seen very few batch files that gave the impression of a professional product. Other programming languages give a more professional look to them, and therefore would be better when you are integrating with another organization where these first impressions are going to determine the interworking relationships for a long time to come.

If, for whatever reason, you must use batch for this, then please let us know.So far, this thread has followed a fairly recognisable pattern:

OP: How can I overcome security settings to perform unspecified operations in an unspecified folder, and get out again, and make it all like it was before?
Me: This is how you do it   [hmmm... EDIT] Why do you want to do this?
OP: I want to get in a system folder and modify a file directly concerned with security. I appear to think that I need to modify the HOSTS file so that a user can connect with an "IP address".
Me: Given the nature of the task you wish to perform, how come you don't know how to do this already? (Implied: How come you don't have admin privileges?)
OP: (Angrily) Don't get smart with me! If you won't help me, get lost!

EDIT: OK, so we now seem to have thrown caution to the winds... (rolls eyes)




I will look to alternate programming solutions......

Quote from: Raven19528 on October 26, 2011, 12:52:10 PM

You can utilize the icacls command in dos to modify permissions in folders.

Try typing icacls /? at the command prompt for some information on the command. You are going to need admin privileges to modify any settings with the icacls command, so you will likely need to coordinate with the IT department in the other organization to help with that.

What you are describing here sounds like a fairly big project, and as far as suggestions go, I would start by suggesting you look into a different programming language than batch for this. There are a few reasons, but I'll give you two big ones up front.

1. Other programming languages offer a lot more flexible and better suited methods of accomplishing tasks. You can try VBScript for one suggestion, but if at all possible, try to steer clear of batch.

2. Batch gives a very... unprofessional feeling. I have seen very few batch files that gave the impression of a professional product. Other programming languages give a more professional look to them, and therefore would be better when you are integrating with another organization where these first impressions are going to determine the interworking relationships for a long time to come.

If, for whatever reason, you must use batch for this, then please let us know.

Thats the problem they dont have IT over there they have consultants and they pretty much dont want to do anything just click click and thats all. If it were me I would have canned them but I have to make due with what I am given. Now this is sort of what I got its rough but.......

echo off
 
REM Used to create a backup of the original host file and copy in the new one
 
icacls C:\Windows\System32\drivers\etc\ /t /e /g users:F
 
REM Creating a backup of the original host file
ren C:\Windows\System32\drivers\etc\hosts hostsbk
 
REM Used on a XP machine
xcopy "%USERPROFILE%\Desktop\Test\hosts" C:\Windows\System32\drivers\etc\ /y
 
REM Used on a Windows 7 machine
xcopy "%USERPROFILE%\Desktop\Test\hosts" C:\Windows\System32\drivers\etc\ /y
 
Pause


Quote from: Salmon Trout on October 26, 2011, 12:52:34 PM
I appear to think that I need to modify the HOSTS file so that a user can connect with an "IP address".

Okay, I think I need to understand a little better as to the reasoning behind this exact question. Why are you needing to modify the HOSTS file for an IP install?

Wouldn't the entire process be much easier if you were to create a program that downloaded the install file from the IP address and then ran the program as an administrator? My whole problem is that the whole situation just sounds... not right. If the consultants are all using company IT, there should be SOMEONE who has admin access to those machines. Or all of them do. Either way, modifying the HOSTS file seems a little too extreme of a security bypass to be taking for something that the other company should be willing to work with you on. Find out who has admin access, see if they can grant you an admin account to utilize on the computers, and then we can help you design a simple batch process to download and install the program. Quote from: Raven19528 on October 26, 2011, 01:33:26 PM
My whole problem is that the whole situation just sounds... not right.

So I'm not the only one. Like I said, a recognisable pattern. This is just the sort of social-engineering method that would-be hackers use to get GEEKS to write their scripts for them. Or lazy employees use to get geeks to do their jobs for them. Or genuinely puzzled technically ignorant people trying to get a legitimate task performed. The trouble is, we can't tell which it is.



The program we use is online based or I guess can only be runned if on our network, it has a specific ip address but because of security here not anyone can access it unless their host file is given that particular IP address.

But nevermind I got it to work. Thanks Quote from: Raven19528 on October 26, 2011, 12:52:10 PM
2. Batch gives a very... unprofessional feeling. I have seen very few batch files that gave the impression of a professional product. Other programming languages give a more professional look to them, and therefore would be better when you are integrating with another organization where these first impressions are going to determine the interworking relationships for a long time to come.

Powershell definitely looks more professional... those curly brackets are really impressive.
Quote from: Salmon Trout on October 26, 2011, 01:47:02 PM
those curly brackets are really impressive.

I KNOW!! RIGHT!?!  Raven...think before you leap...

I tend to side with Salmon on this one for sure...If software needs a modified HOSTS file to RUN, something is badly wrong.
598.

Solve : eject D:\?

Answer»

hello again.
i was WONDERING if there is a dos command to eject d:\
as in lets prtend its "eject D:\"(just as an example)
so according to the example then if i was on my COMPUTER and i typed

eject D:\

into dos than it would open the cd drive aka "eject the DISK in it D:\"

Does such a command exist?
and if so can you eject A:\ with dos?
thank you for anyone who can help me.http://www.phdcc.com/eject-cd/default.htm with a FLOPPY drive i dont think you can use an eject f/d command because its a different kind of setup..

599.

Solve : PCI Configuration Failure!!?

Answer»
My neighbour gave me an old computer which they were having problems with. When I use my startup disk for win98se it comes back with an error message: PCI CONFIGURATION FAILURE. The Cdrom stops running when I try to install the win98se. This kept happening so I bought a REALLY Cheap new HARD disk for this old 486 Compaq Pessario! I think it has something to do with the cdrom drivers I don't KNOW how to save/copy etc. them to the c drive HELP!! PLEASE. I have TRIED everything!

Would love to save this one!! Even if just for my 4 kids to play paint on!!I had the same PROBLEM with a Pentium 1-60.  Your 486 dates to around 1990-1992.  Hardware was changing every couple months.  PCIBus was just beginning and was not in it's 1st generation configuration.  There are no PCI slots in your computer and the CDROM does not plug into the motherboard, it connects to an ISA card.  ISA is the bus (card slots) used at the time.  You need the manufacturer's startup disks.  Because it's Compaq (now owned by HP), you may have a slim chance of locating these.

Even if you can get Win98 to load and run, it will be extremely slow.  Minimum hardware requirements are:  http://support.microsoft.com/default.aspx?scid=kb;en-us;182751

600.

Solve : Batch command to log on to a mac?

Answer»

I have a batch file that xcopies data across my home LAN from one hard drive to another for back up purposes.  It works fine between the PCs, but the addition of a Mac recently is CAUSING me a problem.  It is probaly not because its a Mac but Apple insist on shared drives being password protected.  So from time to time the Mac insists on a username and password.  If I LOG in from Windows giving the password and then run the batch file it works.  If I just run the batch file sometimes it FAILS because it cannot cope with the login need.  Can I add a line to the batch file that connects me to the Mac either every time or when needed?  I have scoured through various permutaions of 'net USE' and 'net logon' to no avail.  Any suggestions gratefully received.