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.

8851.

Solve : Multi Open Folder in a Local Area Network?

Answer» MULTI Open folder.
What can I use to open a folder in one of my pc :

Example :

c:\folder1\folder2

and the rest of my pc in the local area network ?

By example

c:\folder1\folder2

\\pm-7fg7fjkl432a\folder1\folder2
\\jose-a0555092b\folder1\folder2

where pm-7fg7fjkl432a is the equipment NAME.

Best Regards


A sort of a rules folder launcher.
May be with possible selection of several rules pre-established

I usually have the same folders in my three pc, but not all folders.

I would like to get a initial folder selection. I can INTRODUCE in the batch file the name of the COMPUTERS in the local area network
And the program search and open the folders with the same name and path in the LAN.

Trying to figure out what you want to do... what about mapping the path to a drive letter such as

\\pm-7fg7fjkl432a\folder1\folder2 mapped as say Y:\>
\\jose-a0555092b\folder1\folder2 mapped as say Z:\>

You then would be able to go to specific system by drive letter.It's a splendid idea.

Best Regards

8852.

Solve : batch file wont back to prompt?

Answer»

hi there
'
cd\
cd windows
and there is no WAIT for type commands such as dir , copy , ...
its end immediately-i want BATCH file wait for my commands-
can i do this?
by the way thankuopen a command window:
start|run
then type CMD and either press return or click OK
If you are running a batch file from Windows Explorer by double CLICKING it, it will just vanish when it has completed all the commands. It sounds like what you want is a command prompt window, so do what gpl said.
add cmd at end

8853.

Solve : administrative level command prompt?

Answer»

HI,
My internet explorer8 runs slow,Ive read that opening up the ADMINISTRATIVE level command prompt and typing regsvr32actprxy.dll then pressing enter will work, I did type cmd in run window but I didn't see enter. How do I open the administrative level command prompt??This "tweak" can only be done in Vista and Windows 7.

QUOTE from: hollymwebster on July 20, 2011, 10:20:38 AM

How do I open the administrative level command prompt?

Type cmd in the Start menu Search BOX, right-click the Cmd.exe shortcut, and then choose Run As Administrator.

Quote from: hollymwebster on July 20, 2011, 10:20:38 AM
typing regsvr32actprxy.dll

1. You need a space between regscr32 and actprxy.dll like this regsvr32 actxprxy.dll

2. It probably won't do anything.

Quote from: hollymwebster on July 20, 2011, 10:20:38 AM
I didn't see enter.

This is Enter. You press it with your finger.


open start and type cmd and press CTRL+SHIFT+ENTER
8854.

Solve : how to install dos using bios??

Answer»

hey ,i REALLY need some help here..., i dont know how to install this ms-dos os. i've downloaded ms-dos 6.2 or something & i've burned it into a CD.. what next?It must be an illegal copy since MS-DOS only comes legally on floppy disks. No help with piracy.
to install a os from a compact disk go into the bios and set your cd-rom drive to boot FIRST, insert disk and restart and follow prompts, NOTE: i dont think ms-dos can be installed from a cdQuote from: a117yogi on June 03, 2011, 01:29:29 PM

to install a os from a compact disk go into the bios and set your cd-rom drive to boot first, insert disk and restart and follow prompts, NOTE: i dont think ms-dos can be installed from a cd
If you have a legal copy of MS-DOS, it must be installed to a SMALL drive that has a format compatible with that version of DOS. And the drive must be the active drive.
Hard to give more SPECIFIC instructions without knowing your system details. But way would you want to install DOS 6.22 anyway? Topic Closed.
8855.

Solve : MS-DOS 6.2 Step-up Files?

Answer»

An older MS-DOS computer can step up to MS-DOS 6.2 free.
Quote

MS-DOS 6.2 Step-up FILES - Download.com
# Quick specs
# Version: 1
# Date added: August 24, 2007
# Price: Free
# Operating system:
# Total Downloads: 22,447
# Downloads last week: 78
Read more: MS-DOS 6.2 Step-up Files - Free software downloads and software reviews - CNET Downloads http://download.cnet.com/MS-DOS-6-2-Step-up-Files/3000-2072_4-10729964.html#ixzz1OGpgb038
The above was quoted today. Apparently 78 people last week did the download. No explanation of why they would do this.
Is it legal? On y if you have a computer.
No, it's totally illegal, Microsoft is trying to trick people by putting this up.Quote from: BC_Programmer on June 03, 2011, 09:03:36 PM
No, it's totally illegal, Microsoft is trying to trick people by putting this up.
It's a conspiracy Quote from: Geek-9pm on June 03, 2011, 08:36:59 PM
An older MS-DOS computer can step up to MS-DOS 6.2 free.

Not QUITE. It's 6.22 (the last MS-DOS) that they can step up to. And only from a lower version 6.xx. That is, to use the MS-DOS 6.22 Step-Up, your computer MUST be running MS-DOS 6, 6.2, or 6.21. (I told you this about 2 weeks ago.) It's been available since at least 1999. Don't get the Step-Up confused with MS-DOS 6.x upgrade for older VERSIONS of MS-DOS (3.0 to 5.0) which you had to pay for.

Quote
No explanation of why they would do this.

None needed. They have MS-DOS 6, 6.2 or 6.21 installed and they want to update as much as they can.

Quote
Is it legal? On y if you have a computer.

I don't really see the point of these remarks. Is this some kind of running joke?

You do realise that this isn't a complete MS-DOS install set? You may as well think of it as a "Service Pack" for the versions of MS-DOS 6 before 6.22.




8856.

Solve : How do you add line breaks when writing to a notepad file??

Answer»

How do you add LINE BREAKS when using DOS to write to a text document?

Example:

echo blahblah blah > test.txt
(Insert line break here)
echo blahblah > test.txtCode: [Select]echo blahblah blah > test.txt
REM (Insert line break here)
echo blahblah >> test.txt

Code: [Select]echo. >>text.txt
Quote from: Geek-9pm on July 24, 2011, 05:46:18 PM

Code: [Select]whatever

rolls eyes
8857.

Solve : How do you add several requirments to one "if" command??

Answer»

I couldn't find the right way to say this, but:

if %var%==(several variables here)

so like:

if %var%==a,b,c,d,e,F,g

I just don't know how you would put it.

Thanks.You can nest the if statements.
1. In Batch nested nIFs are used often.
2. You and use the AND operator.
3. You can aggregate results.
(pseudo code)
set got to zero
if var is a bump got
if var is b bump got
if var is c bump got
if got is 3 say 'got all'
If got is 0 say 'got nada'

But I don't think that is what you want.

Do you want a CASE block? It is not native to batch files.
(pseudo code)
CASE BEGIN
var = a goto isa
var = b goto isb
var = c goto isc
END CASE

You would have more tools in a script language like Vb script.
Code: [Select] Select Case testexpression
[Case expressionlist-n
[statements-n]] . . .
[Case Else
[elsestatements-n]]
End Select
I'm sort of new, but really I just want to be ABLE to have several possibilities on one "if" COMMAND.

I'm sorry if that doesn't make sense.

So like:

on "if %var%==1,2,3,4,5"

if either 1 through 5 is entered, it will execute a command

but is that the correct format for the command, or do I have to use an "and" command?

if so, Can I have some examples?




Thanks a bunch. AS has been said, batch does not have a multiple - If command, nor a CASE STATEMENT. You have to get crafty.

If a,b,c,d,e are consecutive numbers e.g. 1 to 5 then you can do this

if %var% GTR 0 (
if %var% LSS 6 (
goto pass
)
)
echo Bad value!
goto end

:pass
echo Good value!
:end

Otherwise you must test for the values individually


if "%var%"=="a" goto pass
if "%var%"=="b" goto pass
if "%var%"=="c" goto pass
if "%var%"=="d" goto pass
if "%var%"=="e" goto pass
echo Bad value!
goto end

:pass
echo Good value!
:end

Or you could use some FOR loop trickery but I won't put that here. Bill's around!


8858.

Solve : move the files from one folder to another in VSS using MS-DOS commands?

Answer»

Hi,

move the files from one folder to another in VSS using MS-DOS commands

For Ex, I have file in the path in VSS $/BaseReleasesFolder/subfolder/ASP coder/test.asp file to $/BaseReleasesFolder/subfolder/C# coder path folder, in this how to cove the Test.asp file to the other folder.

Appriciate your SUPPORT,

Thanks,
DIVAKAR. Are you trying to CREATE a batch file, or a VSS whatever?
'Cause in a batch file, you WOULD use the move command.
Look here: MS-DOS Move Commandhttp://msdn.microsoft.com/en-us/library/asxkfzy4%28v=vs.80%29.aspx

8859.

Solve : Batch script for every file found in a given directory.?

Answer»

Hello guys,

I have a KODAK Zi8 pocket CAMCORDER and i'm using a command line tool ffmpeg to remux the mov files to mp4, this works LIKE it should but i'm trying to automate the proces for all *.mov files found in a given directory.

At this moment i'm using:

CODE: [Select]@echo off
ffmpeg -y -i %1.mov -acodec copy -vcodec copy %1.mp4
I have to use this for all my mov files. How can I adjust the script so that it scans a given directory for mov files and RUNS the ffmpeg tool on each of them automatically?

Many thanksCode: [Select]for /f "delims=" %%A in ('dir /b *.mov') do ffmpeg -y -i "%%~dpnxA" -acodec copy -vcodec copy "%%~dpnA.mp4"Many thanks!

This seems to be working as it should!

8860.

Solve : File Rename?

Answer»

Hi All,
I need to rename over 200 files. Right now they are named LLLL1.YYYYMMDD they need to end up with not changing the date STAMP at the end but only changing the front part so LLLL1.20100807 would end up being V0116.20100807 and the NEXT would be V0116.20100808....etc.

Any help doing this would be great.

Thanks

Hi All,
I found a free download that can rename files and was easy to run. I am all set.

Thanks
OK...

Don't tell us what it was...

You are right Patio. I should have posted a link or something about it.

http://www.bulkrenameutility.co.uk/Main_Intro.php

It looks like a pain to learn but comes with a ok help file. I was able to download it and rename about 250 files in under 10 mins.

And its for free!


Nice...
And i wasn't pickin on you Spoiler... Poetry... Stan MANN... evading a ban! GOODBYE Bill.





this should work:

ren LLLL1.* V0116.*More poetry: Spoil Name, you're banned! For shame! So long, Bill.


8861.

Solve : Problem with script to replace substrings in file, *censored* truncating!?

Answer»

Hi, so I have created a batch file to replace each occurence of the SUBSTRING "sid" in a reg file with the usersid.
The only problem is some of the DATA gets truncated.
Consider this batch file:

@echo off
;Get sid from file
set /p usersid=
SETLOCAL DISABLEDELAYEDEXPANSION
FOR /F %%L IN (sandboxie.reg) DO (
SET "line=%%L"
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO !line:sid=%usersid%!>>out.reg
ENDLOCAL
)
ENDLOCAL


out.reg:

[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\*\shell\sandbox]
"Icon"="\"C:\\Program
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\*\shell\sandbox\command]
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\*\shell\sandbox\command]
@="\"C:\\Program
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder]
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell]
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox]
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox]
@="Run
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox]
"Icon"="\"C:\\Program
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox\command]
[HKEY_USERS\S-1-5-21-789336058-1580436667-515967899-500_Classes\Folder\shell\sandbox\command]
@="\"C:\\Program

sandboxie.reg:

[HKEY_USERS\sid_Classes\*\shell\sandbox\command]
@="\"C:\\Program Files\\Sandboxie\\Start.exe\" /box:__ask__ \"%1\" %*"

[HKEY_USERS\sid_Classes\Folder]

[HKEY_USERS\sid_Classes\Folder\shell]

[HKEY_USERS\sid_Classes\Folder\shell\sandbox]

[HKEY_USERS\sid_Classes\Folder\shell\sandbox]
@="Run &Sandboxed"

[HKEY_USERS\sid_Classes\Folder\shell\sandbox]
"Icon"="\"C:\\Program Files\\Sandboxie\\Start.exe\""

[HKEY_USERS\sid_Classes\Folder\shell\sandbox\command]

[HKEY_USERS\sid_Classes\Folder\shell\sandbox\command]
@="\"C:\\Program Files\\Sandboxie\\Start.exe\" /box:__ask__ Explorer.exe \"%1\""


As you can see, the string: @="\"C:\\Program Files\\Sandboxie\\Start.exe\" /box:__ask__ Explorer.exe \"%1\""
gets truncated to: @="\"C:\\Program
in out.reg

How do I fix the script to get proper output?Same truncation will OCCUR on any line containing a space.

Space is one of the default delimiters in a For loop so as soon as the space after Program is encountered that's the end of the line.

Suggest you use For /f "tokens=*" .....etc so that the text line is TREATED as one and not delimited.

Welcome to the CH forums & hope this helps.Appreciate! That worked Thanks for coming back to REPORT your success..

8862.

Solve : ANSI esc Code help. Input on bottom, output on top.?

Answer»

I am modding my MS-DOS 7.10 prompt to look like the colsoles in Fallout 3, the RobCo Unified Operating System. The input is on the bottom, and the OUTPUT in in the middle, after the standard watermark thingy. This is what I have in autoexec.bat.
Code: [Select]PROMPT $e[=3l$e[25;1H$e[0;32;40m$gWhen I enter a command, the output goes to the bottom, the page refreshes, and the output dissapears. I want the output to go to the top. How?
All answers appreciated.
Quote

All answers appreciated.
Sorry, I don't know.
- However,
In the search box on the upper right, TYPE in ANSI and click the search bottom. This site has a collection of over 100 articles or threads on the use of ANSI for MAKING special console layouts or in in DOS. Including color, TEXT size and EVEN graphics.
Like This...
Also, have you looked over this resource?
http://en.wikipedia.org/wiki/ANSI_escape_code

Is this for some kind of presentation or prototype?Well, I have figured out my problem. When the prompt refreshes, it clears the screen with the $e[3l. I have removed that and it's working fine. And I had already read almost all documentation on ANSI. I was refered by another person on Tom's Hardware.
8863.

Solve : create an exact copy with date in batch file?

Answer»

Hi,

I have a question and try to make it simple. I want to create a batch for backup purposes.

The source is C:\Data

The destination is E:\

I'd like to create a directory called Data in E drive with the date next to it, for example Data 20 September 2011. The format of the date does not really matter.

So far I have got the following
@ECHO off
robocopy "C:\Data" "E:\..." /MIR
pause

I want to be able to make another exact copy of the folder "Data" and call it "Data" with date attached to it.

Any help would be greatly appreciated.

Thank youuse %date% variable wherever you want

robocopy "C:\Data" "E:\Data%date%\" /MIR

should work, if not its something like thatQuote from: a117yogi on June 03, 2011, 02:01:04 PM

use %date% variable wherever you want

This is nonsense if %date% contains slashes. Like "03/06/2011". Which is what %date% says here.

Quote
should work, if not its something like that

Please do not post wild guesses. Or "something like that". Just tested solutions. Ones that work.
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do robocopy "C:\Data" "E:\data-%%e-%%f-%%g" /MIR

better?Quote from: a117yogi on June 03, 2011, 03:32:24 PM
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do robocopy "C:\Data" "E:\data-%%e-%%f-%%g" /MIR

better?

OK, but why don't you address the issue of differing local date formats?
This getdate batch comes in handy to determine the date fields without having to read the REGISTRY:
Here is my version of GetDate.bat. I've tried it in all the 'English' date formats in XP, Vista, Win7.
If you pass the name of an environment variable ( no %'s in the argument) it will get set to the current date.
yyyymmdd is returned in the errorlevel as a number but it can be used as %ymd% for an 8 digit date with no separaters.

Code: [Select]@echo off&SetLocal EnableDelayedExpansion&goto :start
:GetDate.bat [EnVar]
echo.GetDate [EnVar] Sets date into environment variable, EnVar as: mm-dd-yyyy
echo.Usage: GetDate mdy^&set ymd=%%errorlevel%%, ^(use %% rather than ^^! in command line)
echo.Usage: GetDate mdy^&set ymd=^^!errorlevel^^!, ^(use ^^! rather than %% in script^)
echo.If no argument passed it echo's the date in mm-dd-yyyy format
echo.Returns yyyymmdd in errorlevel regardless if Envar is passed as argument or not
echo.Works on any NT/2K/XP/Vista/Win7 machine independent of regional date settings
EndLocal&exit /b
:start
set p1=%~1&if /i !p1! equ /? goto :GetDate
for /f "tokens=1-4 delims=/-. " %%a in ("%date%") do call :s_fixdate %%a %%b %%c %%d
if /i 1%yy% lss 20 set "yy=0%yy%"
if /i %yy% lss 80 (set yy=20%yy%) else (if %yy% lss 100 set yy=19%yy%)
if defined p1 EndLocal&call set "%~1=%mm%-%dd%-%yy%"&exit /b %yy%%mm%%dd%
EndLocal&echo.%mm%-%dd%-%yy%&exit /b %yy%%mm%%dd%

:s_fixdate
if /i "%1:~0,1%" gtr "9" shift
for /f "skip=1 tokens=2-4 delims=(-)" %%e in ('date^<nul') do (
set %%e=%1&set %%f=%2&set %%g=%3
)
exit /b

I have some other groovy command line and script friendly date and date math routines if anyone is interested.

carlsomoQuote from: Salmon Trout on June 03, 2011, 05:02:54 PM
OK, but why don't you address the issue of differing local date formats?

he said format is not a problem, read first postQuote from: a117yogi on June 04, 2011, 08:48:55 PM
he said format is not a problem, read first post

I'm talking about your "solution" which does not work for every local date format.Here is the updated solution to get the current date set in mm-dd-yyyy
This is a batch file that does not have to read the registry
if you pass a variable name as argument it gets set to the date in mm-dd-yyyy
errorlevel is set to yyyymmdd

It can now handle the 05-Jun-11 format with minor modifications to what i posted prior.

Code: [Select]@echo off&SetLocal EnableDelayedExpansion&goto :start
:GetDate [EnVar]
echo.GetDate [EnVar] Sets date into environment variable, EnVar as: mm-dd-yyyy
echo.Usage: GetDate mdy^&set ymd=%%errorlevel%%, ^(use %% rather than ^^! in command line)
echo.Usage: GetDate mdy^&set ymd=^^!errorlevel^^!, ^(use ^^! rather than %% in script^)
echo.If no argument passed it echo's the date in mm-dd-yyyy format
echo.Returns yyyymmdd in errorlevel regardless if Envar is passed as argument or not
echo.Works on NT/2K/XP/Vista/Win7 machines independent of most regional date settings
EndLocal&exit /b
:start
set p1=%~1&if /i !p1! equ /? goto :GetDate
for /f "tokens=1-4 delims=/-. " %%a in ("%date%") do call :s_fixdate %%a %%b %%c %%d
if /i 1%yy% lss 20 set "yy=0%yy%"
if /i %yy% lss 80 (set yy=20%yy%) else (if %yy% lss 100 set yy=19%yy%)
if defined p1 EndLocal&call set "%~1=%mm%-%dd%-%yy%"&exit /b %yy%%mm%%dd%
EndLocal&echo.%mm%-%dd%-%yy%&exit /b %yy%%mm%%dd%

:s_fixdate
if /i "%1:~0,1%" gtr "9" shift
for /f "skip=1 tokens=2-4 delims=(-)" %%e in ('date^<nul') do (
set %%e=%1&set %%f=%2&set %%g=%3
)
if /i "%mm:~0,1%" gtr "9" call :month_convert mm
exit /b

:month_convert
SetLocal
set "months=Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
call set "month=%%%~1%%"
for /l %%a in (1,1,12) do (
set/a mon=%%a
call :month_assign !mon!
if /i !errorlevel! equ 0 (
if /i 1!mon! lss 20 set "mon=0!mon!"
goto :out
)
)
:out
EndLocal&call set "%~1=%mon%"&exit /b

:month_assign mnum
set/a mnum=%~1
for /f "tokens=%mnum%" %%m in ("%months%") do if /i %month% equ %%m exit /b 0
exit /b 1
Quote
@echo off&SetLocal EnableDelayedExpansion&goto :start
:GetDate [EnVar]
echo.GetDate [EnVar] Sets date into environment variable, EnVar as: mm-dd-yyyy
echo.Usage: GetDate mdy^&set ymd=%%errorlevel%%, ^(use %% rather than ^^! in command line)
echo.Usage: GetDate mdy^&set ymd=^^!errorlevel^^!, ^(use ^^! rather than %% in script^)
echo.If no argument passed it echo's the date in mm-dd-yyyy format
echo.Returns yyyymmdd in errorlevel regardless if Envar is passed as argument or not
echo.Works on NT/2K/XP/Vista/Win7 machines independent of most regional date settings
EndLocal&exit /b
:start
set p1=%~1&if /i !p1! equ /? goto :GetDate
for /f "tokens=1-4 delims=/-. " %%a in ("%date%") do call :s_fixdate %%a %%b %%c %%d
if /i 1%yy% lss 20 set "yy=0%yy%"
if /i %yy% lss 80 (set yy=20%yy%) else (if %yy% lss 100 set yy=19%yy%)
if defined p1 EndLocal&call set "%~1=%mm%-%dd%-%yy%"&exit /b %yy%%mm%%dd%
EndLocal&echo.%mm%-%dd%-%yy%&exit /b %yy%%mm%%dd%

:s_fixdate
if /i "%1:~0,1%" gtr "9" shift
for /f "skip=1 tokens=2-4 delims=(-)" %%e in ('date^<nul') do (
set %%e=%1&set %%f=%2&set %%g=%3
)
if /i "%mm:~0,1%" gtr "9" call :month_convert mm
exit /b

:month_convert
SetLocal
set "months=Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
call set "month=%%%~1%%"
for /l %%a in (1,1,12) do (
set/a mon=%%a
call :month_assign !mon!
if /i !errorlevel! equ 0 (
if /i 1!mon! lss 20 set "mon=0!mon!"
goto :out
)
)
:out
EndLocal&call set "%~1=%mon%"&exit /b

:month_assign mnum
set/a mnum=%~1
for /f "tokens=%mnum%" %%m in ("%months%") do if /i %month% equ %%m exit /b 0
exit /b 1

Zowie! There is enough code here to launch a space shuttle.

I was able to clean up the code and run it, but I'm unsure of my results or what to do with them. The code set an environmental variable with todays date (mm-dd-yyyy). With all due respect, can't this be done by parsing the %date% variable?

Quote
This getdate batch comes in handy to determine the date fields without having to read the registry:

Why not use the registry? The registry serves as a database for all the system settings, so why not go the source for this information?

The founder of KISS University must be spinning in his grave. Quote from: Sidewinder on June 06, 2011, 08:18:02 AM
Why not use the registry? The registry serves as a database for all the system settings, so why not go the source for this information?

You mean like this?

Code: [Select]for /f "skip=2 tokens=3 delims= " %%A in ('reg query "HKEY_USERS\.DEFAULT\Control Panel\International" /v sShortDate') do echo %%A
Quote
The founder of KISS University must be spinning in his grave.

But his alumni are still around...

I was at the Advanced Studies School of that University, but I never abbreviate it.

The above line returns this here in the UK:

Code: [Select]dd/MM/yyyy
Lots of other goodies... sCurrency, sLanguage, sTimeFormat, etcthe registry related satement:
Code: [Select]for /f "skip=2 tokens=3 delims= " %%A in ('reg query "HKEY_USERS\.DEFAULT\Control Panel\International" /v sShortDate') do echo %%A
certainly gives you M/d/yyyy or whatever format but let's say you wish to create 'yyyymmdd.filename.jpg'
one still has to assign date variables once the format is known. Thus there is more code work to do.

In the end I can put this in a script:
Code: [Select]call getdate today_mdy&set today_ymd=!errorlevel!
ren "filename.ext" "%today_ymd%.filename.ext"
echo "filename.ext" was renamed to" %today_ymd%.filename.ext" on %today_mdy%>>file_rename.log

this statement:
Code: [Select]for /f "skip=1 tokens=2-4 delims=(-)" %%e in ('date^<nul') do set %%e=%1&set %%f=%2&set %%g=%3
where %1 thru %4 came from parsing %date% in whatever format the user has on their machine
makes the assignments in all of the formats, excluding "Mon 06/06/2011" (and/11) and "06-Jun-2011"
ie. mm=06 dd=06 and yy=2011 (or 11) regardless of MM/dd/yyyy, yy/MM/dd, or yyyy/MM/dd
The 'shift' containing statement strips "Mon 06/06/2011" to "06/06/2011" in the M/d/yyyy and M/d/yy formats prior to the for loop. The 'if' statement following and the called code below it is necessary to change 'Jun' to '06' (and not '6')

Since I am an admin I don't have a problem accessing the registry but limitted users may not in all cases.
I was aware of the registry keys holding the date format but I decided to avoid it and I don't think that lengthened the overall code by much and the desired result pops out in less than a second (0.24 on my machine).

I posted here because I had already written the batch code (that I use all the time) and I wished to help the fellow who made the original post. Then Salmon rightly pointed out the "06-Jun-2011" format wasn't covered so I covered it for completeness sake.

Now I can run date related batch code on mutliple machines with differing operating systems and obtain the date (in the formats I use) without worrying about the regional setting or user preference on any given machine.

Now it's my turn.... Please shorten the routine using registry keys or whatever to return the date in two USEFUL formats. My goal at the outset was not to write the shortest code possible but to get the job done as I have had routines blow up when running into differing formats everywhere I go.

Respectfully, CarlAn alternative to using sShortdate would be using iDate and sDate in the HKCU\Control Panel\International registry key. The iDate defines three values and three date formats (0=mm/dd/yy, 1=dd/mm/yy, and 2=yy/mm/dd). The sDate value defines the separator which can be used as the delimeter in a for statement.

The only roadblock is that some machines display the day of week with the date command. This can be determined by using a regular expression in the findstr command.

Code: [Select]for /f "skip=2 tokens=3" %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v iDate') do (
set idate=%%a
)

for /f "skip=2 tokens=3" %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sDate') do (
set sdate=%%a
)

:: If first CHARACTER of date is alpha, presume DOW
::
echo %date:~0,1% | findstr /r "[A-Z]" > nul

if errorlevel 1 (
for /f "tokens=1-3* delims=%sdate% " %%a in ('date /t') do (
if %idate%==0 (set year=%%c & set month=%%a & set day=%%b)
if %idate%==1 (set year=%%c & set month=%%b & set day=%%a)
if %idate%==2 (set year=%%a & set month=%%b & set day=%%c)
)
) else (
for /f "tokens=1-4* delims=%sdate% " %%a in ('date /t') do (
if %idate%==0 (set year=%%d & set month=%%b & set day=%%c)
if %idate%==1 (set year=%%d & set month=%%c & set day=%%b)
if %idate%==2 (set year=%%b & set month=%%c & set day=%%d)
)
)

Once the date components (month, day, year) are isolated, it should be childs play to format them any which way.

Just a thought. VBScript hybrid...

Code: [Select]@echo off
echo Wscript.echo eval(WScript.Arguments(0))>evaluate.vbs
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "FormatDateTime(Now, 0)"') do echo FormatDateTime(Now, 0) %%A
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "FormatDateTime(Now, 1)"') do echo FormatDateTime(Now, 1) %%A
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "FormatDateTime(Now, 2)"') do echo FormatDateTime(Now, 2) %%A
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "FormatDateTime(Now, 3)"') do echo FormatDateTime(Now, 3) %%A
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "FormatDateTime(Now, 4)"') do echo FormatDateTime(Now, 4) %%A
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "Year (Date)"') do echo Year(Date) %%A
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "Month(Date)"') do if %%A lss 10 (
echo Month^(Date^) 0%%A
) else (
echo Month^(Date^) %%A
)
for /f "delims=" %%A in ('cscript //nologo evaluate.vbs "Day (Date)"') do if %%A lss 10 (
echo Day^(Date^) 0%%A
) else (
echo Day^(Date^) %%A
)
Code: [Select]FormatDateTime(Now, 0) 07/06/2011 08:20:15 PM
FormatDateTime(Now, 1) 07 June 2011
FormatDateTime(Now, 2) 07/06/2011
FormatDateTime(Now, 3) 08:20:16 PM
FormatDateTime(Now, 4) 20:20
Year(Date) 2011
Month(Date) 06
Day(Date) 07Thank you for the informative response. I've noticed that you give a lot of your time to help share your knowledge and respond to querries and conundrums. I wish more people had that attitude.
8864.

Solve : Batch file: find and delete?

Answer»

Hi, I need to WRITE a batch FILE that READS a txt file that contains a number of file PATHS, then it should remove the chosen string from each line and copy into a new file e.g.

List.txt contains:-
C:\Projects\file1.txt
C:\Projects\file2.c
etc...

New_list.txt contains:-
file1.txt
file2.c
etc...

I apologize if this question has been answered before, I've tried looking at some code for find/replace but I could not follow it.
Any help will be greatly appreciated.
Thank you
If you just want to isolate the filename and extension from a string which represents the full path you can use FOR with the ~n and ~x modifiers.

Code: [Select]If exist New_list.txt del New_list.txt
for /f "delims=" %%A in (list.txt) do @echo %%~nxA >>New_list.txtThank you for the response, I need to keep certain subfolders ALONG with the filename and extension. I also need to specify the string to remove but it will be the same string throughout the file e.g.

C:\Users\Projects\Monday\file1.txt -->Monday\file1.txt
C:\Users\Projects\Monday\Last\New\file2.c --> Monday\Last\New\file2.c

or

H:\Projects\Monday\file1.txt -->Monday\file1.txt


You can read in each file path and name in turn using FOR and then use the replace in string function to remove the unwanted part of the string.

Code: [Select]@echo off
setlocal enabledelayedexpansion
set RemoveString=C:\Users\Projects\

echo %RemoveString%Cat.txt > list.txt
echo %RemoveString%Dog.txt >> list.txt
echo %RemoveString%Hat.txt >> list.txt
echo %RemoveString%Cow.txt >> list.txt

echo String to remove: %RemoveString%
echo.

echo Input file:
type list.txt
echo.

If exist New_list.txt del New_list.txt
for /f "delims=" %%A in (list.txt) do (
set inputline=%%A
set outputline=!inputline:%RemoveString%=!
echo !outputline! >> New_list.txt
)

echo Output file:
type New_list.txt
echo.
Output

Code: [Select]String to remove: C:\Users\Projects\

Input file:
C:\Users\Projects\Cat.txt
C:\Users\Projects\Dog.txt
C:\Users\Projects\Hat.txt
C:\Users\Projects\Cow.txt

Output file:
Cat.txt
Dog.txt
Hat.txt
Cow.txtThat's Perfect, Thank you

8865.

Solve : .bat file to read a file,create a folder then move file into folder?

Answer»

I would really appreciate anybody's help here, What I'm trying to do is the following:

1. Read the titles from a NUMBER of files within a directory.
2. CREATE a FOLDER for each file based upon its name, but not its file extension.
3. move each file into its own folder.

I would really like some help as i have over 50 GB of files and doing it individually would take me a year or two.....

Many thanksLet's say you have files in the folder named

dog.txt
cow.jpg
Man In The Moon.xls
(etc)

(1) Is this what you WANT to do: make a folder called dog and move dog.txt into it, a folder called cow and move cow.jpg into that, make a folder called Man In The Moon and move Man In The Moon.xls into that, and keep going until all the files are done? Is that right? So instead of a folder full of files you will have a folder full of sub folders, each with one file in it?

(2) Will there be any files with different extensions but the same base name e.g. Horse.jpg Horse.txt Horse.doc, and if so what are you planning to do in that situation?





Salmon,

with respect to your first point that is what i need yes, and there may be multiple files which need copying into the same folder irrespective of file extension.Try this code. It should be placed in the folder in question, saved using a name of your choosing with a .bat extension. It will not include itself in the list of files to be processed and after it has run you should find that it is the only file left in the folder, all the others having been moved into subfolders.

Code: [Select]@echo off

REM Loop through every file in this folder
REM Excluding this BATCH file!

for /f "delims=" %%A in ( ' dir /b /a-d ^| find /v "%~nx0" ' ) do (

REM If a folder with the same base name
REM does not exist, create it
if not exist "%%~nA" md "%%~nA"

REM Move the file into the folder
REM and show message to user
echo Moving file: %%A to folder: %%~nA
move "%%A" "%%~nA"

)

REM Complete
echo Done
echo.
Pause

8866.

Solve : .bat file that reads from a existing .txt file and creates a new .txt file?

Answer»

Hello everyone.

I am trying to make a .bat file that reads the individual lines of a .txt file, and then, CREATES a new .txt file. I am doing this because i am trying to automate an extremely repetitive scheduling task.

For example, I have a file named project.txt which has several lines, and it looks like this:

Firstidea
Secondidea
Thirdidea
Fourthidea
Fifthidea
Sixthidea
Seventhidea
…..(and so on)

Im trying to make a .bat file that will read the file above and create a new file, called projectschedule.txt, that will look like this:



4
firstidea


1



0



4
secondidea


1



0



4
thirdidea


1



0



…….And so on.


So, the section from will reference the first line of the project.txt file.
The section of will reference the 2nd line of the project.txt file
The section of will reference the 3rd line of the project.txt file
The section of will reference the 4TH line of the project.txt file
The section of will reference the 5th line of the project.txt file

And so on for each line in the project.txt file.


The project.txt file that the .bat file will be referencing can have hundreds of lines. How can I make a for loop to reference each individual line of the project.txt file to make an output file called projectschedule.txt that looks similar to above?

I am thinking that the loop will look something like this:

@ECHO off
setlocal enabledelayedexpansion
cd /d "C:\Users\John\Desktop\schedule"
set /a sched=0
for /f "delims=" %%A in (project.txt) do (
echo > projectschedule.txt
echo 4 >> projectschedule.txt
echo firstidea >> projectschedule.txt
echo >> projectschedule.txt
echo >> projectschedule.txt
echo 1 >> projectschedule.txt
echo >> projectschedule.txt
echo >> projectschedule.txt
echo >> projectschedule.txt
echo 0 >> projectschedule.txt
echo >> projectschedule.txt
echo >> projectschedule.txt
sched=!sched!+3
)


I am new to batch, and i had a lot of help developing a similar batch from a forum a member named Salmon Trout.

The code above does not work. Part of the reason is because my output text needs to have < and > symbols.


-----echo firstidea >> projectschedule.txt
Also, the string above is the 8th line of the large code above. This string of code needs output the next consecutive line of the project.txt file each time it is looped through. Currently, the code above will only output"firstidea" every time it is looped through.



Any ideas or help would be greatly appreciated. Hello,

Thank you for the input.

The code you sent above works great!

The line that helped out the most was

echo ^%%i^ >> projectschedule.txt
inside of the do() loop, as i did not know how to reference each invidiviual line of the project.txt file as the loop was running.

Thanks again!

8867.

Solve : Help!Extract content from .xml files?

Answer»

Hi, everyone,
i am trying to build an ENGLISH-chinese bilingual corpus. I have downloaded about 1000 internet pages containing English news and its translations. I have saved them as .xml files which reads like:


-
-
-
-
gate.SourceURL
http://www.freexinwen.com/chinese/eng/news_bilingual/news/news_010107.asp

-
MimeType
text/html


-
-

看新闻学英语


01-01-07



亚洲领导人迎2007承诺促进国际合作 (Asian Leaders Usher in 2007 with Pledges for International Cooperation)



几个亚洲国家政府领导人在2007到来之际承诺促进国际合作并发表政策讲话。


在日本,安倍晋三首相承诺要改进和中国及韩国的关系。日本与这两国的关系近年来出现紧张,原因是它们认为日本歪曲了上世纪前半叶日本军国主义的历史。


在中国,国家主席胡锦涛承诺将建设“和谐社会”,并和其它国家共同解决减少污染和促进经济增长等其它问题。胡锦涛还强调将寻求和台湾实现和平统一。台湾总统陈水扁表示, 台湾的主权由台湾人民决定。他宣称台湾“绝对不属于”中国。



Several Asian government leaders have welcomed 2007 with new pledges for international cooperation and policy speeches.


In Japan, Prime Minister Shinzo Abe pledged to improve relations with China and South KOREA. Japan's relationship with those countries has been strained in recent years because of their perception that Japan misrepresents the history of its military expansionism in the FIRST half of the last century.


In China, President Hu Jintao pledged to pursue social harmony at home, and to work with other countries to ADDRESS common issues, such as pollution and economic growth. MR. Hu also stressed that he intends to pursue peaceful reunification with Taiwan. Taiwan's President Chen Shui-bian said the island's sovereignty was a matter for its people. He declared that the island "definitely does not belong" to China.




How can i extract only the Chinese and English from the 1000 .xml files and convert them into individual .txt files?
Many thanks!
Please don't post the same question more than once. Thank you. I deleted the duplicate post.i am sorry, admin. I won't do it anymore. Could anyone offfer me some tips on how to do it? Welcome to the CH forums.

Here's a small trial script which should get you going but I don't know how to actually display Chinese characters and English text from the same .txt file, there's gotta be a font change in there somewhere.

Code: [Select]@echo off>trial.txt
cls
setlocal

for /f "tokens=*" %%1 in ('dir /b trial.xml') do (

findstr /v /c:"<" /c:">" %%1>>trial.txt
)

type trial.txt

8868.

Solve : Batch remove - and . fixed length many suffix?

Answer»

I have to rename thousands of ???files with the nonstandard characters "." and "-". Fixed length, nothing else in folder, only the number changes, same DATE & system per folder, can be folder specificic, and multiple suffix, ie:
2011-05-21sys-03-99.new.test_0001.scene.fixed.doc
2011-05-21sys-03-99.new.test_0001.scene.fixed.xls
2011-05-21sys-03-99.new.test_0002.scene.fixed.doc
2011-05-21sys-03-99.new.test_0002.scene.fixed.xls
need to be
2011_05_21sys_03_99_new_test_0001_scene _fixed.doc
2011_05_21sys_03_99_new_test_0001_scene _fixed.xls
2011_05_21sys_03_99_new_test_0002_scene _fixed.doc
2011_05_21sys_03_99_new_test_0002_scene _fixed.xls
or with no spaces instead of "_".

ren 2011-??-??-??-??..test_*.scene.fixed.doc 2011_??_??_??_??_new_test_*_scene_fixed.doc
ren 2011-??-??-??-??..test_*.scene.fixed.doc 2011_??_??_??_??_new_test_*_scene_fixed.xls

seems to work, but does not like the number wild card, and only works on one file. I tried a couple FOR loops, something like

FOR %%*doc IN (C:\Temp) DO (ren "%%*.doc" 2011-??-??-??-??..test_*.scene.fixed.doc 2011_??_??_??_??_new_test_*_scene_fixed.doc)
but I am sure I have butchered this code.

Any pointers on how to get the number wild card to work or how to get the batch to work? Do you think the FOR loop is appropriate for this? Thanks.So you want the renamed filenames to be the same except that all dots and dashes BECOME underscores? Not including the dot which starts the extension?

Quote

Do you think the FOR loop is appropriate for this? Thanks.

Absolutely. What I would do is enable delayed expansion and in a loop, READ in each filename, then using the ~n and ~x variable modifiers, split it into base name and extension, take the base name and use string replace (twice, once to replace . with _ and again to replace - with _) then add the extension back and use the old name and new name in a REN command. Unfortunately it is 7 AM here and I am gong to work so I won't be able to actually post some example code until around 9 hours time. Maybe somebody else will beat me to the punch? (Not you, Bill!)



Quote from: Salmon Trout
Maybe somebody else will beat me to the punch?

Nobody would dare!!!

Ugh, I don't know why the little smiley faces showed up all over my post!

Thanks, Salmon Trout, that is the solution. I actually posted the same question on another forum and code using the filename parameter extensions (ie, %~n and %~a) were used in an FOR loop. I'll have to brush up on the use of extensions.

I give credit to Salmon Trout and the other person with code for the solution. I'd post the other person's website and username, but I don't know how kosher that is with you all or him/her. Either way, you all have created a true believer in DOS-Batch. Thanks again.Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%A in ( ' dir /b ' ) do (
set oldbasename=%%~nA
set extension=%%~xA
set newbasename=!oldbasename:.=_!
set newbasename=!newbasename:-=_!
echo Renaming "!oldbasename!!extension!" to "!newbasename!!extension!"
REN "!oldbasename!!extension!" "!newbasename!!extension!"
)
echo.
echo All done
pause

Quote from: AndrewJW on June 13, 2011, 08:22:54 AM
I don't know why the little smiley faces showed up all over my post!

Unless you show text as code, this forum shows VARIOUS character combinations as EMOTICONS to all guests and all registered users who have not have selected "No Smileys" as the "Current Smiley Set" in their Profile Look and Layout Preferences. These are 3 question marks: If you see that as that *censored* stupid bewildered emoticon, that is why. This is a figure 8 and an end bracket

I really hate emoticons.


8869.

Solve : batchfile to backup sharepoint web application?

Answer»

I am trying to write a batch file that will backup a WEB application, we have a multi-tennant farm so I WANT to promt the end user to type in the siteID
i.e. 110xx-Auth01 to 11010-Auth01

What I have so far is:

@echo off
echo ===============================================================
echo Back up site to \\s604414dc4vw74\11005\
echo Change 110xx-Auth01 to the site you are backing up in integration
echo ===============================================================
@echo off
pause >CON
REM variables to replace - VERIFY before continuing - hit ctrl+c to cancel script
set /p siteid stsadm.exe -o backup -DIRECTORY \\s604414dc4vw74\11005\ -backupmethod full -ITEM "Farm\Windows SharePoint Services Web Application\110xx-Auth01" -nositelock

echo completed

Thanks for the help.

8870.

Solve : DOS batch file - not recognized as an internal command ...?

Answer»

This is all you really NEED. The rest is just BELLS and whistles.

Code: [Select]for %%A in (%ddir%\*.gz) do %zdir%\7za.exe E "%%~dpnxA" -o%TDIR% -AOA
for %%B in (%tdir%\*.tar) do %zdir%\7za.exe e "%%~dpnxB" -o%gdir% -aoa

8871.

Solve : shutdown batch script?

Answer»

I am trying to write a batch file that I can use to shutdown/restart computers in my domain REMOTELY. When I type this into the CMD prompt it will work.

Code: [Select]shutdown /s /m \\pcName /t 300 /c "Your message here"


But if I copy that into a batch file so I can use it for different machines as needed it just keeps looping through the first two questions. If I leave echo on I can see where the shutdown command is run, but nothing happens (see bottom of post). Any suggestions?


Code: [Select]@echo off

SET /p _pcName="What computer do you wish to shutdown/restart? "
SET /p _pcAction="Do you want to restart or shutdown the computer? "

if "%_pcAction%" equ "r" goto :pcRestart
if "%_pcAction%" equ "s" goto :pcShutdown

:pcRestart
shutdown /r /m "\\%_pcName% /t 300 /c "5 minutes to AUTOMATIC restart"
goto :confirm


:pcShutdown
shutdown /s /m \\%_pcName% /t 300 /c "5 minutes to automatic shutdown"
goto :confirm

:confirm
set /p _confirm="Shutdown in progress. Would you like to abort? "
if "%_confirm%" equ "y" shutdown /a /m \\%_pcName%
exit

Code: [Select]
C:\Users\[username]\Desktop>SET /p _pcName="What computer do you wish to shutdown
/restart? "
What computer do you wish to shutdown/restart? test_pc

C:\Users\[username]\Desktop>SET /p _pcAction="Do you want to restart or shutdown
the computer? "
Do you want to restart or shutdown the computer? s

C:\Users\[username]\Desktop>if "s" EQU "r" goto :pcRestart

C:\Users\[username]\Desktop>if "s" EQU "s" goto :pcShutdown

C:\Users\[username]\Desktop>shutdown /s /m \\test_pc /t 300 /c "5 minutes to auto
matic shutdown"

C:\Users\[username]\Desktop>SET /p _pcName="What computer do you wish to shutdown
/restart? "
What computer do you wish to shutdown/restart?
have you tried using START in FRONT of each shutdown command?I tried that and it still doesn't work. It opened a new window and started asking the questions again. The original window asked if I wanted to abort the shutdown and then went back to the questions again. The command never actually went through to the remote pc though.

8872.

Solve : ftpcmd with dynamic names?

Answer»

Hello,

I use this ftpcmd:

open mywebserver.com
usrname
password
cd httpdocs/mp3
put "C:\files\20062011221.mp3"
QUIT

but 20062011221.mp3 is dynamic. DDMMYYYYHH1 (The one is always the same).mp3
I want to upload every day this mp3 file with a SCRIPT but the name of this file is everyday different

How to solve this problem?easy!!
Create a text file with your commands in it and call FTP -s filename
where filename is the file you stored your commands

Id suggest you put in a bin command before the upload, otherwise you run the risk of stripping off the bit 7 from every mp3 (makes for interesting effects on photos)THANKS for your reply, but that's just what I'm doing. The problem is that I don't know to handle a dynamic file name.

The name of the mp3 is every day different. I can't use "C:\files\20062011221.mp3" because the name changes every day. It should be %D%M%Y%H1.mp3 or something like that.

Is there anyone who knows this?The date and time format is local to each machine. Without knowing that, we can only guess at a solution. For more specific code, please run echo %date% and echo %time% at the command line and post the results.

This little snippet will work if the date format is dow mm/dd/yyyy and the time format is hh:mm:ss.ms You might be able to use it as a template.

Code: [Select]@echo off
setlocal

set dt=%date:~7,2%%date:~4,2%%date:~10,4%%time:~0,2%1
set dt=%dt: =0%

(
echo open mywebserver.com
echo usrname
echo password
echo cd httpdocs/mp3
echo BINARY
echo put "C:\files\%dt%.mp3"
echo quit
) > script.txt

ftp -s script.txt

Good luck.
Thanks. This is exactly what I need.

Is it also possible to give the file a suffix? So 20062011221.mp3 will be 20062011221-done.mp3 on my SERVER?Glad it helped.

Quote

Is it also possible to give the file a suffix? So 20062011221.mp3 will be 20062011221-done.mp3 on my server?

Why not try renaming the file?

Code: [Select]ren C:\files\%dt%.mp3 %dt%-done.mp3

Suggest doing this after the ftp command is complete. If the ftp command returns an errorlevel you can condition the ren in case the upload fails.

8873.

Solve : Attempting to find hash?

Answer»

I'm trying to FIND the hash of my favourite minecraft server so I can automatically switch to it if it changes IP addresses without having to look through the server list and find it, but I'm running into a bit of an issue. When I go to http://www.minecraft.net/servers.jsp and look at the source, I see the server details like this:<BR>Code: [Select]<a href="play.jsp?server=79be7a5abc334f8ae4bcbcd235cd4141"><b>Neko-san. Nyan!</b></a> 8/50

<br>

<a href="play.jsp?server=9439c1e4ca9c75edf046f7a03dbb92bb"><b>Au70 Galaxy</b></a> 14/35

<br>

<a href="play.jsp?server=d828ce6a503f2f61c12c19b70df2f48a"><b>Minecraft Server</b></a> 0/16

<br>
...It would be all too easy to find the hash for my desired server like this, but when I TRY to get the source of the page with a tool like CURL, wGET, or this miscellaneous VBS tool from http://www.robvanderwoude.com/vbstech_internet_download.php, the source looks like this:
Code: [Select] <b>Team9000 Public (team9000.net)</b> 94/512

<br>

<b>Javackes - LavaSurvival!</b> 30/30

<br>

<b>Official Opticraft Dev Server!</b> 104/320

<br>
...
Does anyone know of another method of downloading the source of a page that would work for me?Tried using PHP with cURL?Quote from: kpac on May 24, 2011, 02:59:15 PM

Tried using PHP with cURL?
How exactly kpac? There is no switch between --pass and --post301. I'm using the command line "Win32 2000/XP on i386 curl executable" version.
you need to be logged in to join or even get links to multiplayer games. (if you log out and view the page you don't get links either).
why can't you use view source from within the browser to acquire the link/hash?Quote from: BC_Programmer on May 24, 2011, 08:53:03 PM
you need to be logged in to join or even get links to multiplayer games. (if you log out and view the page you don't get links either).
why can't you use view source from within the browser to acquire the link/hash?
So true BC, I completely forgot about that. I already answered that question in my first post however, I wish to do this all automatically. I run a bot for the server, which automatically rejoins except when the server IP changes.

I tried using my cookie from internet explorer, but that didn't give desired results, so how would I log in with cURL and download the file?
I tried using --user USERNAME:PASSWORD, but that ALSO didn't work.
I tried to OBTAIN a cURL cookie by using Code: [Select]curl --cookie-jar newcookie.txt --data "username=USERNAME^&password=PASSWORD^&use_secure=false" http://www.minecraft.net/login.jsp but it tells me my username or password is incorrect, I've checked that they're right.Quote from: Helpmeh on May 24, 2011, 09:05:53 PM
So true BC, I completely forgot about that. I already answered that question in my first post however, I wish to do this all automatically. I run a bot for the server, which automatically rejoins except when the server IP changes.

I tried using my cookie from internet explorer, but that didn't give desired results, so how would I log in with cURL and download the file?
I tried using --user USERNAME:PASSWORD, but that also didn't work.
I tried to obtain a cURL cookie by using Code: [Select]curl --cookie-jar newcookie.txt --data "username=USERNAME^&password=PASSWORD^&use_secure=false" http://www.minecraft.net/login.jsp but it tells me my username or password is incorrect, I've checked that they're right.

youve put that secure=false, surely this needs to be set to true?Nope. I checked the POST data when I submit the form and that's what it is.I would try Denmark....

Sorry Helpmeh....couldn't resist.

Quote from: patio on June 07, 2011, 05:37:12 PM
I would try Denmark....

Sorry Helpmeh....couldn't resist.


*sigh* No actual advice though?

It doesn't even technically need it to be batch...it just needs to put the hash in a file for the bot.Nobody has an answer...*sigh*

BUMP
8874.

Solve : makefile and enviromental varriable confusion?

Answer»

Hi I'm trying define functions in a makefile such as echo and sed using the following code:-

Code: [Select]
# CHECK EXPECTED variables are defined
define ASSERT_VARIABLE_EXISTS
ifndef $(1)
$$(error Environment Variable $(1) must be defined )
endif
endef

$(eval $(call ASSERT_VARIABLE_EXISTS,MINGW_TOOL_DRIVE))
$(eval $(call ASSERT_VARIABLE_EXISTS,MINGW_TOOL_PATH))


# MinGW Commands
ECHO := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\echo
DATE := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\date
HOSTNAME := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\hostname
UNAME := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\uname
WHOAMI := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\whoami
SED := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\sed
GREP := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\grep
MKDIR := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\mkdir


I have the following added to my path: C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\MinGW\MSYS\1.0\local\bin
However each TIME I run the make file I receive the error that I set up to say that the varriables are are not defined
Is there anything else I must do to set up the environmental variables.

Any help is appreciated
Thanks Problem sorted, just a misunderstanding of environmental variables Quote from: souslatable on JUNE 21, 2011, 09:10:59 AM

environmental variables

Environment variables.
8875.

Solve : bat file to search a file and form new reports from the file?

Answer»

Hi i have a log.txt file which has multiple entries like below


Message to the mobile no [ mnumber=9623434524 not sent ].failed
something somethingXXXX xXXX
Message to the mobile no [ Recieved Acknowledgement for mnumber=98373458938 ]
Message to the mobile no [ mnumber=962342345324 not sent ].failed
something somethingXXXX xXXX
Message to the mobile no [ mnumber=96234432454 not sent ].failed
Message to the mobile no [ Recieved Acknowledgement for mnumber=9543448938 ]



I want a BAT file to READ this log file for lines with keywords ".failed" and "[Recieved Acknowledgement".

then from each LINE with keyword ".failed" it should find the substring "mnumber=98987676765" and save in a file failedreport.txt
similarly
from each line with keyword "[Recieved Acknowledgement" it should find the substring "mnumber=989873453345" and save in a file succesreport.txt

the log file is at location c:\Application\logs
reports can be MADE at c:\Application\reports
all mnumbers are differnt but only 10 digits
mnumbers will be SURELY present in line with keywords ".failed" and "[Recieved Acknowledgement".

can this be done ..
pleas help .

aditya Note correct spelling of "Received". Is this as it appears in log.txt?

sorry its "Received" ..... my mistake...Note "success" is spelt thus...

Code: [Select]@echo off
for /f "tokens=1-26 delims== " %%A in (log.txt) do (
if "%%G"=="Received" echo %%J=%%K >> c:\Application\reports\successreport.txt
if "%%G"=="mnumber" echo %%G=%%H >> c:\Application\reports\failedreport.txt
)

8876.

Solve : Saving hard drive C: to portable hard drive via DOS?

Answer»

If possible, what WOULD the DOS command be to save the total contents of hard drive C: to portable hard drive E? Or will drag and drop do it?You can create an almost exact copy of C to E with DOS, but you will want to avoid trying to copy parts of windows such as SWAP files etc. Most use an image utility to BACKUP C: as an image to say E: external if you want a full system recovery option. If you are looking to just backup MUSIC, PICTURES, documents etc, then you can create a routine to do xcopy or robocopy those files/folders to E:Thanks David Lembke

Donald Gedge

8877.

Solve : Can i make those changes??

Answer»

I have a book. I WANT to some CHANGES in this book. This book is in pdf format. Can I make those changes?YES. But you NEED to have a CONVERTER. I am not sure if there are any free PDF to MS Word converter out there.

8878.

Solve : Which is the best cli os??

Answer»

can anyone tell me which one is the best & popular cli os in linux & unix?Are you REFERRING to the shell?

BASH is the most common standard as far as shell's go. There are many other shells that can be used, however. While the wikipedia entry on the subject is not exactly the most thorough, it seems to provide a GOOD overview.

http://en.wikipedia.org/wiki/Unix_shell

As far as Linux goes, generally what you get with the distro "ought" to be what you use most often. This doesn't mean you cannot use another shell- far from it- but most distros contain a number of shell scripts for various purposes, and these will of course not always work in other shell implementations. Whether this constitutes a problem depends on the specific user and what they are trying to do, of course.i actually meant gentoo linux ,redhat fedora linux in linux family....
& solaris ETC in unix family... ,which one's CLI?CLI?
You mean Command Line Interface.
All Linux distributions have a CLI and they are also called 'shells'.

For the ENJOYMENT of all... Here is a video...
playing With Shells In Ubuntu

8879.

Solve : Need batch file to provide answers to prompts that come up after running the cmd?

Answer»

Hi

I'm trying to create a batch file that will generate SNMP authentication failures on my system. I can issue this command:

“C:\Program Files (x86)\snmpri\JBb.JMADK\snmp17.2.0.1\eso\w32.bin\getone” –v3 172.16.0.40 admin sysDescr.0

but when I do that, it'll prompt me for my auth and priv passwords. I want to be able to generate a whole bunch of these errors so I don't want to have to enter the auth/priv passwords every time. Is there any way to get the .bat file to do this for me? I tried:

“C:\Program Files (x86)\snmpri\JBb.JMADK\snmp17.2.0.1\eso\w32.bin\getone” –v3 172.16.0.40 admin sysDescr.0
SHA:thisIsMyPassword
AES12:thisIsMyPassword

in my batch file (the LAST two lines are the answers to the "what's your auth KEY" and "what's your priv key" questions that come up after issuing the getone command) but I still got the prompts asking these questions and my .bat file complained about the SHA:thisIsMyPassword and AES12:thisIsMyPassword lines.

I HOPE I explained this well enough for someone to make sense of what I'm trying to ask.....Thanks for your help!Try putting the 2 passwords in a text file, in the right order, each on its own line, and using redirection e.g.

Code: [Select]“C:\Program Files (x86)\snmpri\JBb.JMADK\snmp17.2.0.1\eso\w32.bin\getone” –v3 172.16.0.40 admin sysDescr.0 <passwords.txtThank you thank you thank you!!!! That worked!!! Now all I NEED to do is throw it in a loop and voila!!!

Thanks again!!!

8880.

Solve : Need Help in appending a substring of previous line to next subsequent lines?

Answer»

You can right justify the file size in an (e.g.) 16 char wide column quite easily - then you can use sort /R /+N on the output file - N (starting column for sort) will depend on the date and time field widths which depend on local SETTINGS.

A tip with sort - specifying an output file for example: sort /R /+24 Unsorted.txt /O Sorted.txt is quicker than redirecting stdout to a file (according to Microsoft): sort /R /+24 Unsorted.txt > Sorted.txt

I have actually tried this method on my system and I found I was getting some blank date/time/size fields for certain files, about 20 out of 600,000, whereas using the full DIR listing didn't do that.

Code: [Select]setlocal enabledelayedexpansion
for /f "usebackq tokens=1" %%v in (`mountvol ^| find ":\"`) do (
for /f "tokens=* delims=" %%i in ('dir "%%v" /b /s /a-d /o:-s') do (
set fsize=%%~zi
set fsize= !fsize!
set fsize=!fsize:~-16!
echo %%~ti,!fsize!,%%~nxi,%%~dpi >> Unsorted_Intermediate.csv
)
)
Admittedly the findstr commands are not needed. They were leftover from when testing without the /b switch.

BASED on the OP reply #1, the files are sorted correctly coming out of the dir command and require no further processing, while the echo command formats the csv file and gang punches the proper folder name into each record.

Quote

and my expected output should be

07/01/2011 02:29 PM 17,503,511 Conf_Logs.log D:\
07/06/2011 09:07 PM 3,013,934 Master.txt D:\
12/01/2010 11:48 AM 1,383,424 CRBT_FRR_ID_50.doc D:\
01/17/2011 12:49 PM 1,042,944 SpainFCA_Installation Note.doc D:\


01/08/2011 07:18 PM 3,178,425 IMG_2801.JPG D:\Accord_Get2Gthr_Photos
01/08/2011 07:18 PM 2,879,090 IMG_2802.JPG D:\Accord_Get2Gthr_Photos
01/08/2011 07:18 PM 2,856,676 IMG_2803.JPG D:\Accord_Get2Gthr_Photos
01/08/2011 07:35 PM 2,745,495 IMG_2818.JPG D:\Accord_Get2Gthr_Photos
01/08/2011 08:50 PM 2,685,050 IMG_2838.JPG D:\Accord_Get2Gthr_Photos
01/08/2011 07:14 PM 2,663,947 IMG_2799.JPG D:\Accord_Get2Gthr_Photos



01/08/2011 08:40 PM 100,078,852 MVI_2833.AVI D:\Accord_Get2Gthr_Photos\vid D:\Accord_Get2Gthr_Photos\vid
01/08/2011 07:47 PM 10,844,132 MVI_2827.AVI D:\Accord_Get2Gthr_Photos\vid
01/08/2011 07:47 PM 11,458 MVI_2827.THM D:\Accord_Get2Gthr_Photos\vid

Forcing the size data into a 16 byte width seems unnecessary as does using the sort command. Excel with import it correctly.

The new model of this snippet from *censored* has gone from I/O bound to to CPU bound. Is this an improvement? [that's a rhetorical question ST]

Code: [Select]@echo off

rem for /f "usebackq tokens=1" %%v in (`mountvol ^| find ":\"`) do (
for /f "tokens=* delims=" %%i in ('dir "%%v" /b /s /a-d /o:-s') do (
echo %%~ti,%%~zi,%%~nxi,%%~dpi >> Final_Master.csv
)
)

Quote from: Sidewinder on July 17, 2011, 02:32:35 PM
Based on the OP reply #1, the files are sorted correctly coming out of the dir command and require no further processing

In a later post he says he WANTS a LIST of files in each folder, on each drive letter on his server, sorted in descending order of file size...

Quote
1. I need to search each and directory and file in each drive and sort all the files according their size in descending order. i.e Largest file in the server to smallest file with path where it is existing.

Dir sorts the files for each folder independently, so a further sort will be necessary.

Quote
Forcing the size data into a 16 byte width seems unnecessary as does using the sort command. Excel with import it correctly.

I asked the OP whether he had Excel but got no reply.

Quote
The new model of this snippet from *censored* has gone from I/O bound to to CPU bound. Is this an improvement? [that's a rhetorical question ST]

I'm not sure...

Quote from: Sidewinder on July 17, 2011, 02:32:35 PM
Forcing the size data into a 16 byte width seems unnecessary as does using the sort command. Excel with import it correctly.

I just found that when importing a csv that Excel 2003 has a maximum number of rows limitation of 65,536 - Excel 2007 is 1,048,576 rows

Anyhow, Powershell is much quicker than batch - I catalogued my whole computer in 2 minutes 35 seconds; using batch and dir took 50 minutes 51 seconds.

320,000 files approx in around 62,000 folders

Found 25 GB of forgotten stuff to delete
8881.

Solve : .txt output of batch session?

Answer»

I am using batch to run a folder full of python scripts over the weekend

FOR %%x IN (*.py) DO call "%%x"

Occasionally, one of the .py files does not WORK, gives and error on the command prompt window, and then moves on to the next .py. I would LIKE a print (output to .txt) of the batch SESSION so that I can tell which .py did not work.

It seems that the redirect command (> or >>) would only transfer command output (ie, dir) to particular place. My batch command (ie, call) does not have any output and simply executes. Is there a way to get and output of everything that happened during a batch session? It would mimic alt+print screen or cut and paste of a command window. Thanks,

Have you tried REDIRECTING the batch output to a FILE?

Mybatch.bat > report.txt

Mybatch.bat > report.txt generally just creates a blank .txt file.

Some other posters have suggested a error or output log 1>>output.log or 2>>error.logYou can print the errors and standard output to a single file by using the "&1" command to redirect the output for STDERR to STDOUT and then sending the output from STDOUT to a file:

Mybatch.bat 1> output.msg 2>&1

8882.

Solve : Echo vs. Echo to file (make file)?

Answer»

Hi,
I'm writing a makefile and I need it to create a .TCL FILE before executing it, the problem is that the echo command to a file is not working e.g.

for the following code:-
Code: [Select] $E Hello1
$E Hello2 > hello.txt

The result to the cmd prompt is:-

Code: [Select]Hello1
/usr/bin/sh: C:MINGWmsys1.0binecho: command not found
make: *** [test] Error 127

Any ideas why the echo command works but not for writing to a file?
ThanksThe problem was my DEFINITION for the echo command, it works by REPLACING:

Code: [Select]ECHO := $(MINGW_TOOL_DRIVE):\$(MINGW_TOOL_PATH)\msys\1.0\bin\echo

With

Code: [Select]ECHO := $(MINGW_TOOL_DRIVE):/$(MINGW_TOOL_PATH)/msys/1.0/bin/echo

However if the problem was interpreting the SLASHES why did the standard echo command work with the first definition?

8883.

Solve : Batch Generator?

Answer»

Hi
I am new to this and would like some help.

I have TRIED reading manuals but cant get my head around it, I have tried a Batch Generator to help me http://www.newgrounds.com/portal/view/452275 and wondering if there is a more better one available that can be downloaded or online.

I have tried some of the examples on the forum and messed araund with some of them.

Its best to learn by example and exploration than using a handicap tool that dynamically creates a batch for you. CREATE 2 folders on your hard drive using MD and Directory name such as MD TEST1 and MD TEST2 and place a text file into the TEST1 folder and learn how to copy it to TEST2 via a batch, then build onto something more complex like placing a bunch of files and folders at TEST1 and then create an XCOPY if XP or earlier or ROBOCOPY if Win 7 to learn how to have a batch grab all or specific files and folders and copy them to TEST2. When done doing that, post back here if you need another batch assignment for us to help you learn.

This reminds me of the guy who claimed he knew HTML and Java script when he contacted me about a problem and when i checked into his problem he was using a WYSIWYG HTML/Java script tool. When looking at the HTML/Java script source he was totally lost. He didnt know why or how any of it worked other than if he used his WYSIWYG tool that it is suppose to WORK and it DOESNT. The problem here was the tool had a flaw in its design that reflected when it created his dynamic HTML / Java Script web pages 10 years ago. I directed him to take cheap courses at Virtual University Online which was like $20 for a semester of up to 4 courses. He took HTML, Java Script, and CSS and thanked me for directing him into really learning it. He is now a graphic artist who also creates professional web pages with some WYSIWYG tools as well as source code touch ups SINCE he can now go back and read it and understand it to correct it.

8884.

Solve : Programmes running?

Answer»

I have used this COMMAND many times in the PAST, but have now suddenly forgotten it. The command brings up, I think 3 tabs. Under one of them are listed the startup programmes, each with a tick box. If you want to stop a particular programme from starting, just remove the tick..I've just remembered, always the way...msconfig..Msconfig was designed to be a diagnostic utility. It should not be used to make permanent changes to startup processes. Instead you should use a 3rd party app designed for the purpose. One such app is Mike LIN's Startup Control Panel (http://www.mlin.net/StartupCPL.shtml). There are other, more comprehensive apps - but this one is simple and STRAIGHTFORWARD.

8885.

Solve : how to form a triangle on dos command??

Answer»

i need the whole code to form a triangle... plss HELP Me!homework?Quote from: Allan on JULY 12, 2011, 06:19:28 AM

homework?

They give homework in summer school? If you don't do the ASSIGNMENT, do they punish you by sending you to regular school?

I found this on the CH boards. The basic code is there, feel free to modify it.


Quote from: Kay_IT23 on July 12, 2011, 06:18:17 AM
i need the whole code to form a triangle... plss Help Me!

-You didn't say what programming language
-You didn't show what you have tried so farCode: [Select]@echo. ___
@echo. \ /
@echo. V

run that as a batch file..LOL
8886.

Solve : Use Batch to Stop a service that is in a state of starting??

Answer»

Can someone confirm if stop or taskkill from a batch file will be able to stop/kill a service that is hung in a state of "starting"? I need to stop services across MULTIPLE servers in a particular order and then restart those same services in the reverse order.

Example:

Stop service2 on server2
stop service1 on server2
stop service2 on server1
stop service1 on server1

start service1 on server1
start service2 on server1
start service1 on server2
start service2 on server2

My issue is that if a service gets hung in a state of "starting" the batch does not go on to the next step. I suspect I can simply kill the hung process and then attempt to start it again to see if that fixes the issue and allows the batch to complete.

I realize this is treating the symptom and not the issue, but I do not know of a way to replicate a hung service to determine what the root problem is.

I'm running Windows 2003 on some servers and Windows 2008 on the other servers.

Any help would be greatly appreciated.



no responses, yet...I was able to find a service that TOOK long enough in the starting state to test...sc stop works but takes a BIT....taskkill /F took care of it quickly...thought I would UPDATE in case it helps anyone ELSE

8887.

Solve : batch to stop services on multiple servers and then restart same services?

Answer»

I've seen some different postings regarding stopping and starting services and dependencies between services. Here is my need. I have 3 servers with one or two services in question running on each server. I will always know which of the 2 services exist on each server, so that is not an issue. Here is what needs to happen:

Stop IBM Cognos 8 on \\EP App Server
wait for service to stop, then
Stop IBM Cognos 8 Planning 8.4 on \\EP App Server
wait for service to stop, then
Stop IBM Cognos 8 on \\Web Server
wait for service to stop, then
Stop IBM Cognos 8 Planning 8.4 on \\Web Server
wait for service to stop, then
Stop IBM Cognos 8 on \\BI App Server
wait for service to stop, then

Reboot all three servers

Wait for all three servers to start up

Start IBM Cognos 8 on \\BI App Server
wait for service to start, then
Start IBM Cognos 8 on \\EP App Server
wait for service to start, then
Start IBM Cognos 8 Planning 8.4 on \\EP App Server
wait for service to start, then
Start IBM Cognos 8 on \\Web Server
wait for service to start, then
Start IBM Cognos 8 Planning 8.4 on \\Web Server

If possible, then email an output showing that all services started properly. This is not as critical, but would be nice, though.

Notice that the services are started in the reverse order that they are stopped.

I am running Windows 2003 on all three servers.

Let me know what else you need to know...thanks, in advance!First you need to explain:

IBM Cognos 8 Planning 8.4

Here on this forum many are USING Windows server 2003 and the commands are specific to windows.
Does IBM Cognos 8 tun on Windows server 2003?
And does it allow remote control?
can you tell us the service name (Not display name) of IBM Cognos 8 and other service you mentioned. You can find this value when you double click on the service name in services.msc snap in.


Also, I dont think there is a reliable way to "wait for the servers to comeup" from a script. Script can keep pinging the server but ping stars responding as soon as network services are started,does not mean the server is fully up. May be experts here are aware of any way.

Besides that what you asked can be done including emails. May be you can give a approximate time taken by the server for reboot and the script will wait for that much time.



thanks..
Here's what I did that works (still room for improvement, but it works):

ECHO off

REM Script created by Jeff Owen in June 2011 to recycle the Cognos services in the Cognos 8.4 QA environment
REM and to reboot all of the servers in the environment
REM --
REM -- PURPOSE --
REM Cognos Planning performs much of its tasks using java processes constrained by 2G of RAM on each
REM processor, given the 32-bit platform for the Planning applications. Consequently, it is necessary to
REM recycle the services, periodically, to free up the memory for each java process available in the system.
REM This scripts also handles rebooting all of the servers in the environment to further improve
REM performance for the QA environment.

REM -- DOCUMENTATION --
REM This script provides documentation through both the command prompt window (primarily for developing and
REM testing purposes) and a text file for later review. Currently, the text file overwrites itself after
REM each run, on the premise that this will run once or twice a week, so issues will be ID'ed before the next
REM run. Multiple runs will not need to be logged in the file. If this changes, then make sure the first
REM entry to the text file is preceded by >> instead of a single >.


REM ****** ISSUES TO RESOLVE ******
REM what happens if one of the servers does not come back up? this script does not account for this
REM need to change the script to remove the planning services from the GATEWAY server once "production" changes
REM are CARRIED out to QA instance



REM --- stop order for servers ---
REM all planning servers can be stopped at the same time
REM PlanningServer
REM standby content manager
REM active content manager
REM BIServer

REM --- recycle IIS ---
REM stop w3svc
REM start w3svc
REM GatewayServer

REM --- start order for servers ---
REM active content manager
REM BIServer
REM standby content manager
REM all planning servers can be started at the same time
REM PlanningServer

REM --- on individual server with both services ---
REM stop IBM Cognos 8
REM stop IBM Cognos 8 Planning 8.4
REM start IBM Cognos 8 Planning 8.4 (IBM Cognos 8 service is started automatically by starting Planning 8.4)


Echo Planning Recycle started %date% %time% > "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



echo -------------- stopping Cognos services ------------------
echo -------------- stopping Cognos services ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on PlanningServer

:Resolve_PlanningServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8_pre

:StopService_PlanningServer_IBMCognos8
echo stop IBM Cognos 8 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer stop "IBM Cognos 8"

:Resolve_PlanningServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8_post

:StoppedService_PlanningServer_IBMCognos 8

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer

:Resolve_PlanningServer_IBMCognos8Planni ng84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8Planni ng84_pre

:StopService_PlanningServer_IBMCognos8Pl anning84
echo stop IBM Cognos 8 Planning 8.4 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer stop "IBM Cognos 8 Planning 8.4"

:Resolve_PlanningServer_IBMCognos8Planni ng84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_PlanningServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_PlanningServer_IBMCognos8Planni ng84_post

:StoppedService_PlanningServer_IBMCognos 8Planning84

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"




Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on GatewayServer

:Resolve_GatewayServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8_pre

:StopService_GatewayServer_IBMCognos8
echo stop IBM Cognos 8 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer stop "IBM Cognos 8"

:Resolve_GatewayServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8_post

:StoppedService_GatewayServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer

:Resolve_GatewayServer_IBMCognos8Plannin g84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8Plannin g84_pre

:StopService_GatewayServer_IBMCognos8Pla nning84
echo stop IBM Cognos 8 Planning 8.4 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer stop "IBM Cognos 8 Planning 8.4"

:Resolve_GatewayServer_IBMCognos8Plannin g84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_IBMCognos8Pla nning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_IBMCognos8Plannin g84_post

:StoppedService_GatewayServer_IBMCognos8 Planning84

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"






Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer

:Resolve_BIServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
GOTO Resolve_BIServer_IBMCognos8_pre

:StopService_BIServer_IBMCognos8
echo stop IBM Cognos 8 Service on Content Manager / BI App Server Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\BIServer stop "IBM Cognos 8"

:Resolve_BIServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_BIServer_IBMCognos8_post

:StoppedService_BIServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\BIServer query "IBM Cognos 8" | Find "STATE"







Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo Cognos Services stopped %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo wait 15 seconds >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sleep 15

echo -------------- Reboot Servers ------------------
echo -------------- Reboot Servers ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Rebooting all servers in QA simultaneously >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Rebooting all servers in QA simultaneously

shutdown -m \\BIServer -r -t 15 -c "Weekly Maintenance Reboot - Cognos Administrator initiated. Please save and logoff." -f -d p:4:1

shutdown -m \\PlanningServer -r -t 15 -c "Weekly Maintenance Reboot - Cognos Administrator initiated. Please save and logoff." -f -d p:4:1

shutdown -m \\GatewayServer -r -t 15 -c "Weekly Maintenance Reboot - Cognos Administrator initiated. Please save and logoff." -f -d p:4:1

echo wait 90 seconds to ensure all servers are shutting down
sleep 90

:CheckStatus_BIServer
REM This is to check the status of the Event LOG service as a means of determining the server is up and running
SC \\BIServer query "Eventlog" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO CheckStatus_PlanningServer
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "Eventlog" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO CheckStatus_BIServer

:CheckStatus_PlanningServer
REM This is to check the status of the Event Log service as a means of determining the server is up and running
SC \\PlanningServer query "Eventlog" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO CheckStatus_GatewayServer
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "Eventlog" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO CheckStatus_PlanningServer

:CheckStatus_GatewayServer
REM This is to check the status of the Event Log service as a means of determining the server is up and running
SC \\GatewayServer query "Eventlog" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO All_Servers_Started
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "Eventlog" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO CheckStatus_GatewayServer


:All_Servers_Started





echo -------------- Servers Rebooted ------------------
echo -------------- Servers Rebooted ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"


echo -------------- stopping and starting World Wide Web Publishing service ------------------
echo -------------- stopping and starting World Wide Web Publishing service ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of World Wide Web Publishing Service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of World Wide Web Publishing Service on GatewayServer

:Resolve_GatewayServer_W3SVC_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_W3SVC_pre

:StopService_GatewayServer_W3SVC

echo stop World Wide Web Publishing Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer stop "W3SVC"

:Resolve_GatewayServer_W3SVC_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StoppedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StopService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_GatewayServer_W3SVC_post

:StoppedService_GatewayServer_W3SVC

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "W3SVC" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo World Wide Web Publishing Service stopped %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"





echo Status of World Wide Web Publishing service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of World Wide Web Publishing service on GatewayServer

:Resolve_START_GatewayServer_W3SVC_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_W3SVC_pre

:StartService_GatewayServer_W3SVC
echo start World Wide Web Publishing Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer start "W3SVC"

:Resolve_START_GatewayServer_W3SVC_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_W3SVC
SC \\GatewayServer query "W3SVC" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_W3SVC
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "W3SVC" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_W3SVC_post

:StartedService_GatewayServer_W3SVC

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "W3SVC" | Find "STATE"


Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

Echo World Wide Web Publishing Service started %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"




echo -------------- starting Cognos services ------------------
echo -------------- starting Cognos services ------------------ >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on BIServer

:Resolve_START_BIServer_IBMCognos8_pre
REM This is to check the status of this particular service prior to making any changes
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_BIServer_IBMCognos8_pre

:StartService_BIServer_IBMCognos8
echo start IBM Cognos 8 Service on Content Manager / BI App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\BIServer start "IBM Cognos 8"

:Resolve_START_BIServer_IBMCognos8_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_BIServer_IBMCognos8
SC \\BIServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_BIServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\BIServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_BIServer_IBMCognos8_post

:StartedService_BIServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\BIServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on PlanningServer

:Resolve_START_PlanningServer_IBMCognos8 Planning84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 Planning84_pre

:StartService_PlanningServer_IBMCognos8P lanning84
echo start IBM Cognos 8 Planning 8.4 and IBM Cognos 8 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer start "IBM Cognos 8 Planning 8.4"

:Resolve_START_PlanningServer_IBMCognos8 Planning84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8Planning84
SC \\PlanningServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8P lanning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 Planning84_post

:StartedService_PlanningServer_IBMCognos 8Planning84

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

REM This section is left in strictly as a fail safe in case the IBM Cognos 8 service does not automatically
REM start with the start of the IBM Cognos 8 Planning 8.4 service. Generally speaking, this should only
REM serve to present the status of the IBM Cognos 8 service as running.

echo Status of IBM Cognos 8 service on PlanningServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on PlanningServer

:Resolve_START_PlanningServer_IBMCognos8 _pre
REM This is to check the status of this particular service prior to making any changes
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 _pre

:StartService_PlanningServer_IBMCognos8
echo start IBM Cognos 8 Service on EP App Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\PlanningServer start "IBM Cognos 8"

:Resolve_START_PlanningServer_IBMCognos8 _post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_PlanningServer_IBMCognos 8
SC \\PlanningServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_PlanningServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_PlanningServer_IBMCognos8 _post

:StartedService_PlanningServer_IBMCognos 8

REM Show final status before moving on to the next service/server
sc \\PlanningServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 Planning 8.4 service on GatewayServer

:Resolve_START_GatewayServer_IBMCognos8P lanning84_pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8P lanning84_pre

:StartService_GatewayServer_IBMCognos8Pl anning84
echo start IBM Cognos 8 Planning 8.4 and IBM Cognos 8 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer start "IBM Cognos 8 Planning 8.4"

:Resolve_START_GatewayServer_IBMCognos8P lanning84_post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8 Planning84
SC \\GatewayServer query "IBM Cognos 8 Planning 8.4" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8Pl anning84
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8P lanning84_post

:StartedService_GatewayServer_IBMCognos8 Planning84

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8 Planning 8.4" | Find "STATE"




Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

REM This section is left in strictly as a fail safe in case the IBM Cognos 8 service does not automatically
REM start with the start of the IBM Cognos 8 Planning 8.4 service. Generally speaking, this should only
REM serve to present the status of the IBM Cognos 8 service as running.

echo Status of IBM Cognos 8 service on GatewayServer >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo Status of IBM Cognos 8 service on GatewayServer

:Resolve_START_GatewayServer_IBMCognos8_ pre
REM This is to check the status of this particular service prior to making any changes
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8_ pre

:StartService_GatewayServer_IBMCognos8
echo start IBM Cognos 8 Service on Gateway Server >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sc \\GatewayServer start "IBM Cognos 8"

:Resolve_START_GatewayServer_IBMCognos8_ post
REM This is to check that the service has stopped before moving on to the next service/server
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "STOPPED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "RUNNING" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartedService_GatewayServer_IBMCognos8
SC \\GatewayServer query "IBM Cognos 8" | FIND "STATE" | FIND "PAUSED" >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
IF errorlevel 0 IF NOT errorlevel 1 GOTO StartService_GatewayServer_IBMCognos8
echo Service State is changing, waiting for service to resolve its state before making changes
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"
echo wait 10 seconds
sleep 10
GOTO Resolve_START_GatewayServer_IBMCognos8_ post

:StartedService_GatewayServer_IBMCognos8

REM Show final status before moving on to the next service/server
sc \\GatewayServer query "IBM Cognos 8" | Find "STATE"



Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"




Echo Cognos Services started %date% %time% >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"






Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

REM Delay, primarily for development and testing purposes to quickly review the environment
echo wait 15 seconds >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
sleep 15

Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo - >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo completed RecycleServices_QA.bat >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

echo completed RecycleServices_QA.bat

echo wait 15 seconds
sleep 15

Echo --- >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo --- >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"
Echo --- >> "\\ScriptsServer\Cognos Scripts\RebootAndRecycleServices_QA.txt"

8888.

Solve : Need help on file compare option?

Answer»

Hi Friends,

Is it possible to compare 2 text file USING DOS command? Please advise. The clear data is mentioned below for your reference.

content on File1:
1.zip
2.zip
3.zip
4.zip

content on File2:
1.zip
2.zip
4.zip

The output file should display the 3.zip which is not in file2 but on file1. Please help on this. Thanks.If 3 zip isn't on file 2 it won't show in the content output...no matter what you do...Hi Patio,

Thanks much foir quick reply. Is there is any possiblity to print the line which is not in file2 but which is available on file1? Please adviseCode: [Select]@echo off
setlocal enabledelayedexpansion

echo 1.zip > File1
echo 2.zip >> File1
echo 3.zip >> File1
echo 4.zip >> File1
echo 5.zip >> File1
echo 6.zip >> File1
echo 7.zip >> File1
echo 8.zip >> File1
echo 9.zip >> File1
echo 10.zip >> File1

echo 1.zip > File2
echo 2.zip >> File2
REM echo 3.zip >> File2
echo 4.zip >> File2
echo 5.zip >> File2
REM echo 6.zip >> File2
echo 7.zip >> File2
echo 8.zip >> File2
echo 9.zip >> File2
echo 10.zip >> File2
echo 99.zip >> File2

for /f "delims=" %%A in (File1) do (
set found=1
For /F "delims=" %%B in (File2) do if "%%A"=="%%B" set /a found+=1
if not !found! equ 2 echo %%A is present in File1 but not in File2
)

for /f "delims=" %%A in (File2) do (
set found=1
For /F "delims=" %%B in (File1) do if "%%A"=="%%B" set /a found+=1
if not !found! equ 2 echo %%A is present in File2 but not in File1
)

Code: [Select]3.zip is present in File1 but not in File2
6.zip is present in File1 but not in File2
99.zip is present in File2 but not in File1Fixed a possible bug if a line is present more than once in one of the files

Code: [Select]@echo off
setlocal enabledelayedexpansion

echo 1.zip > File1
echo 2.zip >> File1
echo 3.zip >> File1
echo 4.zip >> File1
echo 5.zip >> File1
echo 6.zip >> File1
echo 7.zip >> File1
echo 8.zip >> File1
echo 9.zip >> File1
echo 10.zip >> File1

echo 1.zip > File2
echo 2.zip >> File2
REM echo 3.zip >> File2
echo 4.zip >> File2
echo 5.zip >> File2
REM echo 6.zip >> File2
echo 7.zip >> File2
echo 8.zip >> File2
echo 9.zip >> File2
echo 10.zip >> File2
echo 99.zip >> File2

for /f "delims=" %%A in (File1) do (
set found=1
For /F "delims=" %%B in (File2) do if "%%A"=="%%B" set /a found+=1
if !found! equ 1 echo %%A is present in File1 but not in File2
)

for /f "delims=" %%A in (File2) do (
set found=1
For /F "delims=" %%B in (File1) do if "%%A"=="%%B" set /a found+=1
if !found! equ 1 echo %%A is present in File2 but not in File1
)

Code: [Select]3.zip is present in File1 but not in File2
6.zip is present in File1 but not in File2
99.zip is present in File2 but not in File1of course, a batch script is just about the slowest way to do this sort of THING, especially if the file sizes are larger than just a few lines. I tried the script above on two 10,000 line files and the time was 15 minutes for each compare. With VBScript it was down to 2 minutes.
fc file1 file2

OR output to file

fc file1 file2 > diffs.txt

Why doesn't this work for you?



Quote from: sandy1000 on June 23, 2011, 10:19:51 AM

fc file1 file2

The original poster desired to find which strings were present in the first file but not in the second. The FC command merely does a simple comparison. If we assume that the second file is just a copy of the first but with one or more lines deleted, then FC will flag every line after the missing one as a "difference", whether or not it is missing from the first file. Possibly by a diligent EXAMINATION ofthe output it might be possible to discover the required information, but ti WOULD not be very convenient.
8889.

Solve : .bat - looping through a text file?

Answer»

Hi,

what i am trying to achieve, is to measure network performance using a batch file
The batch file copies a test file (1meg.test) from from a central server to the c:\TEMP directory on a bunch of COMPUTERS. by looping through a list (list.txt) of computers at remote sites to calculate the AMOUNT of time taken to copy the file to each computer, then outputs the results to a txt file (timer.txt)

i have two batch files
the first (run.bat) calls the main batch file and reads from the list.txt

---RUN.BAT---

FOR /f %%u IN (list.txt) DO call c:\temp\timer.bat %%u >> c:\temp\timer.txt

--------------------------------------------------------------------------
which then should then run the second batch file (timer.bat)

---timer.bat---

@echo off

FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO (
set Milisecond=%time:~9,2%
set Day=%%A
set Hour=%%B
set Minute=%%C
set Second=%%D
)
set /a Start=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond%

copy c:\temp\1meg.test \\%comp%\c$\temp [this is where i am having a problem]

FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO (
set Day=%%A
set Hour=%%B
set Minute=%%C
set Second=%%D
)
set Milisecond=%time:~9,2%
set /a End=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond%
set /a Diff=%End%-%Start%
set /a DiffMS=%Diff%%%100
set /a Diff=(%Diff%-%DiffMS%)/100
set /a DiffSec=%Diff%%%60
set /a Diff=(%Diff%-%Diff%%%60)/60
set /a DiffMin=%Diff%%%60
set /a Diff=(%Diff%-%Diff%%%60)/60
set /a DiffHrs=%Diff%

:: format with leading zeroes
if %DiffMS% LSS 10 set DiffMS=0%DiffMS!%
if %DiffSec% LSS 10 set DiffMS=0%DiffSec%
if %DiffMin% LSS 10 set DiffMS=0%DiffMin%
if %DiffHrs% LSS 10 set DiffMS=0%DiffHrs%

echo %DiffHrs%:%DiffMin%:%DiffSec%.%DiffMS% >> c:\temp\timer.txt
---------------------------------------------------------------------------

---list.txt---
computer1
computer2
computer3
computer4
computer5
.etc..

the output that i am trying to get is something like
----output.txt------
computer1
00.200 sec
computer2
00.300 sec
computer3
00.400 sec
etc ....

the time function calculates correctly my problem is getting the batch to loop through the list of remote computers
if you can help, thanks in advance Have you considered MAKING this into one file? You could call your list and then USE a nested for loop to run the functions of the timer.bat file.

For instance:


@echo off
FOR /f %%u IN (list.txt) DO (

FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO (
set Milisecond=%time:~9,2%
set Day=%%A
set Hour=%%B
set Minute=%%C
set Second=%%D
)
set /a Start=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond%

copy c:\temp\1meg.test \\%%u\c$\temp

FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Second /Format:table ^| findstr /r "."') DO (
set Day=%%A
set Hour=%%B
set Minute=%%C
set Second=%%D
)
set Milisecond=%time:~9,2%
set /a End=%Day%*8640000+%Hour%*360000+%Minute%*6000+%Second%*100+%Milisecond%
set /a Diff=%End%-%Start%
set /a DiffMS=%Diff%%%100
set /a Diff=(%Diff%-%DiffMS%)/100
set /a DiffSec=%Diff%%%60
set /a Diff=(%Diff%-%Diff%%%60)/60
set /a DiffMin=%Diff%%%60
set /a Diff=(%Diff%-%Diff%%%60)/60
set /a DiffHrs=%Diff%

:: format with leading zeroes
if %DiffMS% LSS 10 set DiffMS=0%DiffMS!%
if %DiffSec% LSS 10 set DiffMS=0%DiffSec%
if %DiffMin% LSS 10 set DiffMS=0%DiffMin%
if %DiffHrs% LSS 10 set DiffMS=0%DiffHrs%

echo %%u %DiffHrs%:%DiffMin%:%DiffSec%.%DiffMS% >> c:\temp\timer.txt
)

8890.

Solve : Adding domain users to local group through command prompt?

Answer»

In computer management, when I add a domain USER group to the local ADMINISTRATORS group, I'm prompted for my Active Directory CREDENTIALS.

Is there way to USE net localgroup administrators domain/groupname /ADD WITHOUT being on the domain? Perhaps a credentials switch?

8891.

Solve : File Compare?

Answer»

Hello all,

I am using file compare on two text files. It seems to return the line previous to and the line following, as well as the line that's different. Is this correct? I don't find this noted in FC help info.

Thank,

SandyFC shows the differences in a dumb way. If you want to know the first place in a file where there is a difference, use a binary comparison.

CODE: [Select]C:\>type file1
hello
goodbye
different1

C:\>type file2
hello
goodbye
different2

C:\>fc file1 file2
Comparing files file1 and FILE2
***** file1
goodbye
different1
***** FILE2
goodbye
different2
*****

Code: [Select]C:\>fc /b file1 file2
Comparing files file1 and FILE2
00000019: 31 32
So then, I should see the line that's different, along with the line above and the line after it (if there is one)?

I apologize that I don't know how to read the binary result, if you could get me started with that.

Thanks.What is the reason for using FC? What are you trying to find out about the two files?
I'm running an invoice off of a system. I want to make sure the invoice is exactly like a previous run of that invoice.

I expected to see the run date was different. The additional lines threw me and I could not find anything different about them. Except that it appears to be including info from above and below the line of discrepancy. (A name edit had also taken place in the body of the invoice, so there was extraneous info there also). A bit confusing when you're only expecting to see what's different.

So I' was trying to confirm how FC works and that I'm not somehow missing something.



Actually, I had done a test with text and it returned the lines above and below the line of discrepancy. So I thought that's what was happening.

Looking at the real data:

* It is showing only the last 8 characters of the 136 character line above.

* What looks like it would be the line below the line of discrepancy (which has a name edit)
is actually the last 32 characters of that same line (which is 160 characters total).


Specifically how does FC report back?



Can anyone describe what FC would return when one line is different? Why don't you do some experiments?
I did do a controlled test to see what returned. The real data return seems different and I don't understand the result. So, I'm not understanding what FC is supposed to return when one line differs.

I'd like to know the syntax for the return if anyone knows it (can't seem to find it anywhere for some reason).

Quote from: sandy1000 on June 24, 2011, 09:49:17 AM

I did do a controlled test to see what returned. The real data return seems different and I don't understand the result. So, I'm not understanding what FC is supposed to return when one line differs.

I'd like to know the syntax for the return if anyone knows it (can't seem to find it anywhere for some reason).

What do you mean "if one line differs"? Do you mean 2 files which have exactly the same number of characters, in the same number of lines, but one line is different in one of the files? At the beginning, in the middle, or at the end? Or two one-line files, each different from the other? Or what?

The results below seem clear enough to me.

Text1.txt

Code: [Select]The prime minister, in Brussels for an EU summit where Greece's debt crisis is
among items on the agenda, SAID: "Britain is out of the euro - I think we will
stay out of the euro and certainly as long as I am doing this job there is no
prospect of Britain even contemplating JOINING the euro."
The Greek parliament has to pass fresh austerity measures next week before the
country can gain vital bail-out funds to prevent it defaulting on its loan
payments, due in mid-July.
Mr Blair told BBC One's Politics Show, in an interview to be broadcast on
Sunday, he had backed the idea of Britain joining the euro when he came to
power - but had accepted that the conditions had to be right.
Text2.txt - First line: lower case p changed to upper case.

Code: [Select]The Prime minister, in Brussels for an EU summit where Greece's debt crisis is
among items on the agenda, said: "Britain is out of the euro - I think we will
stay out of the euro and certainly as long as I am doing this job there is no
prospect of Britain even contemplating joining the euro."
The Greek parliament has to pass fresh austerity measures next week before the
country can gain vital bail-out funds to prevent it defaulting on its loan
payments, due in mid-July.
Mr Blair told BBC One's Politics Show, in an interview to be broadcast on
Sunday, he had backed the idea of Britain joining the euro when he came to
power - but had accepted that the conditions had to be right.
Text3.txt - 7th line: July changed to july

Code: [Select]The prime minister, in Brussels for an EU summit where Greece's debt crisis is
among items on the agenda, said: "Britain is out of the euro - I think we will
stay out of the euro and certainly as long as I am doing this job there is no
prospect of Britain even contemplating joining the euro."
The Greek parliament has to pass fresh austerity measures next week before the
country can gain vital bail-out funds to prevent it defaulting on its loan
payments, due in mid-july.
Mr Blair told BBC One's Politics Show, in an interview to be broadcast on
Sunday, he had backed the idea of Britain joining the euro when he came to
power - but had accepted that the conditions had to be right.
Text4.txt - Last line: had changed to Had

Code: [Select]The prime minister, in Brussels for an EU summit where Greece's debt crisis is
among items on the agenda, said: "Britain is out of the euro - I think we will
stay out of the euro and certainly as long as I am doing this job there is no
prospect of Britain even contemplating joining the euro."
The Greek parliament has to pass fresh austerity measures next week before the
country can gain vital bail-out funds to prevent it defaulting on its loan
payments, due in mid-July.
Mr Blair told BBC One's Politics Show, in an interview to be broadcast on
Sunday, he had backed the idea of Britain joining the euro when he came to
power - but Had accepted that the conditions had to be right.
Code: [Select]C:\>fc Text1.txt Text2.txt
Comparing files Text1.txt and TEXT2.TXT
***** Text1.txt
The prime minister, in Brussels for an EU summit where Greece's debt crisis is
among items on the agenda, said: "Britain is out of the euro - I think we will
***** TEXT2.TXT
The Prime minister, in Brussels for an EU summit where Greece's debt crisis is
among items on the agenda, said: "Britain is out of the euro - I think we will
*****


C:\>fc Text1.txt Text3.txt
Comparing files Text1.txt and TEXT3.TXT
***** Text1.txt
country can gain vital bail-out funds to prevent it defaulting on its loan
payments, due in mid-July.
Mr Blair told BBC One's Politics Show, in an interview to be broadcast on
***** TEXT3.TXT
country can gain vital bail-out funds to prevent it defaulting on its loan
payments, due in mid-july.
Mr Blair told BBC One's Politics Show, in an interview to be broadcast on
*****


C:\>fc Text1.txt Text4.txt
Comparing files Text1.txt and TEXT4.TXT
***** Text1.txt
Sunday, he had backed the idea of Britain joining the euro when he came to
power - but had accepted that the conditions had to be right.
***** TEXT4.TXT
Sunday, he had backed the idea of Britain joining the euro when he came to
power - but Had accepted that the conditions had to be right.
*****




This is in the middle of the file. The two files differ: Nicole and NICOL

Line 388 shows only the last 8 characters of the 136-char line above
Line 390 shows the last 32 chars of the end of line 389 (I removed some spaces from its 160 chars for viewing)

388: 70126 F
389: CN 00003336163300276801 SMITH, NICOLE 20110510 007076730 319.45
390: F+000000000+000000000

So, it looks like lines are limited to 128 characters. The line above shows the tail end after the first 128. The line below shows the overflow beyond 128 chars of the line that differs.

Rings a bell. It's been some time since I've used this but I do look at DOS text files well exceeding 128 character line lengths.

Now I know what I'm looking at! Could not compute yesterday ; )

Thanks.


8892.

Solve : Batch file set /p not working?

Answer»

If I make a batch and place set /p=whatever? inside an if statement, it doesn't work. However, if it is outside of the if statement, it does.

Works:
Code: [Select]@echo off
set /p thing=enter choice(y/n)?

Doesn't:
Code: [Select]@echo off
if exist C:\WINDOWS\blabal.exe (
set /p thing=enter choice(y/n)?
)

Can anyone help me make the set command work inside the if statement? I have tried setlocal expansion thing.

Thanks.Put a caret ^ before the BRACKETS. Your code should be:
Quote

@echo off
if exist C:\WINDOWS\blabal.exe (
set /p thing=enter choice^(y/n^)?
)
Quote from: Helpmeh on June 14, 2011, 03:33:31 PM
Put a caret ^ before the brackets. Your code should be:

As has been noted, ordinary brackets have a special meaning in batch scripts. I tend to use SQUARE brackets e.g.

set /p answer="Do you want to dance [y/n]? "

and I like to use quotes to space the console cursor away from the end of the prompt string.
Salmon, I noticed that you put quotes around it. I found that using the quotes eliminates the need for the ^ even if I use (y/n).

Thanks for the help.Quote from: Linux711 on June 14, 2011, 04:43:33 PM
I noticed that you put quotes around it. I found that using the quotes eliminates the need for the ^ even if I use (y/n).

Yes, I forgot to mention that. I do that with set /p user prompt messages because I like to not have the console blinking cursor straight after the end of the prompt. With quotes I can add a space. But quotes are useful in other ways too. You can get rid of a lot of special-character-in-string problems if you quote the string.
Quotes aren't necessary to add the extra space, but like you said Salmon, it does eliminate special character issues.Quote from: Helpmeh on June 15, 2011, 05:40:02 PM
Quotes aren't necessary to add the extra space

What other way is there of addding the extra space?


Quote from: Salmon Trout on June 15, 2011, 11:53:49 PM
What other way is there of addding the extra space?

I know about using a non-printing space (Hex FF or Alt+255)

Just to summarize:

The OP found that a structure of this TYPE didn't do what he expected:

IF X=Y (
set /p blabla=Answer yes or no (/y/n)
)

The reason was that the round brackets around "y/n" break the parenthetical (bracketed) multiline IF structure.

The OP was offered a number of solutions:

  • Escape the opening and closing brackets around y/n with carets
  • Use different (square) brackets
  • Quote the prompt string

Following this, the OP pronounced himself satisfied.

Quote from: Salmon Trout on June 15, 2011, 11:53:49 PM
What other way is there of addding the extra space?

Adding a space at the end...:facepalm:

Code: [Select]@echo off
title BOTSAY
echo Between:
echo.^| ^|
:loop
set /p msg=
echo %msg% > SAY.txt
goto loopThe space does exist in the original code, it just gets eliminated by the forum software.Quote from: Helpmeh on June 20, 2011, 04:25:36 PM
Adding a space at the end...:facepalm:

Code: [Select]@echo off
title BOTSAY
echo Between:
echo.^| ^|
:loop
set /p msg=
echo %msg% > SAY.txt
goto loopThe space does exist in the original code, it just gets eliminated by the forum software.

What are you talking about exactly? This has nothing to do with the point I was making.



Quote from: Salmon Trout on June 20, 2011, 11:59:55 PM
What are you talking about exactly? This has nothing to do with the point I was making.
Quote from: Salmon Trout on June 15, 2011, 11:53:49 PM
What other way is there of addding the extra space?
I answered the QUESTION. Batch files themselves don't need the quotes, the forum software does, because it truncates trailing spaces.
8893.

Solve : Actual MS-DOS?

Answer»

#1 Rule...

If you find yourself digging a hole it's best to put the SHOVEL down...

No offense intende here but in this instance you're wrong...other than the semantics which can never be argued effectively...Quote from: Geek-9pm on June 06, 2011, 01:49:24 PM

The OP did not make it clear why he wants "actual DOS". Perhaps some users night believe that the old DOS has primitive utilities that can better manage the hard drive. Not so.
Quite right, and I do agree with you here. I don't think I would ever say fdisk is easier to use- or understand- then SOMETHING like Disk Management or GParted, unless one has already had experience using it.

Quote
These utilities wee written before significant changes were made in Hared Drive geometry and do not perform as the user might wish.
"These utilities"; they only talk about fdisk, and there is no significant danger from running fdisk on a drive, since it will not rewrite the boot code of the MBR, only the partition table.

Quote
The MAR is not just an area one the hard drive where some address are stored.
I never said it was. It is one area of the hard drive, though. the first sector of the drive, to be exact. Exactly 512 bytes. The offsets of important data are in fact standardized. All MBR's will have the Partition table (4 16-byte entries) at offset 446 within the sector. This is never different, regardless of the operating system. All that changes is the bytes before that, which determine the actual code used to start the boot loader itself. NT's boot loader differed from Win9x/MSDOS because it needed to have rudimentary support for NTFS to be able to find the boot loader, additionally it needed to know to look for NTLDR. Windows Vista's MBR boot code differs from XP and earlier in that they changed the boot loader to bootmgr, which has far more capabilities than NTLDR. Either way, the only task of the boot code in the MBR is to start this boot loader. That's it. It doesn't determine or change the "layout" of data on the drive, excepting of course the partition table.


Quote
There are rules as ton what can be placed there.
Yes. That's what I've been saying.

Quote
The rules have changed.
No they haven't. The code area of the MBR is still the first 446 bytes. the partition table is still 4 16 byte entries. the MBR signature that follows is still 2 bytes. What rules have changed with Vista? none- the only difference is that there is a different boot code to look for the new boot loader. Does the boot loader operate differently? Of course. But GRUB also operates differently from NTLDR and LILO operates different from BOOTMGR, but for some reason nobody is saying that a tool like GPARTED will cause the MBR to become "corrupted".

Quote
The rules are not consistent
Yes. they are really quite simple. Certain data is stored at specific offsets. 4 partitions per drive. the size of logical drives in the extended partition(which can be used to work past the "4-partition limit" are stored in EBR (Extended Boot Records) within the Extended partition. This has not changed with Vista.

Quote
The full set of rules is not seen by a casual examination of the area.
Yes, they are. the fact that the Vista and XP MBR's both conform to the given standard for MBR layout sort of confirms that there is a full set of rules and they are being used by both operating SYSTEMS.


Quote
The rules have been a moving target.
They were never a moving target. In fact, the layout of the MBR has been entirely unchanged since MS-DOS 2.00 when the original Hard disk support was added. Probably earlier. No Operating System that runs on a PC has used a on-disk format that didn't have an MBR. This includes Vista x64 when the drives are partitioned using GPT, since those drives also have a valid MBR- GPT acts as an extension.
Quote
That is why the GUID is now the way to go.
GPT is the preferred choice over the longer course simply because it extends the limitations of MBR. with MBR, no one partition can exceed 2TB in size, and no one partition can have an offset larger then 2TB from the start of the disk. needless to say this causes problems when you have drives larger than 2TB, which are starting to become available on the consumer market. It also adds redundant partition tables to mitigate the issues with the MBR's partition table (which, to repeat, is always at offset 446 and is always 16*4 bytes in size), where there was only one copy and if it got corrupted for any reason the disk was pretty MUCH unsalvageable (without tools like MIRROR, of course). From the looks of things GPT merely brings to the lower level structures of the disk what file systems like NTFS, HPFS, Ext2/3/4 and so forth have been providing as file systems for years- that is, larger sized partitions, more partitions, and better resilience.I use Partition Manager 8 booted from a DOS floppy or a bootable USB drive. PM8 will see as much of the drive as your BIOS allows.

PM8 will do just about anything you need to do a hard drive - partitioning, format FAT, FAT32, NTFS (all versions) etc. You can hide partitions, pick which partion you want active etc. Version 4 or 5 will format HPFS if you need it.

If you have the Windows version you can create the 'rescue disks' if you have a 1.4 MB floppy drive. I use these disks to boot to Calerdra DOS.
8894.

Solve : Ping Command Crashing DOS?

Answer»

Quote from: H2O on July 11, 2011, 11:38:02 PM

Also Linux, I tried to upload my pingpath and ping files but they weren't accepted by the site. Any ideas?

Open in Notepad and copy and paste into a forum post. That's what most people do.
I'm not exactly sure how to run it under 32-bit actually, and if Somebody knows then feel free to share. That time was for a picture but if I even just run the "ping" it closes. It even closes if I enter in "ping /?" which I find even more unnerving. Quote from: H2O on July 12, 2011, 05:58:50 PM
I'm not exactly sure how to run it under 32-bit actually, and if Somebody knows then feel free to share. That time was for a picture but if I even just run the "ping" it closes. It even closes if I enter in "ping /?" which I find even more unnerving.

your ping.exe file is corrupted. use sfc /scannow or a Repair install with the windows disc handy.

(32-bit command prompt is cmd.exe; 16-bit is command.com. Salmon Trout already answered that question in an earlier post.)

Also, what is a "pingpath" file?Thanks for clearing that up. I believe I will need to order a new disc as I haven't seen mine for over seven years

I really don't know what pingpath is exactly. I did a search for "ping" on my system32 folder to find and run it from system32 as you recommended. It brought up my ping command as expected but also pingpath as well, which I thought seemed important. When I opened it, the same thing happens as when I ran ping- command box, randomness, TERMINATE. I'm thinking it's some outdated type of file associated with ping that might have become obsolete in newer models. If nobody else has it though I'll be a little suspicious.Quote from: BC_Programmer on July 12, 2011, 06:11:38 PM
your ping.exe file is corrupted. use sfc /scannow or a Repair install with the windows disc handy.

(32-bit command prompt is cmd.exe; 16-bit is command.com. Salmon Trout already answered that question in an earlier post.)

Also, what is a "pingpath" file?

He means PathPing, I'm pretty sure, which is a network utility supplied in Windows NT and beyond that combines the functionality of ping with that of tracert, with additional information that neither of those tools provides. PathPing sends packets to each router on the way to a final destination over a period of time, and then computes results based on the packets returned from each hop. Since PathPing shows the degree of packet loss at any given router or link, you can pinpoint which routers or links might be causing network problems.

http://technet.microsoft.com/en-gb/library/cc958876.aspx

http://en.wikipedia.org/wiki/PathPing

Example (My IP obfuscated):

Code: [Select]C:\Users\Salmon>pingpath
'pingpath' is not recognized as an internal or external command,
operable program or BATCH file.

C:\Users\Salmon>pathping

Usage: pathping [-g host-list] [-h maximum_hops] [-i address] [-n]
[-p period] [-q num_queries] [-w timeout]
[-4] [-6] target_name

Options:
-g host-list Loose SOURCE route along host-list.
-h maximum_hops Maximum number of hops to search for target.
-i address Use the specified source address.
-n Do not resolve addresses to hostnames.
-p period Wait period milliseconds between pings.
-q num_queries Number of queries per hop.
-w timeout Wait timeout milliseconds for each reply.
-4 Force using IPv4.
-6 Force using IPv6.

C:\Users\Salmon>pathping www.google.com

Tracing route to www.l.google.com [209.85.229.147]
over a maximum of 30 hops:
0 Salmon-And-Tuna.cable.virginmedia.net [99.99.999.99]
1 10.15.176.1
2 aztw-geam-1a-ge134.network.virginmedia.net [80.1.242.49]
3 aztw-core-1a-ae0-0.network.virginmedia.net [80.1.241.9]
4 winn-bb-1a-as0-0.network.virginmedia.net [213.105.175.157]
5 manc-bb-1b-as7-0.network.virginmedia.net [212.43.163.189]
6 tele-ic-3-ae0-0.network.virginmedia.net [212.43.163.70]
7 158-14-250-212.static.virginmedia.com [212.250.14.158]
8 209.85.255.175
9 209.85.253.94
10 72.14.232.134
11 209.85.252.83
12 209.85.243.85
13 ww-in-f147.1e100.net [209.85.229.147]

Computing statistics for 325 seconds...
Source to Here This Node/Link
Hop RTT Lost/Sent = Pct Lost/Sent = Pct Address
0 Salmon-And-Tuna.cable.virginmedia.net [82.33.185.47]
0/ 100 = 0% |
1 --- 100/ 100 =100% 100/ 100 =100% 10.15.176.1
0/ 100 = 0% |
2 17ms 0/ 100 = 0% 0/ 100 = 0% aztw-geam-1a-ge134.network.virginmedia.net [80.1.242.49]
0/ 100 = 0% |
3 15ms 0/ 100 = 0% 0/ 100 = 0% aztw-core-1a-ae0-0.network.virginmedia.net [80.1.241.9]
0/ 100 = 0% |
4 19ms 0/ 100 = 0% 0/ 100 = 0% winn-bb-1a-as0-0.network.virginmedia.net [213.105.175.157]
0/ 100 = 0% |
5 25ms 0/ 100 = 0% 0/ 100 = 0% manc-bb-1b-as7-0.network.virginmedia.net [212.43.163.189]
0/ 100 = 0% |
6 31ms 0/ 100 = 0% 0/ 100 = 0% tele-ic-3-ae0-0.network.virginmedia.net [212.43.163.70]
0/ 100 = 0% |
7 29ms 0/ 100 = 0% 0/ 100 = 0% 158-14-250-212.static.virginmedia.com [212.250.14.158]
0/ 100 = 0% |
8 27ms 0/ 100 = 0% 0/ 100 = 0% 209.85.255.175
0/ 100 = 0% |
9 26ms 0/ 100 = 0% 0/ 100 = 0% 209.85.253.94
0/ 100 = 0% |
10 32ms 0/ 100 = 0% 0/ 100 = 0% 72.14.232.134
0/ 100 = 0% |
11 37ms 0/ 100 = 0% 0/ 100 = 0% 209.85.252.83
0/ 100 = 0% |
12 37ms 0/ 100 = 0% 0/ 100 = 0% 209.85.243.85
0/ 100 = 0% |
13 33ms 0/ 100 = 0% 0/ 100 = 0% ww-in-f147.1e100.net [209.85.229.147]

Trace complete.

C:\Users\Salmon>



Thank you once again Salmon. I appreciate your zeal in this forum. I just tried the PathPing command out on my computer and I'm please that it works just fine. I visited the links and it appears that PathPing can do what Ping does, but better (although it takes a bit longer). Would it make a difference if I forgot about Ping and use PathPing instead?Quote from: H2O on July 13, 2011, 08:46:44 PM
Thank you once again Salmon. I appreciate your zeal in this forum. I just tried the PathPing command out on my computer and I'm please that it works just fine. I visited the links and it appears that PathPing can do what Ping does, but better (although it takes a bit longer). Would it make a difference if I forgot about Ping and use PathPing instead?

I suggest you try both and SEE which one suits you best.
8895.

Solve : Why do we still use DOS today??

Answer»

why do we still need DOS today?I boot into pure DOS to run PARTITION Magic 8 to set up all my hard drives. I find I get BETTER control over the drive without Windows around.Quote from: ymaldonado on June 27, 2011, 06:05:32 PM

why do we still need DOS today?
Who are "we" in this case.
Many who use DOS will never come here hand tell you why.The just use it in their work and it never occurs to them that they should change it.

To illustrate the point, consider vehicles. Autos the travel on highways must meet safety rules. Rules can change. But vehicles that do service off of any highway do not have to comply with new highway rules.

Many business users continue to run their accounting software on a DOS based system. The use it the same way, DAY after day. They make backups. They make print outs. They post invoices. The system is a part of their business operation. They never get on the internet. They never let anybody PUT anything on the business computer.

There are some very powerful implication programs the still run on DOS based SYSTEMS. As long as the stay away from the public internet, they will continue to benefit from those old systems until the wear out.

And if they ever need replacement parts, they will pay extra just to get a 486 motherboard that fits the old case and runs they old software. No joke.
8896.

Solve : Trouble with Incrementing a Variable?

Answer»

I am attempting to WRITE a program that will ping a list of machines on our network and INCREMENT a variable based on whether or not a reply is received. The program reads the IP's from a host file and should ping each machine X amount of times. Then the variables for successes and failures will be compared (this part isn't written yet) and run some commands. However, I can not seem to get the counterOK and counterFailed variables to increment. I have been working on this for two days and I think I just need another set of eyes to point me in the right direction. This is the what I have so far.



@ECHO off
title Network Monitor
REM set variables for batch file
set NrOfPings=3
set counterOK=0
set counterFailed=0
set dPath=c:\users\%username%\desktop\monitor\
set hostfile=%dPath%myhosts.txt
set pingLog=%dPath%ping.txt

if EXIST del %pingLog%

REM echo %hostfile%
REM echo %pingLog%
REM echo %counterOK%
REM echo %counterFailed%
REM pause


REM create a loop to go through the ip addresses in the host file
for /f %%z in (%hostfile%) do (
set counterOK=0
set counterFailed=0
rem create a loop to ping each machine 10 times
for /l %%i in (1, 1, %NrOfPings%) do (
echo this is attempt %%i for IP %%z


ping -n 1 %%z > %pingLog%
find "Reply from" %pingLog%
IF ERRORLEVEL 0 set /a counterOK=%counterOK%+1
IF NOT ERRORLEVEL 0 set /a counterFailed=%counterFailed%+1
echo good:%counterOK% bad:%counterFailed%
echo.
PAUSE
ECHO.
)
)

del %pingLog%
pause

exit





Any help would be greatly appreciated.
not sure how to count++ increment in batch either, so I will be keeping an eye on this thread for how. Its easy in other languages. Just never done it in batch to be able to show how.This is an oldie but goodie. I knew when I saw the thread title what the problem was. Everybody who reaches the level in batch scripting of using loops seems to wonder "Why don't my variables change value in a loop?" The answer is to do with the way that the command interpreter expands variables before running a script. Variables which are set (and read) inside a loop or other parenthetical structure such as a FOR loop or extended IF structure or a && or || block will NOT change unless you use DELAYED EXPANSION.

1. Put this command before the loop. At the top of the batch file straight under the @echo off LINE is as good as anywhere else.

setlocal enabledelayed expansion

2. The variables inside the loop don't have percent signs before and after - they use exclamation MARKS instead.

3. There are a zillion web pages about it... take your pick...

http://www.google.com/search?source=ig&hl=en&rlz=&q=delayed+expansion&aq=0&aqi=g3g-v4g-m3&aql=&oq=delayed+expa





Code: [Select]setlocal enabledelayedexpansion
REM create a loop to go through the ip addresses in the host file
for /f %%z in (%hostfile%) do (
set counterOK=0
set counterFailed=0
rem create a loop to ping each machine 10 times
for /l %%i in (1, 1, %NrOfPings%) do (
echo this is attempt %%i for IP %%z
ping -n 1 %%z > %pingLog%
find "Reply from" %pingLog%
IF !errorlevel! equ 0 (
set /a counterOK+=1
) else (
set /a counterFailed+=1
)
echo good:!counterOK! bad:!counterFailed!
echo.
PAUSE
ECHO.
)
)Humm. The batch command

setlocal enabledelayed expansion

is a Windows Batch command, not an MS-DOS batch comand. Won't work with MS-DOS 6.x or PC-DOS 7.


I don't believe that MS-DOS has a counter batch command native to it.

Years ago in the 80's & 90's I used an MS-DOS executable that I called from the batch file when I needed a counter. I can't recall the exact name but when I'm home next week I'll see if I can dig it out.Quote from: aoresteen on June 22, 2011, 03:10:59 PM

Humm. The batch command

setlocal enabledelayed expansion

is a Windows Batch command, not an MS-DOS batch comand.

Yes, we know! Your point is?

It's not just Windows - the OP's code is clearly Windows NT family batch scripting language.

PC-DOS 7 has Rexx.





Better to pipe the output of Ping into FIND and look for the text "TTL", because "Reply from" in the output of PING does not always indicate a positive response. You may receive a message from a router such as: Reply from 192.168.1.254: Destination Net Unreachable.

Also no need for log.txt.

Code: [Select]setlocal enabledelayedexpansion
REM create a loop to go through the ip addresses in the host file
for /f %%z in (%hostfile%) do (
set counterOK=0
set counterFailed=0
rem create a loop to ping each machine 10 times
for /l %%i in (1, 1, %NrOfPings%) do (
echo this is attempt %%i for IP %%z
ping -n 1 %%z | find "TTL=" > nul
IF !errorlevel! equ 0 (
set /a counterOK+=1
) else (
set /a counterFailed+=1
)
echo good:!counterOK! bad:!counterFailed!
echo.
PAUSE
ECHO.
)
)I made the changes suggested in the replies but the variables still refuse to increment. I should have mentioned this in the beginning but this batch file will be running in a Windows 7/Server 2008 environment. Here is what I have changed the code to


@echo off
setlocal enabledelayedexpansion
title Network Monitor

REM set variables for batch file
set NrOfPings=3
set counterOK=0
set counterFailed=0
set dPath=c:\users\%username%\desktop\monitor\
set hostfile=%dPath%myhosts.txt

REM create a loop to go through the ip addresses in the host file
for /f %%z in (%hostfile%) do (
set counterOK=0
set counterFailed=0
rem create a loop to ping each machine 10 times
for /l %%i in (1, 1, %NrOfPings%) do (
echo this is attempt %%i for IP %%z


ping -n 1 %%z | find "TTL" > nul
IF !ERRORLEVEL! equ 0 (
set /a counterOK+=1
) else (
set /a counterFailed+=1
)
echo good:%counterOK% bad:%counterFailed%
echo.
PAUSE
ECHO.
)
)

pause

exit

Code: [Select]echo good:%counterOK% bad:%counterFailed%
I told you already you need to use exclamation marks, not percent signs, with delayed expansion in loops.
sorry I missed that line. It works now!

Thanks!!Quote from: Salmon Trout on June 22, 2011, 03:43:43 PM
Yes, we know! Your point is?

It's not just Windows - the OP's code is clearly Windows NT family batch scripting language.

PC-DOS 7 has Rexx.

Sorry Salmon. I don't see where in the OP posting he says he's using Windows:

"..I am attempting to write a program that will ping a list of machines on our network and increment a variable based on whether or not a reply is received. The program reads the IP's from a host file and should ping each machine X amount of times. Then the variables for successes and failures will be compared (this part isn't written yet) and run some commands. However, I can not seem to get the counterOK and counterFailed variables to increment. I have been working on this for two days and I think I just need another set of eyes to point me in the right direction. This is the what I have so far."

I guess since I'm a DOS guy I didn't consider Windows batch code.

My main DOS is PC DOS 7 and I do use REXX on occasion but I never assume every DOS user has REXX available to them. Glad he's sorted it out.

Quote from: aoresteen on June 27, 2011, 08:42:27 PM
Sorry Salmon. I don't see where in the OP posting he says he's using Windows:

In his code the use of for /f and for /l (absent in MS-DOS and Win 9x) confirm that he is writing for cmd.exe, the NT family command interpreter. In his revised code, the second line, where he invokes delayed variable expansion, identifies the environment as a Windows 2000 or later version of cmd.exe.



8897.

Solve : xml file rename problem?

Answer»

I have to rename a image file based on an xml file. Here is the xml.



sales
abc company
lexmark_Jun_23_2011_15_27_40_504.tif


so the image file would be
c:\scans\lexmark_Jun_23_2011_15_27_40_504.tif

The XML and image file are in the same folder.
I want to end up with "sales_abc company.tif" and have the orginal tif and xml deleted

Can you help? I was going to GO to php but say another post where you did it with VB so I thought I would ask.Code: [Select]@echo off
set xmlfile=test.xml
for /f "tokens=1-2 delims=^<^>" %%A in ( ' type %xmlfile% ^| find "imagefile" ' ) do set imagename=%%B
ren "%imagename%" "sales_abc company.tif"
del "%xmlfile%"

So Bill has graduated from just being a damned nuisance to poisoning threads with malicious "code". Please ignore the troll. His post contains an attempt at SABOTAGE. This line would obliterate the image file!

Code: [Select]echo hello > %imagename%
I sure hope the OP does not act upon any PM he may have received.



Posts removed.
Sorry didn't catch it sooner Salmon...

patio.Quote from: patio on June 25, 2011, 12:54:58 PM

Posts removed.
Sorry didn't catch it sooner Salmon...

patio.

Never mind... it enlivened the thread a bit...
The script I posted above will correctly process the xml file posted by the OP to isolate the TIF filename. It then proceeds to rename the TIF, and delete the xml file, which, as the OP says...

Quote
are in the same folder.

I have tested this with an actual TIF from my scanned images folder. It works. It would work with any arbitrarily named file.

Since a certain troll INSISTS on polluting this thread, I am disabling notification of replies to avoid recurrent annoyance from this character.



This might be a BAD time to point out that I don't like your poetry.Quote from: BC_Programmer on June 27, 2011, 12:46:22 PM
This might be a bad time to point out that I don't like your poetry.

Did you mean me? Or the idiot?
Quote from: Salmon Trout on June 27, 2011, 01:10:31 PM
Did you mean me? Or the idiot?
The latter of course. You mean you haven't read my poetry?

I'll go out on a limb here and guess bill ain't real good at poetry...A good idea to lock this thread?
done
8898.

Solve : How to enlarge the window "code included"?

Answer»
I have been messing around with the code bellow.
How can you enlarge the WINDOW wihout draging with the mouse.

I would like to set the size of the window within the code.

How do i do it.



@echo off
@color 0a
title Buddy Box
:a
cls
echo =========================
echo Windows 7 64BIT BuddyBox
echo =========================
echo.
echo 1) Mozilla Firefox
echo 2) Internet Explorer
echo 3) Windows Media Player
echo 4) Notepad
echo 5) Regedit
echo 6) Calculator
echo 7) Wordpad
echo 8) Command Prompt
echo 9) Charactor Map
echo 10) On-Screen Keyboard
echo 11) Disk Cleanup
echo 12) Command Prompt
echo 13) Computer Management
echo 14) Control Panel
echo 15) Component Services
echo 16) Disk Defragmenter
echo 17) DirectX Diagnostic Tool
echo 18) Privatee Character Editor
echo 19) Event Viewer
echo 20) Volume Mixer
echo 21) Snipping Tool
echo 22) Sound Recorder
echo 23) Sticky Notes
echo 24) Create Restore Point
echo 25) Windows Task Manager
echo 26) User Account Control Settings






