MSFN Forum: Feature request: remove need for workstations service - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Feature request: remove need for workstations service replace OS verification routine Rate Topic: -----

#1 User is offline   HolgerHops 

  • Group: Members
  • Posts: 2
  • Joined: 30-November 03

Posted 09 August 2008 - 06:10 AM

First I would like to thank you for this great script.

On my computer the workstation service is disabled, so the script hangs when it tries to figure out the OS version.

Problem lies here:
 
:: Find host OS - based on code posted by Yzöwl on MSFN.org
SET HostOS=Unknown
FOR /F "DELIMS=" %%I IN ('NET CONFIG WORK^|FIND /I " Windows "') DO (
	ECHO %%I|FIND "2000">NUL 2>&1&&(SET HostOS=2000&GOTO :HOSD)
	ECHO %%I|FIND "2002">NUL 2>&1&&(SET HostOS=XP&GOTO :HOSD)
	ECHO %%I|FIND "2003">NUL 2>&1&&(SET HostOS=2003&GOTO :HOSD)
	ECHO %%I|FIND /I "Vista">NUL 2>&1&&(SET HostOS=Vista&GOTO :HOSD)
) 

as this code relies on the workstation service to function properly.

This Code should do the same, but doesn't rely on the workstation service:
 
FOR /F "DELIMS=" %%I IN ('ver') DO (
	ECHO %%I|FIND "2000">NUL 2>&1&&(SET HostOS=2000&GOTO :HOSD)
	ECHO %%I|FIND "XP">NUL 2>&1&&(SET HostOS=XP&GOTO :HOSD)
	ECHO %%I|FIND "2003">NUL 2>&1&&(SET HostOS=2003&GOTO :HOSD)
	ECHO %%I|FIND /I "VISTA">NUL 2>&1&&(SET HostOS=Vista&GOTO :HOSD)
) 



#2 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 October 2008 - 08:56 AM

Sorry to add to a topic which has lay here silently for a couple of months but the reason for using that particular method was that VER returns only the version of the command interpreter not the running Operating System!

#3 User is offline   Tomalak 

  • Member
  • PipPip
  • Group: Members
  • Posts: 162
  • Joined: 24-January 06

Posted 31 October 2008 - 03:58 PM

View PostYzöwl, on Oct 31 2008, 04:56 PM, said:

Sorry to add to a topic which has lay here silently for a couple of months but the reason for using that particular method was that VER returns only the version of the command interpreter not the running Operating System!

Hm, for me (German Windows XP Pro) it displays "Microsoft Windows XP [Version 5.1.2600]". So is it possible that someone runs another command interpreter with his OS (let's say the Win 2000 version of cmd.exe with Win XP), misleading the mentioned code to assume the wrong OS? Shouldn't happen on a clean source though...
In the end it's just a matter of taste - the wish to have hfslip working even with disable workstation service may also not be that common.

#4 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 31 October 2008 - 04:37 PM

First thing I'd be interested in is why anyone would see the need to disable that service. By doing so, not only would you be unable to connect to any shared file or print resources on a network you'd also in effect not be able to use several other dependent services. Although I'm sure that some 'extreme home users' may have disabled it, using the batch scripting methods employed with HFSLIP it is still the best command interpreter independent method of determining the OS.

My suggestion without deliberately trying to find an alternative solution would be to incorporate a check for the services status first, if it isn't running then choose an alternate course of action to achieve your goal.
Net start|Find "Work"


As an alternative idea, you could use the attached executable I've created.
For /f "delims=" %%# In ('NTOS.exe') Do Set "HostOS=%%#"
The possible returned values are:
  • <empty>
    Best found with If Not Defined HostOS
    This will indicate an unknown or non-NT based OS
  • NT 3.51
  • NT 4.0
  • 2000
  • XP
  • 2003
  • Vista
    This will be returned for Windows Vista or 2008


I hope it comes in useful to those of you requiring it!

Attached File(s)

  • Attached File  NTOS.zip (238.35K)
    Number of downloads: 12


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy