Jump to content


  • 0
bowlen

VBS > GPO

Question

Hi All,

 

I have a client who has just emailed me a VBS and asked me to convert it into a GPO. My experience with VB is pretty much 0, so this looks chinese to me. Could someone give me a hand as to what would be required to translate this into a GPO?

 

Option Explicit
on error resume next
dim strEnviroNew, strEnviroOld
Dim WshShell, OsType, objReg
dim registry, strServer
dim result
Dim strComputer, OsResult
dim strKeyPath, strValueName, strValue
Const HKEY_LOCAL_MACHINE = &H80000002
const REG_KEY_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ODBC\ODBC.INI\ODBC Data Sources"
strServer = "canauth\authority"
Set WshShell = CreateObject("WScript.Shell")
strServer = "adm-auth-test\authtest"
CreateOdbc("authcantest")
CreateOdbc("authcandev")
CreateOdbc("authcantrain")
CreateOdbc("authcanconv")
CreateOdbc("authngtest")
strServer = "canauth\authority"
CreateOdbc("authcanlive")
CreateOdbc("authnglive")
wscript.quit
Function CreateOdbc(strEnviroNew)
Dim objReg
Dim strComputer
dim strKeyPath, strValueName, strValue
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set WshShell = CreateObject("WScript.Shell")
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
If OsType = "x86" then
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
else
strKeyPath = "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\ODBC Data Sources"
end if
strValueName = strEnviroNew
strValue = "SQL Server"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If OsType = "x86" then
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\" & strEnviroNew
else
strKeyPath = "SOFTWARE\Wow6432Node\ODBC\ODBC.INI\" & strEnviroNew
end if
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strValueName = "Database"
strValue = strEnviroNew
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Description"
strValue = strEnviroNew
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Driver"
strValue = "C:\WINDOWS\System32\SQLSRV32.dll"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "QuotedId"
strValue = "No"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Server"
strValue = strServer
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Trusted_Connection"
strValue = "Yes"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
End Function

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.