echo.
set /p op=Choose which application to open:
if %op%==1 goto 1
if %op%==2 goto 2
if %op%==3 goto 310

if %op%==4 goto 4
if %op%==5 goto 5
if %op%==6 goto 6
if %op%==7 goto 7
if %op%==8 goto 8
if %op%==9 goto 9
if %op%==10 goto 10
if %op%==11 goto 11
if %op%==12 goto 12
if %op%==13 goto 13
if %op%==14 goto 14
if %op%==15 goto 15
if %op%==16 goto 16
if %op%==17 goto 17
if %op%==18 goto 18
if %op%==19 goto 19
if %op%==20 goto 20
if %op%==21 goto 21
if %op%==22 goto 22
if %op%==23 goto 23
if %op%==24 goto 24
if %op%==25 goto 25
if %op%==26 goto 26




:1
start firefox.exe
goto a
:2
start iexplore.exe
goto a
:3
start wmplayer.exe
goto a
:4
start notepad.exe
goto a
:5
start regedit.exe
goto a
:6
start calc.exe
goto a
:7
start Wordpad.exe
goto a
:8
start cmd.exe
goto a
:9
start charmap.exe
goto a
:10
start osk.exe
goto a
:11
start cleanmgr.exe
goto a
:12
start cmd.exe
goto a
:13
start CompMgmtLauncher.exe
goto a
:14
start control.exe
goto a
:15
start dcomcnfg.exe
goto a
:16
start dfrgui.exe
goto a
:17
start dxdiag.exe
goto a
:18
start eudcedit.exe
goto a
:19
start eventvwr.exe
goto a
:20
start SndVol.exe
goto a
:21
start SnippingTool.exe
goto a
:22
start SoundRecorder.exe
goto a
:23
start StikyNot.exe
goto a
:24
start SystemPropertiesProtection.exe
goto a
:25
start taskmgr.exe
goto a
:26
start UserAccountControlSettings.exe

