Help Needed Combining Scripts

Author Message
alastair79

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 11/29/2011
  • Status: offline
Help Needed Combining Scripts Tuesday, November 29, 2011 8:36 PM (permalink)
0
Hello, complete VBeginner here. I have managed to the create the two following scripts that do what I need but I don't know how to get them to be in the same script file so I don't need two. Below are the scripts:
 
Script 1:
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
'find user name
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
'find user group's
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
'if user member of a group then map network drive
Select Case strGroupName
Case "Arm-All_Users"
objNetwork.MapNetworkDrive "N", "\\ukarmf02\pccommon"
Case "Dub-All_Users"
objNetwork.MapNetworkDrive "N", "\\ukdubfp02\groups\pccommon"
Case "BK-UK-Dublin-AcCommon"
objNetwork.MapNetworkDrive "P", "\\ukdubfp02\groups\accommon"
Case "BK-UK-Otley-All_Users"
objNetwork.MapNetworkDrive "N", "\\ukotlfp02\pccommon"
Case "BK-UK-Otley-SCCommon"
objNetwork.MapNetworkDrive "J", "\\ukotlfp02\sccommon"
End Select
Next
 
Script 2:
Option Explicit
'Variable for shell object
Dim wshShell
'Variable for redirecting Folders
Dim strFavoriteRedirectRegKey
Dim strFavoriteRedirectLocation
Dim strFavoriteRedirectRegType
Dim strFavoriteRedirectRegKey2
Dim strFavoriteRedirectLocation2
Dim strFavoriteRedirectRegType2
Dim strPicturesRedirectRegKey
Dim strPicturesRedirectLocation
Dim strPicturesRedirectRegType
Dim strPicturesRedirectRegKey2
Dim strPicturesRedirectLocation2
Dim strPicturesRedirectRegType2
Dim strDocumentsRedirectRegKey
Dim strDocumentsRedirectLocation
Dim strDocumentsRedirectRegType
Dim strDocumentsRedirectRegKey2
Dim strDocumentsRedirectLocation2
Dim strDocumentsRedirectRegType2
Dim strSyncMgrInitializedRegKey
Dim strSyncMgrInitializedLocation
Dim strSyncMgrInitializedRegType
Dim strNoRemindersRegKey
Dim strNoRemindersLocation
Dim strNoRemindersRegType
'CREATE GLOBAL OBJECTS
Set wshShell = CreateObject("WScript.Shell")
'Folder Redirection Registry Info
strFavoriteRedirectRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Favorites"
strFavoriteRedirectLocation = "I:\redirectTest\Favorites"
strFavoriteRedirectRegType = "REG_SZ"
strFavoriteRedirectRegKey2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites"
strFavoriteRedirectLocation2 = "I:\redirectTest\Favorites"
strFavoriteRedirectRegType2 = "REG_EXPAND_SZ"
strPicturesRedirectRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures"
strPicturesRedirectLocation = "I:\redirectTest\My Pictures"
strPicturesRedirectRegType = "REG_SZ"
strPicturesRedirectRegKey2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures"
strPicturesRedirectLocation2 = "I:\redirectTest\My Pictures"
strPicturesRedirectRegType2 = "REG_EXPAND_SZ"
strDocumentsRedirectRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal"
strDocumentsRedirectLocation = "I:\redirectTest\My Documents"
strDocumentsRedirectRegType = "REG_SZ"
strDocumentsRedirectRegKey2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal"
strDocumentsRedirectLocation2 = "I:\redirectTest\My Documents"
strDocumentsRedirectRegType2 = "REG_EXPAND_SZ"
strSyncMgrInitializedRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\NetCache\SyncMgrInitialized"
strSyncMgrInitializedLocation = "1"
strSyncMgrInitializedRegType = "REG_DWORD"
strNoRemindersRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\NetCache\NoReminders"
strNoRemindersLocation = "0"
strNoRemindersRegType = "REG_DWORD"
'Redirect Folders by writing registry entry.
wshShell.RegWrite strFavoriteRedirectRegKey, strFavoriteRedirectLocation, strFavoriteRedirectRegType
wshShell.RegWrite strFavoriteRedirectRegKey2, strFavoriteRedirectLocation2, strFavoriteRedirectRegType2
wshShell.RegWrite strPicturesRedirectRegKey, strPicturesRedirectLocation, strPicturesRedirectRegType
wshShell.RegWrite strPicturesRedirectRegKey2, strPicturesRedirectLocation2, strPicturesRedirectRegType2
wshShell.RegWrite strDocumentsRedirectRegKey, strDocumentsRedirectLocation, strDocumentsRedirectRegType
wshShell.RegWrite strDocumentsRedirectRegKey2, strDocumentsRedirectLocation2, strDocumentsRedirectRegType2
wshShell.RegWrite strSyncMgrInitializedRegKey, strSyncMgrInitializedLocation, strSyncMgrInitializedRegType
wshShell.RegWrite strNoRemindersRegKey, strNoRemindersLocation, strNoRemindersRegType
 
#1
    alastair79

    • Total Posts : 2
    • Scores: 0
    • Reward points : 0
    • Joined: 11/29/2011
    • Status: offline
    Re:Help Needed Combining Scripts Tuesday, November 29, 2011 10:33 PM (permalink)
    0
    Think I sorted it now, I had to name the varianles from the 1st script when I combined. Added below so if someone wants to look and see if I done it right that would be cool:
     
    Option Explicit
    'Variables
    Dim wshShell
    'Variable for redirecting Folders
    Dim strFavoriteRedirectRegKey
    Dim strFavoriteRedirectLocation
    Dim strFavoriteRedirectRegType
    Dim strFavoriteRedirectRegKey2
    Dim strFavoriteRedirectLocation2
    Dim strFavoriteRedirectRegType2
    Dim strPicturesRedirectRegKey
    Dim strPicturesRedirectLocation
    Dim strPicturesRedirectRegType
    Dim strPicturesRedirectRegKey2
    Dim strPicturesRedirectLocation2
    Dim strPicturesRedirectRegType2
    Dim strDocumentsRedirectRegKey
    Dim strDocumentsRedirectLocation
    Dim strDocumentsRedirectRegType
    Dim strDocumentsRedirectRegKey2
    Dim strDocumentsRedirectLocation2
    Dim strDocumentsRedirectRegType2
    Dim strSyncMgrInitializedRegKey
    Dim strSyncMgrInitializedValue
    Dim strSyncMgrInitializedRegType
    Dim strNoRemindersRegKey
    Dim strNoRemindersValue
    Dim strNoRemindersRegType
    Dim objSysInfo
    Dim objNetwork
    Dim objUser
    Dim strUserPath
    Dim strGroupPath
    Dim strGroupName
    Dim objGroup
    Dim strGroup
    On Error Resume Next
    Set objSysInfo = CreateObject("ADSystemInfo")
    Set objNetwork = CreateObject("Wscript.Network")
    'find user name
    strUserPath = "LDAP://" & objSysInfo.UserName
    Set objUser = GetObject(strUserPath)
    'find user group's
    For Each strGroup in objUser.MemberOf
    strGroupPath = "LDAP://" & strGroup
    Set objGroup = GetObject(strGroupPath)
    strGroupName = objGroup.CN
    'if user member of a group then map network drive
    Select Case strGroupName
    Case "Arm-All_Users"
    objNetwork.MapNetworkDrive "N", "\\ukarmf02\pccommon"
    Case "Dub-All_Users"
    objNetwork.MapNetworkDrive "N", "\\ukdubfp02\groups\pccommon"
    Case "BK-UK-Dublin-AcCommon"
    objNetwork.MapNetworkDrive "P", "\\ukdubfp02\groups\accommon"
    Case "BK-UK-Otley-All_Users"
    objNetwork.MapNetworkDrive "N", "\\ukotlfp02\pccommon"
    Case "BK-UK-Otley-SCCommon"
    objNetwork.MapNetworkDrive "J", "\\ukotlfp02\sccommon"
    End Select
    Next
    'CREATE GLOBAL OBJECTS
    Set wshShell = CreateObject("WScript.Shell")
    'Folder Redirection Registry Info
    strFavoriteRedirectRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Favorites"
    strFavoriteRedirectLocation = "M:\Favorites"
    strFavoriteRedirectRegType = "REG_SZ"
    strFavoriteRedirectRegKey2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites"
    strFavoriteRedirectLocation2 = "M:\Favorites"
    strFavoriteRedirectRegType2 = "REG_EXPAND_SZ"
    strPicturesRedirectRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\My Pictures"
    strPicturesRedirectLocation = "M:\My Documents\My Pictures"
    strPicturesRedirectRegType = "REG_SZ"
    strPicturesRedirectRegKey2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\My Pictures"
    strPicturesRedirectLocation2 = "M:\My Documents\My Pictures"
    strPicturesRedirectRegType2 = "REG_EXPAND_SZ"
    strDocumentsRedirectRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal"
    strDocumentsRedirectLocation = "M:\My Documents"
    strDocumentsRedirectRegType = "REG_SZ"
    strDocumentsRedirectRegKey2 = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal"
    strDocumentsRedirectLocation2 = "M:\My Documents"
    strDocumentsRedirectRegType2 = "REG_EXPAND_SZ"
    strSyncMgrInitializedRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\NetCache\SyncMgrInitialized"
    strSyncMgrInitializedValue = "1"
    strSyncMgrInitializedRegType = "REG_DWORD"
    strNoRemindersRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\NetCache\NoReminders"
    strNoRemindersValue = "0"
    strNoRemindersRegType = "REG_DWORD"
    'Redirect Folders by writing registry entry.
    wshShell.RegWrite strFavoriteRedirectRegKey, strFavoriteRedirectLocation, strFavoriteRedirectRegType
    wshShell.RegWrite strFavoriteRedirectRegKey2, strFavoriteRedirectLocation2, strFavoriteRedirectRegType2
    wshShell.RegWrite strPicturesRedirectRegKey, strPicturesRedirectLocation, strPicturesRedirectRegType
    wshShell.RegWrite strPicturesRedirectRegKey2, strPicturesRedirectLocation2, strPicturesRedirectRegType2
    wshShell.RegWrite strDocumentsRedirectRegKey, strDocumentsRedirectLocation, strDocumentsRedirectRegType
    wshShell.RegWrite strDocumentsRedirectRegKey2, strDocumentsRedirectLocation2, strDocumentsRedirectRegType2
    wshShell.RegWrite strSyncMgrInitializedRegKey, strSyncMgrInitializedValue, strSyncMgrInitializedRegType
    wshShell.RegWrite strNoRemindersRegKey, strNoRemindersValue, strNoRemindersRegType
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9