A file that exists only on XP?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am doing a batch file with an "if exist" statement so I can ensure that
the script goes to XP boxes and not servers. I am looking to check for the
presence of a file which would only be present on an XP box but not server.

Can anyone suggest a file that I could use for this?
 
Maybe you could use the results of the VER command instead of relying on
the presence of files.

John
 
Hello,

I am doing a batch file with an "if exist" statement so I can ensure that
the script goes to XP boxes and not servers. I am looking to check for
the presence of a file which would only be present on an XP box but not
server.

Can anyone suggest a file that I could use for this?

Instead of looking for a file that exists/does not exist, consider using a
command that reports specifically what type of machine you're on. Here are
two of them:

@echo off
ver
net accounts | find /i "role"
 
I agree that's probably better I just don't know how to work that into the
IF statement...
 
@echo off
ver | find /i "XP Workstation"
if %ErrorLevel% EQU 0 echo This is a WinXP Workstation
 
Pegasus,
I don't understand how Mr dash finds success in :

@echo off
ver | find /i "XP Workstation"
if %ErrorLevel% EQU 0 echo This is a WinXP Workstation

???

....since the output of the ver command (on my machine at least) is :

Microsoft Windows XP [Version 5.1.2600]

....so [find /i "XP Workstation"] would not work!!


Please clarify this for me.

==

Cheers, Tim Meddick, Peckham, London. :-)
 
I suspect that Mr. dash did not religiously copy my code but modified it
like so:

ver | find /i "Windows XP"

in order to compensate for my mistake in mixing the output from the two
commands
ver
net accounts

Thanks for pointing out my error! :-)


Tim Meddick said:
Pegasus,
I don't understand how Mr dash finds success in :

@echo off
ver | find /i "XP Workstation"
if %ErrorLevel% EQU 0 echo This is a WinXP Workstation

???

...since the output of the ver command (on my machine at least) is :

Microsoft Windows XP [Version 5.1.2600]

...so [find /i "XP Workstation"] would not work!!


Please clarify this for me.

==

Cheers, Tim Meddick, Peckham, London. :-)




Pegasus said:
@echo off
ver | find /i "XP Workstation"
if %ErrorLevel% EQU 0 echo This is a WinXP Workstation
 
Thanks - I wasn't trying to be "clever" or point out mistakes - I
genuinely did not know if I was missing something.

Thankyou again for clarification.

==

Cheers, Tim Meddick, Peckham, London. :-)




Pegasus said:
I suspect that Mr. dash did not religiously copy my code but modified
it like so:

ver | find /i "Windows XP"

in order to compensate for my mistake in mixing the output from the
two commands
ver
net accounts

Thanks for pointing out my error! :-)


Tim Meddick said:
Pegasus,
I don't understand how Mr dash finds success in :

@echo off
ver | find /i "XP Workstation"
if %ErrorLevel% EQU 0 echo This is a WinXP Workstation

???

...since the output of the ver command (on my machine at least) is :

Microsoft Windows XP [Version 5.1.2600]

...so [find /i "XP Workstation"] would not work!!


Please clarify this for me.

==

Cheers, Tim Meddick, Peckham, London. :-)




Pegasus said:
@echo off
ver | find /i "XP Workstation"
if %ErrorLevel% EQU 0 echo This is a WinXP Workstation


<-> wrote in message I agree that's probably better I just don't know how to work that
into the IF statement...


<-> wrote in message Hello,

I am doing a batch file with an "if exist" statement so I can
ensure that the script goes to XP boxes and not servers. I am
looking to check for the presence of a file which would only be
present on an XP box but not server.

Can anyone suggest a file that I could use for this?

Instead of looking for a file that exists/does not exist, consider
using a command that reports specifically what type of machine
you're on. Here are two of them:

@echo off
ver
net accounts | find /i "role"
 
I'm actually glad you noticed my mistake. This is one of the advantages of
newsgroup: Peer review. It increases the confidence level for posters who
may otherwise attempt to implement a useless or damaging solution to their
problem.
 
This is what I used:

echo on
ver | find "5.1"
if not errorlevel 1 (
CALL \\server1\share\batchfile1.cmd
) else (
goto :eof
)


@Shenan - This was not a Google situation. I initially was trying to find a
file that existed only on XP and after Googling extensively could not find a
lock. I posted here, and an alternate suggestion was offered. I know how
to search Google, that's how I found the syntax for this code to select
"5.1" But thanks for bringing it up.
 
Looks good. You could simplify it further, if only because the logic is a
lot easier to understand than the double negative you're forced to use in
your implementation:

echo on
ver | find "5.1" || goto :eof
call \\Server\share\batchfile1.cmd
 
You're right that is easier. Of course, I just put it into production today
so at this point I won't even breathe on it.

Thanks again for your help!
 
Pegasus,
I had major problems testing the code you posted - it was
some time before I worked out that the cause was not your script but the
character set.

On 'copying and pasting' your posted script, the "bar" redirectional
character did not come out as 0x7C but came out as 0xDD instead thus
wrecking the functionality of the batch file.

Just thought you might like to know as it might be a bit of a hazard if
it were code given to help someone who was not so well acquainted with
batch programming as Mr dash...

==

Cheers, Tim Meddick, Peckham, London. :-)
 
Back
Top