goto aUse the mode command after the @echo off statement:

MODE CON[:] [COLS=c] [LINES=n]

Good luck.

This is what i used.

MODE CON:cols=50 lines=32

Thank you
Much appreciated

Ya know?..... I had never DONE that before, but I just tried it and it works great, but.....
I had to use much higher numbers, due to the resolution of my screen. 150 and 65 worked great for me.

Thanks for that helpful tip. This day has not been wasted! Now I'm going to the movies.

Nice tip.

thanx
8899.

Solve : creating batch file to start up programs after one another, not at the same time?

Answer»

Sorry I tried searching the forum and goggling this, but can't seem to get anything to work.

I have a basic batch file to startup some programs and it works fine. But I am now trying to make it where one program starts after the one before it is finished.

I tried the /wait and timeout .
timeout 10 works in Win7, but not on XP, haven't tried it on vista.
/wait starts up the first program and won't start the REST of the programs unless I close the one before it.

This is my basic batch file.
Code: [Select]@echo off

start "" "C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe"
start "" "C:\Program Files\iTunes\iTunes.exe"
start "" "C:\Program Files\Corel\Corel Paint Shop Pro Photo XI\Corel Paint Shop Pro Photo.exe"
start "" "C:\Program Files\CoreFTP\coreftp.exe"

