![]() |
|
|||||||
| ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum? |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello All,
I haven’t a clue as to how to go about writing vbscripts, but I’ve been able to get quite a bit done by visiting various forums and asking various questions of my peers and such. I however have run into a snag that for the life of my I can’t figure out. The script below speaks to the creation of a folder, the deletion of any content in that folder (if of course it exists), the creation of a folder within that folder, the dropping of files into the root and sub folders and finally the creation of a shortcut on the user’s desktop. All of these functions work as expected but only when logging onto the system with a user that has administrative privileges i.e.: me. What I’m needing to do is have the script assign the “domain\domain users” write and delete privileges to the “c:\databases” folder. But again I for the life of me can’t figure this out. Where I think I’m getting confused is 1. where to place the string to allow for this functionality and 2. What statement actually allow for it, (I’ve found so many that that I don’t know what to use). If one of you can modify this script for me to allow for the assignment of these permissions that would be great. Thank you Shannon 'region Script Settings '<ScriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd"> ' <ScriptPackager> ' <process>cscript.exe</process> ' <arguments /> ' <extractdir>%TEMP%</extractdir> ' <files /> ' <usedefaulticon>true</usedefaulticon> ' <showinsystray>false</showinsystray> ' <altcreds>false</altcreds> ' <efs>true</efs> ' <ntfs>true</ntfs> ' <local>false</local> ' <abortonfail>true</abortonfail> ' <product /> ' <version>1.0.0.1</version> ' <versionstring /> ' <comments /> ' <includeinterpreter>false</includeinterpreter> ' <forcecomregistration>false</forcecomregistration> ' <consolemode>false</consolemode> ' <EnableChangelog>false</EnableChangelog> ' <AutoBackup>false</AutoBackup> ' </ScriptPackager> '</ScriptSettings> 'endregion '$$$$ Version 2007-10-10 $$$$ 'Compiled/Written by Shannon Harvey, 2007-2008 ' 11:00 PM 10/09/2007: ADD: WriteLog() function. See Usage below ' 12:25 AM 10/10/2007: ADD: Print successfull isMember() functions to the log file. ' 12:01 AM 10/10/2007: ADD: isComputerMember function Check group membership for computers ' 1:07 AM 10/10/2007: MOD: Cleaned up code a bit, properly empty objects and some other minor changes ' 1:20 AM 10/10/2007: ADD: Run Command: Execute external files ' 1:31 AM 10/10/2007: ADD: FileCopy Command: Execute external files ' 10:17 AM 10/10/2007: FIX: Driveletter remap issue in the DriveMapper sub ' 10:40 AM 10/10/2007: FIX: Error handling in isComputerMember function in case group referred does not exist. ' 10:44 AM 10/10/2007: ADD: Support for Cross Domain Authentication. Set bolEnableCrossDomain to True below. ' I have only tested this on XP and 2003. Vista is an unknown '11:00 AM 10/10/2007: FIX: Option Explicit revealed some undefined variables. '11:16 AM 10/10/2007: ADD: RemovePrintersFromServer to remove all printers connected to a server '11:36 AM 10/10/2007: ADD: isThisIP function to match against active IP addresses on the computer. Option Explicit Dim strLogName, bolWriteLog, bolManagePrinters, bolEnableCrossDomain strLogName = "script.log" ' Filename of log to write to in the temp folder. bolWriteLog = True ' Toggles log-writing. I like it on, you may like it off. bolManagePrinters = True ' Windows 9x doesn't do very well with printer management, set this to false to disable bolEnableCrossDomain = False ' Toggles Cross Domain Authentication. Reads registry to obtain NetBIOS domain for the machine. 'Script Begins Here Dim fso Set fso = CreateObject("Scripting.FileSystemObject") if not fso.FolderExists("C:\Databases\") Then fso.CreateFolder("C:\Databases\") End If if not fso.FolderExists("C:\Databases\Reports") Then fso.CreateFolder("C:\Databases\Reports") End If if not fso.FileExists("C:\Databases\*.mdb") Then End If fso.CopyFile "\\SBSNTSERVER1\Apps\HealthBridge\HealthBridge.mdb ", "C:\Databases\HealthBridge.mdb" fso.DeleteFile "C:\Databases\*.mdb", True Dim objNetwork, objDrives, objDict, objComputer, objShell, objFileSystem, objLogFile, objRootDSE, objTrans Dim strComputerName, strDomain, strUser, strAdsPath, strNetBIOSDomain, strDNSDomain, strTemp, strLogPath, i Set objNetwork = WScript.CreateObject("Wscript.Network") Set objDrives = objNetwork.EnumNetworkDrives Set objShell = WScript.CreateObject("WScript.Shell") strComputerName = objNetwork.ComputerName strDomain = objNetwork.UserDomain strUser = objNetwork.UserName strAdsPath = strDomain & "/" & strUser If bolEnableCrossDomain Then On Error Resume Next strNetBIOSDomain = objShell.RegRead _ ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName") If Not err.number = 0 Then MsgBox "Problem reading the computer's domain name from the Registry." & Chr(10) & _ "Please set ""bolEnableCrossDomain"" to False", vbCritical, "Logon Script Error" WScript.quit End If On Error goto 0 Else strNetBIOSDomain = strDomain End If 'Set objComputer = GetObject("WinNT://" & strNetBIOSDomain & "/" & strComputerName & ",computer") strTemp = objshell.ExpandEnvironmentStrings("%TEMP%") strLogPath = strTemp & "\" & strLogName '" Set objFileSystem = WScript.CreateObject("Scripting.FileSystemObject") If bolWriteLog Then 'initialize log file On Error Resume Next Set objLogFile = objFileSystem.OpenTextFile(strLogPath, 2, True) '" writelog "############### Start Login Script ##################" If Not err.number = 0 Then MsgBox "There was a problem opening the log file for writing." & Chr(10) & _ "Please check whether """ & strLogPath & """ is a valid file and can be openend for writing." & _ Chr(10) & Chr(10) & "If you're not sure what to do, please contact your support person.",vbCritical, "Logon Script Error" WScript.quit End If On Error goto 0 End If |
|
This ad is part of our Revenue Sharing program |