Active Directoryでコンピュータオブジェクトを検索するVBScriptを作成しています。オブジェクトが存在しないか、存在し、正しいOUにある場合は、コンピュータをADに作成/結合する別のスクリプトを実行する必要があります。ステートメント条件が満たされずにコードが実行されています
ObjExist_CorrectOU_7 = Null
ObjExist_CorrectOU_10 = Null
If compare = True Then
Win7_OU = "OU=DisallowRDP,OU=64Bit,OU=Win8"
Win10_OU = "OU=DisallowRDP,OU=64Bit,OU=Win10"
For x = 16 To 46
If Asc(Mid(objRS.Fields("distinguishedName"), x, 1)) = Asc(Mid(Win7_OU, (x - 15), 1)) Then
ObjExist_CorrectOU_7 = True
Else
ObjExist_CorrectOU_7 = False
End If
Next
For y = 16 To 46
If Asc(Mid(objRS.Fields("distinguishedName"), y, 1)) = Asc(Mid(Win10_OU, (y - 15), 1)) Then
ObjExist_CorrectOU_10 = True
Else
ObjExist_CorrectOU_10 = False
End If
Next
End If
If ObjExist_CorrectOU_7 = True Then
WScript.Echo "TRUE"
End If
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
filename = "C:\programdata\dell\kace\k2000_deployment_info.conf"
Win7_Deployment = "deployment_name=Windows 7 x64 with SP1, join AD"
Win10_Deployment = "deployment_name=Development Windows 10 (x64), join AD"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filename)
Do While Not f.AtEndOfStream
If ((f.ReadLine = Win7_Deployment) Or ((f.ReadLine = Win7_Deployment) And (ObjExist_CorrectOU_7 = True))) Then
WScript.Echo "IT WORKED!"
'objShell.Run "JoinAD_Win7.vbs"
Exit Do
End If
On Error Resume Next
Loop
f.Close
Set g = fso.OpenTextFile(filename)
Do While Not f.AtEndOfStream
If ((g.ReadLine = Win10_Deployment) Or ((g.ReadLine = Win10_Deployment) And (ObjExist_CorrectOU_10 = True))) Then
'objShell.Run "JoinAD_Win10.vbs"
WScript.Echo "IT WORKED AGAIN!"
Exit Do
End If
On Error Resume Next
Loop
g.Close
Set objShell = Nothing
私はに実行している問題は、2つのIf..Then
文が、私は条件が全く満たされていない知っているにもかかわらず、毎回実行することです。
私はOr
とAnd
を使用する必要がありますか?
ようこそStackOverflow;あなたの最初の質問を投稿していただきありがとうございます。あなたが話している特定の声明を特定してください。新規ユーザーには、[よくある質問をする方法](http://stackoverflow.com/help/how-to-ask)、[完璧な質問](http://codeblog.jonskeet .uk/2010/08/29/writing-the-perfect-question /)と[最小限で完全で検証可能な例](http://stackoverflow.com/help/mcve)を参照してください。それに応じて質問を編集することを検討してください。 – MikeC