exit

Thank you for your assisstance.Not sure it's necessary to use start or wait or any sort of timeout. Try keeping it SIMPLE:

Code: [Select]@echo off

"C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe"
"C:\Program Files\iTunes\iTunes.exe"
"C:\Program Files\Corel\Corel Paint Shop Pro Photo XI\Corel Paint Shop Pro Photo.exe"
"C:\Program Files\CoreFTP\coreftp.exe"

exit

Good luck. Quote

But I am now trying to make it where one program starts after the one before it is finished.

Quote
/wait starts up the first program and won't start the rest of the programs unless I close the one before it.

According to the first quote above, this is what you want, isn't it?


Quote from: Salmon Trout on July 08, 2011, 01:02:14 PM
According to the first quote above, this is what you want, isn't it?

no I want program 1 to startup ...
then once it has finished loading, I want to keep that program open and then
program 2 starts up, and so on.

I want all programs to be open, but in a sequence. is that possible?Use

start "" "program 1.exe"
PING 127.0.0.1 -n X >nul
start "" "program 2.exe"
PING 127.0.0.1 -n X >nul
start "" "program 3.exe"
PING 127.0.0.1 -n X >nul

[etc]

Replace X with a number, which is 1 more than the number of seconds delay you require, e.g. for 10 seconds delay replace X with 11.




