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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error when running Vbscript--error 800A004C

Status
Not open for further replies.

OHSLG

Technical User
Oct 2, 2012
1
US
This script used to run fine, then we suddenly started to get the 800A004C error - "Path not found".
The error occurs on the line that states "fs.createFolder(currpath)".


'=============================================
' VARIABLES
'=============================================
' Base Variables
Set wshell = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")

strUserName = cmd("echo %username%") ' Set variable to the Windows login user name
'strProfilePath = cmd("echo %userprofile%")

strProfilePath = "H:"
strLocalUserProfiledirectory= strProfilePath & "\VMFGINI\"
strInstallDirectory = "C:\Infor\VISUAL Enterprise\VISUAL Manufacturing"
strStdINIDirectory = "\\SUSCDCSQLN02\visual\Admin654\Standard INI Files"


'=================================================================================================

'=============================================
' PROGRAM - Check to see if the program had been run before else begin
'=============================================


if not fs.fileexists(strLocalUserProfiledirectory & "Visual.ini") then
makefolder strLocalUserProfiledirectory
end if

addreg
cpyStdIni(strLocalUserProfiledirectory)
'msgbox "Visual has been configured"

deletebuildinfo

'=============================================
'FUNCTIONS
'=============================================

'---------------------------------------------
function makeFolder(strFolder)
'---------------------------------------------
foldersplit = split(strFolder,"\")
for each folderitem in foldersplit
currpath = currpath & folderitem & "\"
if not fs.folderexists(currpath) then
fs.createFolder(currpath) end if
next
end function


'---------------------------------------------
function addreg()
'---------------------------------------------
wshell.RegWrite "HKEY_CURRENT_USER\Software\Infor Global Solutions\VISUAL Manufacturing\Configuration\Local Directory", strLocalUserProfiledirectory
wshell.RegWrite "HKEY_CURRENT_USER\Software\Infor Global Solutions\VISUAL Manufacturing\Configuration\InstallDirectory", strInstallDirectory
end function



'---------------------------------------------
function deletebuildinfo()
'---------------------------------------------

wshell.Run "cmd /C REG DELETE HKCU\Software\Identification\other\buildinformation /va /f"
wshell.Run "cmd /C REG DELETE HKEY_LOCAL_MACHINE\Software\Identification\other\buildinformation /va /f"

end function


'---------------------------------------------
Function Cmd(cmdline) ' Function to get results from a console command
'---------------------------------------------
fOut = fs.GetTempName
sCmd = "%COMSPEC% /c " & cmdline & " >" & fOut
wshell.Run sCmd, 0, True
If fs.FileExists(fOut) Then
If fs.GetFile(fOut).Size>0 Then
Set OutF = fs.OpenTextFile(fOut)
Cmd = trim(replace(OutF.Readall,vbcrlf,""))
OutF.Close
End If
fs.DeleteFile(fOut)
End If
End Function





'------------------------------------------------------------
Function cpyStdIni(sPath)
'------------------------------------------------------------
' Copy standard ini files
dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
' Don't copy Visual.ini file
' filesys.CopyFile strStdINIDirectory & "\Visual.ini", sPath
filesys.CopyFile strStdINIDirectory & "\*.vms", sPath

end function

 
Question: Where do you intialize currpath ? I may have missed it but all I see is:


foldersplit = split(strFolder,"\")
for each folderitem in foldersplit
currpath = currpath & folderitem & "\"
if not fs.folderexists(currpath) then
fs.createFolder(currpath) end if
next



Windows Haiku:

Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
 
msgbox currpath and see what it is equal to. Also, the .createFolder method will fail it any parent folder does not exist. For example, if the folder c:\temp exists and I want to create c:\temp\shows\breaking_bad, this attempt will fail because c:\temp\shows does not exist.

In the past, I'v used a recursive function to create a directory structure.

Code:
function createDirectory (strDir)
	set objFSO = CreateObject("Scripting.FileSystemObject")
	if (right(strDir, 1) = "\") then strDir = left(strDir, len(strDir) - 1)
	strParentDir = objFSO.GetParentFolderName(strDir)
	if NOT (objFSO.FolderExists(strParentDir)) then createDirectory (strParentDir)
	if NOT (objFSO.FolderExists(strDir)) then objFSO.CreateFolder (strDir)
end function

'usage
createDirectory("c:\temp\shows\breaking_bad\season1")

-Geates

"I do not offer answers, only considerations."
- Geates's Disclaimer

 
As far as I can tell the script should work. currpath doesn't need to be initialized, because it starts as a blank string and disappears once the makeFolder function loses scope. And the makeFolder function does recursively create all the parent folders (though, a bit awkwardly).

My vote is for the script not having access to the H: drive
 
Geates: I meant the OP's function called makeFolder. And I shouldn't have used the term "recursively"... What I meant is that the OP's function appears to do the job of creating the folder (including parent folders if they do not exist)
 
Oops. I didn't even notice his function makeFolder even though it is the subject of the OP!! I guess that would make my replies moot; well, mostly :)

I would still recommend you echo [tt]strFolder[/tt] before the loop begins and [tt]currpath[/tt] during the loop to validate the data.

-Geates

"I do not offer answers, only considerations."
- Geates's Disclaimer

 
I should also add that [tt]800A004C error - "Path not found".[/tt] is not a vbscript error; it is a logical error. This further suggests something is wrong with the values of [tt]strFolder[/tt] and [tt]currpath[/tt]

-Geates
Note: It'd be nice if I was able to edit/append to my previous posts.

"I do not offer answers, only considerations."
- Geates's Disclaimer

 
Wouldn't the script give a permissions error if the running account does not have access to the H: drive path? Definitly need to follow Geates's troubleshooting path echo out those variables so that you can visually see where it is looking at. Verify the folder structure namings is correct as well, maybe someone renamed a folder or something.

Windows Haiku:

Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top