Skip to content

VBS > GPO

Featured Replies

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
  • Author

If you try, even a little bit, you can see that it's all about registry keys and values.

 

Yeah I can see the registry changes that it's making. But it's also making ODBCs as well, which is above my head.

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.