Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell.application

Status
Not open for further replies.

ajtsystems

IS-IT--Management
Jan 15, 2009
80
GB
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






 
Code:
set Shellfolder = objShell.NameSpace(backupdir)
backupdir is not defined for a few lines. Shellfolder will equal nothing. Thus, line 53, will error out.

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top