[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Need help with getting Win Versions and use it as argument
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

Need help with getting Win Versions and use it as argument

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Posted by Dpcompower   (1 post)  [Biography] bio
Date Tue 09 Aug 2011 01:28 AM (UTC)
Please help me sort this out!!!
We started a vbs a below. What we need is read computer names from text file, then copy file to each PC depending on the Windows version of that PC. Somehow (it guess I'm not good enough) the part where processing Windows version didn't work correctly. If I remove and just copy file without check Win versions then it works fine.


Option Explicit
'Read name from TTT.txt file and copy file depending on Windows Version
Sub CopyFileToPCs(FileName)
  Const dFileName  = "ProxyFix.bat"
  Const TargetDir = "\c$\Documents and Settings\All Users\Start Menu\Programs\Startup\"
  Const TargetDir1 = "\c$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\"
  Const ForReading = 1
  Const Overwrite = TRUE
  Dim objFSO
  Dim objFile
  Dim strComputer
  Dim strVersion
  Dim strVers

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.OpenTextFile(FileName)
  On Error Resume Next
  Do Until objFile.AtEndOfStream
    strComputer = objFile.ReadLine
	strVers = GetVer(strComputer)
	If strVers = "Microsoft Windows X" Then
    objFSO.CopyFile dFileName, "\" & strComputer & TargetDir & dFileName, Overwrite
	objFSO.CopyFile dFileName, "\" & strComputer & TargetDir1 & dFileName, Overwrite
	End If
End Sub

Function GetVer(ComputerName)
Dim strVersion
Dim strVer
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & ComputerName & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
	strVersion = objOperatingSystem.Caption
	strVer = Left(strVersion, 19)
	Wscript.Echo strVer
	GetVer = strVer
    'Wscript.Echo objOperatingSystem.Caption & "  " & objOperatingSystem.Version
End Function

CopyFileToPCs("TTT.txt") 'testing
[Go to top] top

Posted by Fiendish   USA  (1,724 posts)  [Biography] bio   Global Moderator
Date Reply #1 on Tue 09 Aug 2011 02:23 PM (UTC)

Amended on Tue 09 Aug 2011 02:25 PM (UTC) by Fiendish

First, there's no such thing as "Windows X".

Second, from http://mushclient.com/scripts/doc.php?function=GetInfo
You can deduce the operating system as follows by using GetInfo (265) through to GetInfo (268):

If platform ID == 0 (Win32s) then:
you should not get this, MUSHclient doesn't run under Win32s

If platform ID == 1 (Windows 95-style versions) then:

If major == 4 and minor == 0 then: Windows 95
If major == 4 and minor == 10 then: Windows 98 (or 98SE)
If major == 4 and minor == 90 then: Windows ME

If platform ID == 2 (Windows NT versions) then:

If major == 3 then: Windows NT 3.51
If major == 4 then: Windows NT 4
If major == 5 and minor == 0 then: Windows 2000
If major == 5 and minor == 1 then: Windows XP
If major == 5 and minor == 2 then: Windows Server 2003
If major == 6 and minor == 0 then: Windows Vista, or Windows Server Longhorn
If major == 6 and minor == 1 then: Windows 7

[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #2 on Wed 10 Aug 2011 09:20 AM (UTC)
And third - this is a forum dedicated to VBScripting inside the MUSHclient application, something you very likely aren't looking to do. :)

I am sure people are willing to help you with your questions, but it is unlikely that we will be able to help you as well as, say, a forum dedicated to general-purpose VBS scripting.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]