Re: Scrip Help



gbrown135 wrote:
I have created this script to remove a user's home drive from the
server by reading AD. The script is as follows: Can you check why
this doesn't work?

dim strUser, strDomain, strUserDN
dim objUser, objTrans, objFSO, objFolder
dim HomeShare

Const ForReading = 1
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1

strUser = InputBox("Enter User Name")

strDomain = "Globalinfra"

Set objTrans = CreateObject("NameTranslate")

objTrans.Init ADS_NAME_INITTYPE_GC, ""

objTrans.Set ADS_NAME_TYPE_NT4, strDomain & "\" & strUser

strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)

Set objUser = GetObject("LDAP://"; & strUserDN)

HomeShare = objUser.homeDirectory

set objFSO = createobject("scripting.filesystemobject")

objFolder = objFSO.GetFolder(HomeShare)

You need the Set statement for an object reference. Without it all you get
is the default property (or an assignment error if there is no default
property).

Set objFolder = objFSO.GetFolder(HomeShare)


objFolder.Delete True

This is still however getting an error on line objFolder.Delete True
it comes with an error saying: Object required:
'\\Serevrname\Homedrive$'. I think that due to my Home Drive being in
ShareName rather than UNC format. Maybe i will need to query server
first. Do you know how that is done?

--
Michael Harris
MVP- Admin Frameworks


.



Relevant Pages

  • Re: jpg file name change
    ... Dim objFSO As Object ... Dim objFolder As Object ... Dim objFile As Object ...
    (microsoft.public.excel.programming)
  • Re: jpg file name change
    ... Dim objFSO As Object ... Dim objFolder As Object ... Dim objFile As Object ...
    (microsoft.public.excel.programming)
  • Re: VB code to count the number of folders within a directory
    ... Private Sub Command1_Click ... Dim objFSO As Object ... Dim objFolder As Object ...
    (microsoft.public.access.formscoding)
  • Re: Creating folders using VB Script
    ... 'Creates new sub folders in all folders in the specified path. ... Dim objFSO As Scripting.FileSystemObject ... Dim objFolder As Scripting.Folder ...
    (microsoft.public.scripting.vbscript)
  • Re: Copy and move mail to folder
    ... Dim obj As Object ... Dim objFolder As Outlook.MAPIFolder ... Set objInbox = objNS.GetDefaultFolder ... Because the mail folder could contain different objects you must not use ...
    (microsoft.public.outlook.program_vba)