|
Need help with getting Win Versions and use it as argument
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Dpcompower
(1 post) bio
|
| Date |
Tue 09 Aug 2011 01:28 AM (UTC) [ quote
] |
| 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 (848 posts) bio
Global Moderator |
| Date |
Reply #1 on Tue 09 Aug 2011 02:23 PM (UTC) [ quote
] 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
|
http://aardwolfclientpackage.googlecode.com/ | top |
|
| Posted by |
Worstje
Netherlands (867 posts) bio
|
| Date |
Reply #2 on Wed 10 Aug 2011 09:20 AM (UTC) [ quote
] |
| 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.
1,317 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )