ajtsystems
IS-IT--Management
Hi,
I have a script which I have compilled to collect some file paths. it uses set objShell = CreateObject("shell.application") and then copies files using these properties
shellfolder.CopyHere (arrmem), 20
I am getting an error on line 53 which says object required "shellfolder" but I know its in the code on line 5. Here is y code:
Const strInFile = "hostlist.txt"
Const ForReading = 1
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("shell.application")
set Shellfolder = objShell.NameSpace(backupdir)
Dim objInFile, objOutFile
Set objInFile = objFSO.OpenTextFile(strInFile,ForReading, False)
backupdir = "c:\copy1"
Do Until objInFile.AtEndOfStream
strUser = "username"
strpassword= "password"
strComputer = objInFile.Readline
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
'Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, "root\WebAdministration", "username", "password", ms406)
Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, "root\WebAdministration", ms406)
objSWbemServices.Security_.authenticationLevel = 6
Set colitems = objSWbemServices.ExecQuery("Select physicalpath From virtualdirectory")
for each objapp in colitems
arrMem = array(objapp.physicalpath)
for i = 0 to UBound(arrMem)
call backup (arrmem(i))
next
next
Loop
'===========================================================================
'Sub receives file paths from IIS and copies themand their contnets to directory speciied in backupdir
sub backup (arrmem)
'backupfldr=InputBox("Please enter your backup folder destination","Userinput")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Note If..Exists. Then, Else ... End If construction
If objFSO.FolderExists(backupdir) Then
Set objFolder = objFSO.GetFolder(backupdir)
'WScript.Echo strDirectory & " Direcroty already created "
Else
' Set objFolder = objFSO.CreateFolder(backupdir)
'WScript.Echo "Directory created " & backupdir
End If
shellfolder.CopyHere (arrmem), 20
set objfso = nothing
end sub
I is possibly a bug or maybe a problem in windows 7. BTW I have disabled UAC. Any help woukd be good
I have a script which I have compilled to collect some file paths. it uses set objShell = CreateObject("shell.application") and then copies files using these properties
shellfolder.CopyHere (arrmem), 20
I am getting an error on line 53 which says object required "shellfolder" but I know its in the code on line 5. Here is y code:
Const strInFile = "hostlist.txt"
Const ForReading = 1
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("shell.application")
set Shellfolder = objShell.NameSpace(backupdir)
Dim objInFile, objOutFile
Set objInFile = objFSO.OpenTextFile(strInFile,ForReading, False)
backupdir = "c:\copy1"
Do Until objInFile.AtEndOfStream
strUser = "username"
strpassword= "password"
strComputer = objInFile.Readline
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
'Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, "root\WebAdministration", "username", "password", ms406)
Set objSWbemServices = objSWbemLocator.ConnectServer (strComputer, "root\WebAdministration", ms406)
objSWbemServices.Security_.authenticationLevel = 6
Set colitems = objSWbemServices.ExecQuery("Select physicalpath From virtualdirectory")
for each objapp in colitems
arrMem = array(objapp.physicalpath)
for i = 0 to UBound(arrMem)
call backup (arrmem(i))
next
next
Loop
'===========================================================================
'Sub receives file paths from IIS and copies themand their contnets to directory speciied in backupdir
sub backup (arrmem)
'backupfldr=InputBox("Please enter your backup folder destination","Userinput")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Note If..Exists. Then, Else ... End If construction
If objFSO.FolderExists(backupdir) Then
Set objFolder = objFSO.GetFolder(backupdir)
'WScript.Echo strDirectory & " Direcroty already created "
Else
' Set objFolder = objFSO.CreateFolder(backupdir)
'WScript.Echo "Directory created " & backupdir
End If
shellfolder.CopyHere (arrmem), 20
set objfso = nothing
end sub
I is possibly a bug or maybe a problem in windows 7. BTW I have disabled UAC. Any help woukd be good