iT邦幫忙

0

logon script 判斷 Windows 10

  • 分享至 

  • xImage

各位前輩~
我公司目前Logan script會在登入時檢查作業系統版本然後安裝某些軟體
但只有win7登入時會作動,現在想加入win8 & win8.1 &win10
請問該如何修改?
內容如下 :
If PCName = "IRVINE-LIU-N01" Then
Else
Set objOSs = objWMIService.ExecQuery ("Select Caption from Win32_OperatingSystem")
For Each objOS In objOSs
'Wscript.Echo "OS:" & objOS.caption
If objOS.Caption = "Microsoft Windows XP Professional" Then
'WScript.Sleep 12000
'Wscript.Echo "os is : " & objOS.Caption & " Sleep 10 second "

		Set objFSO = CreateObject("Scripting.FileSystemObject")		
		If Not objFSO.FileExists("C:\Program Files\Sophos\AutoUpdate\ALsvc.exe") Then
			If PCName = "sayuri-peng" Or PCName = "IT-R401" Then 
				'Wscript.Echo "Sophos install jump!!" 
			Else
				'Wscript.Echo "Install Sophos, Please waiting a moment!! " 
				cmdstr="\\ICHSSAV01\SophosUpdate\sophos-install.bat"
				result=objShell.run("%comspec% /c " & cmdstr,0,true)
				'				 
			End If 
		End If 
		If Not objFSO.FileExists("C:\Program Files\OCS Inventory Agent\OCSService.exe") Then
			'Wscript.Echo "Install Sophos, Please waiting a moment!! " 
			cmdstr="\\ichsfs01.icatchtek.com.tw\SW\GeneralSW\OCS\DeployPackage\OCSPACKAGE.exe"
			result=objShell.run("%comspec% /c " & cmdstr,0,true)				 
		End If '
	End If 
	'Wscript.Echo "before win 7 detect ... " 
	'If objOS.Caption = "Microsoft Windows 7 專業版" Then
	If Left(objOS.Caption,19) = "Microsoft Windows 7" Then
		'WScript.Sleep 12000
		'Wscript.Echo "os is : " & objOS.Caption  & "  Sleep 10 second " 
	
		Set objFSO = CreateObject("Scripting.FileSystemObject")		
		If Not objFSO.FileExists("C:\Program Files\Sophos\Sophos Anti-Virus\SavService.exe") and Not objFSO.FileExists("C:\Program Files (x86)\Sophos\AutoUpdate\ALsvc.exe") Then
			If PCName = "IT-R405" Or PCName = "IT-R401" or PCName = "edward-kuo-n02" Then 
				'Wscript.Echo "Sophos install jump!!" 
			Else
				'Wscript.Echo "Install Sophos, Please waiting a moment!! " 
				cmdstr="\\ICHSSAV01\SophosUpdate\sophos-install.bat"
				result=objShell.run("%comspec% /c " & cmdstr,0,true)
				'				 
			End If 
		End If 
		If Not objFSO.FileExists("C:\Program Files\OCS Inventory Agent\OcsService.exe") and Not objFSO.FileExists("C:\Program Files (x86)\OCS Inventory Agent\OcsService.exe") Then
			'Wscript.Echo "Install Sophos, Please waiting a moment!! " 
			cmdstr="\\ichsfs01.icatchtek.com.tw\SW\GeneralSW\OCS\DeployPackage\OCSPACKAGE.exe"
			result=objShell.run("%comspec% /c " & cmdstr,0,true)				 
		End If '
	End If 
Next

End If
'
Set objWord = CreateObject("Word.Application")
objWord.UserName = objUser.cn
objWord.UserInitials = Left(objUser.cn, 1) & Left(objUser.SN, 1)
objWord.Quit

doublehow iT邦新手 5 級 ‧ 2016-08-02 14:02:53 檢舉
看起來是vbs包wmi
有沒有考慮從cmd下手
doublehow iT邦新手 5 級 ‧ 2016-08-02 14:06:30 檢舉
例如:
REM --------------[作業系統WIN7]--------------

ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 xcopy "\\pc1\share\a.lnk" "C:\Users\Public\Desktop\" /Y



REM --------------[作業系統WIN8]--------------

ver | findstr /i "6\.2\." > nul
IF %ERRORLEVEL% EQU 0 xcopy "\\pc1\share\a.lnk" "C:\Users\Public\Desktop\" /Y



REM --------------[作業系統WIN8.1]--------------

ver | findstr /i "6\.3\." > nul
IF %ERRORLEVEL% EQU 0 xcopy "\\pc1\share\a.lnk" "C:\Users\Public\Desktop\" /Y



REM --------------[作業系統WIN10]--------------

ver | findstr /i "10\.0\." > nul
IF %ERRORLEVEL% EQU 0 xcopy "\\pc1\share\a.lnk" "C:\Users\Public\Desktop\" /Y
jojochen iT邦新手 5 級 ‧ 2016-08-17 14:44:43 檢舉
可以使用wmi的取得Registry的值:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]

Operating System Version如下網址:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx

再搭配select case判斷windows版本別
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答