Quote from: Salmon Trout on July 08, 2011, 01:25:43 PM
Use

start "" "program 1.exe"
PING 127.0.0.1 -n X >nul
start "" "program 2.exe"
PING 127.0.0.1 -n X >nul
start "" "program 3.exe"
PING 127.0.0.1 -n X >nul

[etc]

Replace X with a number, which is 1 more than the number of seconds delay you require, e.g. for 10 seconds delay replace X with 11.

-AH! Thank you very much!! That worked!
What does all that mean if you don't mind explaining?

I wonder why I have to use PING for XP
but Win7 reads it fine with timeout #?

very confusing for me :p

Much appreciated!Quote from: sehana on July 08, 2011, 01:30:46 PM
What does all that mean if you don't mind explaining?

When you use start like this ("title" can just be 2 quotes "" but cannot be left out) start "title" "program.exe" then the script starts program.exe and then returns at once, leaving program.exe running. So now you want to wait for a period of time before starting the next program. Ping can provide that delay and works with all versions of Windows. 127.0.0.1 is the IP address of the same computer that the script is running on. Its name is localhost. The ping command can take a parameter -n followed by a number which is the number of times to ping. The standard ping interval is 1 second. So ping -n 11 sends the first request and it gets a reply immediately, waits one second, sends the next request, gets an immediate reply, and so on – for the ten requests after the first. So to localhost those 11 times takes exactly 10 seconds. We redirect the output to nul so we don't see the ping command or its output on the screen.

Quote
I wonder why I have to use PING for XP but Win7 reads it fine with timeout #?

The reason why you cannot use timeout with XP is that the timeout.exe program was not included with XP. It was first introduced in Vista.

Thank You!!
I understand it much better now

I was wondering what the ping was for and didn't understand it, but now I understand, thank you Quote from: sehana on July 08, 2011, 02:36:11 PM
I was wondering what the ping was for and didn't understand it, but now I understand, thank you

http://en.wikipedia.org/wiki/Ping

Reading the OP's request I'm wondering why nobody has given the answer yet.

I've been doing the same thing in batch files for somewhere around 30 years, or so.

This would be my SOLUTION:

@Echo off
cls
call program1
call program2
call program3
Rem this batch file will close after program3 runs.


The rule for the "Call" command is that it will maintain the entire batch file in memory till the last program being called closes.
No line can execute till the previous line has completed.

Without the call command, the batch file would close when the first program runs and the subsequent programs would never run at all.

I do hope this helps.


PS: Or more specifically......

@Echo off
cls
Call "C:\Program Files\GIMP-2.0\bin\gimp-2.6.exe"
Call "C:\Program Files\iTunes\iTunes.exe"
Call "C:\Program Files\Corel\Corel Paint Shop Pro Photo XI\Corel Paint Shop Pro Photo.exe"
Call "C:\Program Files\CoreFTP\coreftp.exe"
Quote from: TheShadow on July 09, 2011, 08:42:02 AM
Reading the OP's request I'm wondering why nobody has given the answer yet.

