Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Need help with getting Win Versions and use it as argument
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 page
Posted by
| Dpcompower
(1 post) Bio
|
Date
| Tue 09 Aug 2011 01:28 AM (UTC) |
Message
| 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
'WScript.ECho(strComputer)
strVers = GetVer(strComputer)
WScrtipt.ECho(strVers)
If strVers = "Microsoft Windows X" Then
objFSO.CopyFile dFileName, "\" & strComputer & TargetDir & dFileName, Overwrite
Else
objFSO.CopyFile dFileName, "\" & strComputer & TargetDir1 & dFileName, Overwrite
End If
Loop
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
Next
End Function
CopyFileToPCs("TTT.txt") 'testing
| Top |
|
Posted by
| Fiendish
USA (2,535 posts) 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
|
Message
| First, there's no such thing as "Windows X".
Second, from http://mushclient.com/scripts/doc.php?function=GetInfo
Quote: 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
|
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #2 on Wed 10 Aug 2011 09:20 AM (UTC) |
Message
| 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.
| 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.
18,735 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top