Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBScript to import reg file if the machine name=xxx?

$
0
0

Hi,

Here is my vbscript which checks the computer name and then it'll run the registry key if the first 3 letters of machine code matches. But unfortunately it's not working. Please help me..

'------------------------------
' Computer name
'------------------------------
Dim COMPUTER_NAME

Dim oFso, sShell, oShellEnv, target, source
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oShell = WScript.CreateObject("WScript.Shell")
Set oShellEnv = oShell.Environment("Process")
COMPUTER_NAME = oShellEnv("ComputerName")

'MsgBox COMPUTER_NAME

'------------------------------
' First Three
'------------------------------
Dim FIRST_THREE

FIRST_THREE = Mid(COMPUTER_NAME, 1, 3)

'MsgBox FIRST_THREE

'------------------------------
' Get Run Registry
'------------------------------
Dim IS_RUN_REGISTRY

If FIRST_THREE = "HAC" Then
IS_RUN_REGISTRY = true
Else
IS_RUN_REGISTRY = false
End If

'MsgBox "[" & FIRST_THREE & "][" & IS_RUN_REGISTRY & "] "

'------------------------------
' Run Registry if needed
'------------------------------
Set regFile = "Genesis.reg"

If IS_RUN_REGISTRY Then
Set oShell = CreateObject("Wscript.Shell")
sRegFile = regFile
 
oShell.Run "regedit.exe /s " & Chr(34) & sRegFile & Chr(34), 0, True
End If


Viewing all articles
Browse latest Browse all 15028

Trending Articles