You APPEAR to be answering a question other than the one the OP asked. If you read the whole thread, you will see that he (or she) wishes to start a program, wait a short while, then start a second program, then wait a short while, then start a third program, and so on. He does not wish to run the programs in sequence, closing one before running the next.

Quote
Without the call command, the batch file would close when the first program runs and the subsequent programs would never run at all.

This only applies to other batch files. You can start an executable program and depending on the syntax used for the start command, control will return to the batch script either at once or when the program has terminated.

8900.

Solve : Rename multiple folders using Dos commands?

Answer»

Hi There,

I am a content uploader for mobile phones. I need to format various content provided by the vendors to ours standard format. so, plz help me to rename multiple FOLDERS at one time to our desired format.

Example:

From Format
30x30png
40x30bmp
120x300_bmp
BMP270x300

To Format
png30x30
bmp40x30
bmp120x300
bmp270x300

Thanks!Hello,
The problem you have PRESENTED can easily be done in a batch file. However, there is some information that you have not given. What assurance is there that these file names are unique and will not encounter duplication when they are converted?
Here's why I ask. Programming involves more than just finding some code that takes care of a specific issue. Programming also involves foresight as to conflicts. Some mechanism is needed to guarantee the file names be unique.
This leads to the prospect of using a different method rather than just changing names in batch files. Without knowing more about what kind of system you're using, there should be some kind of library, database or index is able to keep track of files and a sign them a suitable alias reusing your system. Imperatively changing a file name can have serious consequences. The so-called DOS environment does not have a recursive tracking the history of a file, such as who the author was, what its original name was and other information like that. If you're doing ANYTHING on a very large scale you should be using some kind of database or library system and not relying just on DOS.
Okay. That is the end of my rant. I thought appropriate to say this because you indicate your going to be doing this over a large-scale and many other people would be affected by what you do. End of rant.

Somebody will come here and give you a neat clean solution to your problem using only DOS and no third-party programs.The folder names have no pattern, so writing a script would be problematic.

Folders 1 & 2: move three trailing characters to be three leading characters
Folder 3: same as two above folders and eliminate the underscore
Folder 4: Replace three leading uppercase characters with lowercase characters

The logic for folder 1,2,3 can be combined into a single script block. Folder 4 PRESENTS a problem. Not only will it require a separate script block, but there is no characteristic to key off of in order to determine when to activate that script block.

This little snippet will handle folders 1,2,3:

Code: [SELECT]@echo off
setlocal enabledelayedexpansion

for /f "tokens=* delims=*" %%i in ('dir /b /ad') do (
set dirname=%%i
set dirname1=!dirname:_=!
set prefix=!dirname1:~-3!
set suffix=!dirname1:~0,-3!
ren !dirname! !prefix!!suffix!
)

Path information is your responsibility. As for folder #4, converting uppercase to lowercase can be done, but as mentioned there is nothing inherent in the folder name to distinguish it from the other three.

Good luck.

I would humbly suggest brute force:

Code: [Select]@echo off
ren 30x30png png30x30
ren 40x30bmp bmp40x30
ren 120x300_bmp bmp120x300
ren BMP270x300 bmp270x300

Hi Sidewinder/Geek-9pm,

I really appreciate your support for the scripts and about letting me know the scale of the problem.

Thanks!
Sravan
Hi,

Guys can we execute the script based on the idea..

(special character)(file type:png/bmp)(special character)[size](special character)(file type:png/bmp)(special character)

Special character= all wild characters like (.,_-$#@!%^&*..etc)
Size=100x100, 200x100 ..etc
file type: png/bmp Lower case letters.
I'm just not getting it. The original solution was specific to the sample folder names you posted.

What is this?
Quote

(special character)(file type:png/bmp)(special character)[size](special character)(file type:png/bmp)(special character)


Depending on the language, special characters need to be escaped, or not, depending on their usage. You're creating unneeded problems.

Pattern matching and replacements can be accomplished by using regular expressions (RegEx). The RegEx engine in batch is next to useless, but VBScript, Powershell, Python, and Perl along with many UNIX utilities can handle most tasks. Is that a possibilty?

The easiest solution of course would be to tell your vendors what format to supply their content in.

Let use know. Hi,

Thanks for the advice..i won't be WORRYING any of us..will go with the brute force as you mentioned..its easy..and more over..i am new to programming and interested to write scripts..so i wish to try.. anyways will stay connected to learn.

Regards,
Sravan Hello,
I am also in the similar situation, trying to rename folders. I just need to get rid of "_den" suffix from folders' name. For e.g.
I want to rename "Warde_den" to "Warde"; "Divide_NW_den" to "Divide_NW"; "Tripoli_NW_SE_den" to "Tripoli_NW_SE" etc...

Should be easy..but I am new to programming and need help.

Plz help..

Nav