The 800A004C Path not found
error message does not come from shown code snippet.
It comes from "hiddenhost.vbs"
script.
Troubleshooting Code 800A004C — Path not found
For once error 800A004C is not the VBScript’s fault. Check the name
of the file and or folder referenced in the script.Introduction to Error 800A004C
Error 800A004C occurs when you execute a VBScript. My suggestion is that you are trying to read, or
write, to a file reference that does not exist. A wild guess, there
is a typo in your Path statement.Code 800A004C Error — Path not found.
VBScript MicrosoftThe Symptoms You Get 800A004C
When you get a WSH pop-up message box. Put on your detective hat and pay close attention to the line
number. Error 800A004C is a runtime error, so the problem is likely
to outside your script, there could be something the matter with a
file location.
The Cause of Error 800A004C
In the example above, Line 12: is the source of the error. Char 1: is not always very useful as the
error could be anywhere on the line and char 1 will be blamed by WSH.
(Windows Script Host)The cause of error 800A004C is likely to be that the folder that you
wish to create the file does not exist. The VBScript is capable of
creating the file, but there is no such directory.
Error raised from objShell.Run "hiddenhost.vbs"
would be 80070002
if target file (command) does not exist.
I need to create vbscript which will create new folder ‘test’ and subfolder ‘Output’.There is already a folder structure C:Documents and SettingsAll UsersApplication DataFmwire,I need to create testOutput under those structure
I have created vbscript like this but i am getting error like this
Error: Path not found
Code: 800A004C
Source: Microsoft VBScript runtime error
Const OSCPATH = "FmwiretestOutput"
Const ALL_USERS_APPLICATION_DATA = &H23&
Dim fso ' File System Object
Dim objApplication ' Application object
Dim objFolder ' Folder object
Dim objFolderItem ' FolderItem object
Dim fname ' Path to Settings folder
Set objApplication = CreateObject("Shell.Application")
Set objFolder = objApplication.Namespace(ALL_USERS_APPLICATION_DATA)
Set objFolderItem = objFolder.Self
fname = objFolderItem.Path & OSCPATH
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(fname) Then
Set objFolder = fso.GetFolder(fname)
Else
Set objFolder = fso.CreateFolder(fname)
If Err Then
Err.Clear
strErr = SPOFOLDERFAIL
rCode = 4
End If
End If
What changes i have to do for correcting this
asked Apr 20, 2011 at 12:03
1
Const OSCPATH = "FmwiretestOutput"
Const ALL_USERS_APPLICATION_DATA = &H23&
Set objApplication = CreateObject("Shell.Application")
Set objFolder = objApplication.Namespace(ALL_USERS_APPLICATION_DATA)
Set objFolderItem = objFolder.Self
fname = objFolderItem.Path
Set fso = CreateObject("Scripting.FileSystemObject")
folders = Split(OSCPATH, "")
For i = 0 To UBound(folders)
fname = fso.BuildPath(fname, folders(i))
If fso.FolderExists(fname) Then
Set objFolder = fso.GetFolder(fname)
Else
Set objFolder = fso.CreateFolder(fname)
If Err Then
Err.Clear
strErr = SPOFOLDERFAIL
rCode = 4
End If
End If
Next
answered Apr 20, 2011 at 12:11
Kyle AlonsKyle Alons
6,9352 gold badges32 silver badges28 bronze badges
2
Добрый день,
Может кто-то сталкивался с подобной проблемой, если так, то прошу оказать консультативную помощь)
собственно проблема в следующем:
сохраняю путь к директорий с помощью переменной, а далее использую эту переменную в функциях
Все казалось бы элементарно, но парадокс, который мне не понятен, заключается в том, что скрипт выборочно работает на некоторых машинах.
Везде имеем XP SP3, пользователи доменные, доступ к папкам есть, файлы в директорий в ручную создаются, НО из 6 компьютеров, скрипт отрабатывает только на 3-х, на остальных имеем ошибку 800a004c, путь не найден..
кусок кода:
‘—————————————————————-
LogPath = «P:BIILog»
‘—————————————————————-
Set fso = CreateObject(«Scripting.FileSystemObject»)
currentDate = Date()
currentDate = Replace(currentDate, «.», «»)
If fso.FileExists(LogPath & «VBlog» & currentDate & «.log») Then
Set NewFile = fso.OpenTextFile(LogPath & «VBlog» & currentDate & «.log», ForAppending, True)
Else
Set NewFile = fso.CreateTextFile(LogPath & «VBlog» & currentDate & «.log», True)
End If
ошибка появляется на момент SET NewFile = fso.CreateTextFile
I’ve been making this script and I’m really stuck on this error! This’ just a saple of the entire thing, as that also has errors! It all goes very well until it gets to line 95 char. 4 (Highlighted in bold), where it comes up with error 800A04C — Path not
found.
I’m quite new to this, so I’ve probably made a mess of this!
The comments at the top of the script (in italics) give further data I thought you might need
Here it is…
‘This is just a sample of the entire script, as I need to get this working first before I can try and fix the
‘other bugs in the rest of it.
‘For the first inputbox, just press enter, for the second input box just type in this: password
‘And for the third input box, type in what you want the password to change into!
‘In the main script, this section changes a password so a user can personalise it or make a new one.
‘I’ve managed to make it work down to line 95 character 4, where it comes up with error 800A004C: Path not found
‘What it does without this bit it nearly what I want from it; to change one of the variables (the password), make it
‘save the changes, then overwrite the origional file and (if needed) rename itself the origional name (Password Protect).
‘I nearly have this cracked, I just need some help on the last hurdles!
‘======================================================
‘========= Define Variables
Dim sCurPath
dim fso, text, readfile, contents, x, writefile, SearchFor, ReplaceWith
dim FullFileName, ParentDirName, Filename, NewFilename
Dim Newfldr
set fso = CreateObject(«Scripting.FileSystemObject»)
set args = Wscript.Arguments
If not args.count = 0 then
File = args(0)
End If
‘========= Get user input
sCurPath = CreateObject(«Scripting.FileSystemObject»).GetAbsolutePathName(«.»)
FullFileName=inputbox(«Please input the Full Filename and Path», «Input Filename»,»» & sCurPath & «Password Protect.vbs», file)
‘========= Exit if filename not specified
If FullFileName=»» Then
Wscript.quit
End If
‘========= Get user input
SearchFor=inputbox(«Please input your old password:», «Search For»)
ReplaceWith=inputbox(«Please input your new password:», «Replace With»)
‘========= Determine path and filename components
ParentDirName = fso.GetParentFolderName(FullFileName)
Filename = fso.GetFileName(FullFileName)
NewFilename = ParentDirName & «» & «New» & «» & Filename
‘========= Test if Folder exists
Newfldr = ParentDirName & «» & «New»
set fso = CreateObject(«Scripting.FileSystemObject»)
If fso.FolderExists(Newfldr) Then
Else
MakeFolder
End if
‘========= Make Folder if needed
Function MakeFolder
set folder=fso.CreateFolder(NewFldr)
End Function
set readfile = fso.OpenTextFile(FullFileName, 1, false)
set writefile = fso.CreateTextFile(NewFileName, 2)
‘========= The bit that does the work
Do until readfile.AtEndOfStream = True
ThisLine = readfile.ReadLine
‘If Instr(ThisLine,SearchFor) = True Then
writefile.write Replace(ThisLine,SearchFor,ReplaceWith) & vbCRLF
‘Else
‘ writefile.write ThisLine & vbCRLF
‘End If
loop
‘========= Tidy Up
readfile.close
writefile.close
‘========= call message to say «All done»
‘========= popup will disappear by itself after one second.
Popup
Sub Popup
Dim Shell, msg
Set Shell = wScript.CreateObject(«wScript.Shell»)
Msg = «All done»
Timeout = 1
temp = Shell.Popup(Msg, Timeout, «Progress»)
if temp = -1 then
Const OverwriteExisting = TRUE
Set objFSO = CreateObject(«Scripting.FileSystemObject»)
objfso.CopyFile «» & sCurPath & «NewPassword Protect.vbs» , «» & sCurPath & «Password Protect», OverwriteExisting
wScript.Quit
End if
End Sub
‘another thing, you need to be in the same directory as this file for it to work, could someone maybe find a way around this too?
— — — — — frazzle14
The 800A004C Path not found
error message does not come from shown code snippet.
It comes from "hiddenhost.vbs"
script.
Troubleshooting Code 800A004C — Path not found
For once error 800A004C is not the VBScript’s fault. Check the name
of the file and or folder referenced in the script.Introduction to Error 800A004C
Error 800A004C occurs when you execute a VBScript. My suggestion is that you are trying to read, or
write, to a file reference that does not exist. A wild guess, there
is a typo in your Path statement.Code 800A004C Error — Path not found.
VBScript MicrosoftThe Symptoms You Get 800A004C
When you get a WSH pop-up message box. Put on your detective hat and pay close attention to the line
number. Error 800A004C is a runtime error, so the problem is likely
to outside your script, there could be something the matter with a
file location.
The Cause of Error 800A004C
In the example above, Line 12: is the source of the error. Char 1: is not always very useful as the
error could be anywhere on the line and char 1 will be blamed by WSH.
(Windows Script Host)The cause of error 800A004C is likely to be that the folder that you
wish to create the file does not exist. The VBScript is capable of
creating the file, but there is no such directory.
Error raised from objShell.Run "hiddenhost.vbs"
would be 80070002
if target file (command) does not exist.
Добрый день,
Может кто-то сталкивался с подобной проблемой, если так, то прошу оказать консультативную помощь)
собственно проблема в следующем:
сохраняю путь к директорий с помощью переменной, а далее использую эту переменную в функциях
Все казалось бы элементарно, но парадокс, который мне не понятен, заключается в том, что скрипт выборочно работает на некоторых машинах.
Везде имеем XP SP3, пользователи доменные, доступ к папкам есть, файлы в директорий в ручную создаются, НО из 6 компьютеров, скрипт отрабатывает только на 3-х, на остальных имеем ошибку 800a004c, путь не найден..
кусок кода:
‘—————————————————————-
LogPath = «P:BIILog»
‘—————————————————————-
Set fso = CreateObject(«Scripting.FileSystemObject»)
currentDate = Date()
currentDate = Replace(currentDate, «.», «»)
If fso.FileExists(LogPath & «VBlog» & currentDate & «.log») Then
Set NewFile = fso.OpenTextFile(LogPath & «VBlog» & currentDate & «.log», ForAppending, True)
Else
Set NewFile = fso.CreateTextFile(LogPath & «VBlog» & currentDate & «.log», True)
End If
ошибка появляется на момент SET NewFile = fso.CreateTextFile
Troubleshooting Code 800A004C – Path not found
For once error 800A004C is not the VBScript’s fault. Check the name of the file and or folder referenced in the script.
Introduction to Error 800A004C
Error 800A004C occurs when you execute a VBScript. My suggestion is that you are trying to read, or write, to a file reference that does not exist. A wild guess, there is a typo in your Path statement.
The Symptoms You Get 800A004C
When you get a WSH pop-up message box. Put on your detective hat and pay close attention to the line number. Error 800A004C is a runtime error, so the problem is likely to outside your script, there could be something the matter with a file location.
The Cause of Error 800A004C
In the example above, Line 12: is the source of the error. Char 1: is not always very useful as the error could be anywhere on the line and char 1 will be blamed by WSH. (Windows Script Host)
The cause of error 800A004C is likely to be that the folder that you wish to create the file does not exist. The VBScript is capable of creating the file, but there is no such directory.
The Solutions
Amend the script to reference a real folder. Create a folder to match the path in your script.
Incidentally, Source: reports a runtime error not a compilation error, this means you are looking not for a pure syntax problem, but a fault logic error. In the case of runtime errors, you can use this temporary work around. Add this statement just before the line which errors: On Error Resume Next.
‡
Example of Error 800A004C
In this example folder ezine39 does not exist. (It should have been ezine35)
strPath = «E:ezinescriptsezine39ServicesManual.txt»
‘ ServicesManual.vbs – Writes services to a file.
‘ Author Guy Thomas https://computerperformance.co.uk/
‘ Version 3.7 – June 27th 2010
‘ ————————————————————-‘
Option Explicit
Dim objfso, objWMIService, objItem, colItems
Dim strPath, strFile, strComputer
strPath = «E:ezinescriptsezine39ServicesManual.txt»
strComputer = «.»
Set objfso = CreateObject(«Scripting.FileSystemObject»)
Set strFile = objfso.CreateTextFile(strPath, True)
Set objWMIService = GetObject(«winmgmts:» & strComputer & «rootcimv2»)
Set colItems = objWMIService.ExecQuery(«Select * from Win32_Service»,,48)
For Each objItem in colItems
If objItem.StartMode = «Manual» Then
strFile.WriteLine(«DisplayName: » & objItem.DisplayName)
strFile.WriteLine(«Name: » & objItem.Name)
strFile.WriteLine(«PathName: » & objItem.PathName)
strFile.WriteLine(«ServiceType: » & objItem.ServiceType)
strFile.WriteLine(«Started: » & objItem.Started)
strFile.WriteLine(«StartMode: » & objItem.StartMode)
strFile.WriteLine(«State: » & objItem.State)
strFile.WriteLine(«Status: » & objItem.Status)
strFile.WriteLine(«»)
End if
Next
strFile.Close
Wscript.Quit
‘ End of Script
See More Windows Update Error Codes 8004 Series
• Error 800A101A8 Object Required •Error 800A0046 •Error 800A10AD •Error 800A000D
• Error 80048820 •Error 800A0401 •Review of SolarWinds Permissions Monitor
• Error 80040E14 • Error 800A03EA • Error 800A0408 • Error 800A03EE
Guy Recommends: WMI Monitor and It’s Free!
Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems. Fortunately, SolarWinds have created the WMI Monitor so that you can examine these gems of performance information for free. Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.
Download your free copy of WMI Monitor
Do you need additional help?
- For interpreting the WSH messages check Diagnose 800 errors.
- For general advice try my 7 Troubleshooting techniques.
- See master list of 0800 errors.
- Codes beginning 08004…
- Codes beginning 08005…
- Codes beginning 08007…
- Codes beginning 0800A…
Give something back?
Would you like to help others? If you have a good example of this error, then please email me, I will publish it with a credit to you:
If you like this page then please share it with your friends
About The Author
Guy Thomas
I’ve been making this script and I’m really stuck on this error! This’ just a saple of the entire thing, as that also has errors! It all goes very well until it gets to line 95 char. 4 (Highlighted in bold), where it comes up with error 800A04C — Path not
found.
I’m quite new to this, so I’ve probably made a mess of this!
The comments at the top of the script (in italics) give further data I thought you might need
Here it is…
‘This is just a sample of the entire script, as I need to get this working first before I can try and fix the
‘other bugs in the rest of it.
‘For the first inputbox, just press enter, for the second input box just type in this: password
‘And for the third input box, type in what you want the password to change into!
‘In the main script, this section changes a password so a user can personalise it or make a new one.
‘I’ve managed to make it work down to line 95 character 4, where it comes up with error 800A004C: Path not found
‘What it does without this bit it nearly what I want from it; to change one of the variables (the password), make it
‘save the changes, then overwrite the origional file and (if needed) rename itself the origional name (Password Protect).
‘I nearly have this cracked, I just need some help on the last hurdles!
‘======================================================
‘========= Define Variables
Dim sCurPath
dim fso, text, readfile, contents, x, writefile, SearchFor, ReplaceWith
dim FullFileName, ParentDirName, Filename, NewFilename
Dim Newfldr
set fso = CreateObject(«Scripting.FileSystemObject»)
set args = Wscript.Arguments
If not args.count = 0 then
File = args(0)
End If
‘========= Get user input
sCurPath = CreateObject(«Scripting.FileSystemObject»).GetAbsolutePathName(«.»)
FullFileName=inputbox(«Please input the Full Filename and Path», «Input Filename»,»» & sCurPath & «Password Protect.vbs», file)
‘========= Exit if filename not specified
If FullFileName=»» Then
Wscript.quit
End If
‘========= Get user input
SearchFor=inputbox(«Please input your old password:», «Search For»)
ReplaceWith=inputbox(«Please input your new password:», «Replace With»)
‘========= Determine path and filename components
ParentDirName = fso.GetParentFolderName(FullFileName)
Filename = fso.GetFileName(FullFileName)
NewFilename = ParentDirName & «» & «New» & «» & Filename
‘========= Test if Folder exists
Newfldr = ParentDirName & «» & «New»
set fso = CreateObject(«Scripting.FileSystemObject»)
If fso.FolderExists(Newfldr) Then
Else
MakeFolder
End if
‘========= Make Folder if needed
Function MakeFolder
set folder=fso.CreateFolder(NewFldr)
End Function
set readfile = fso.OpenTextFile(FullFileName, 1, false)
set writefile = fso.CreateTextFile(NewFileName, 2)
‘========= The bit that does the work
Do until readfile.AtEndOfStream = True
ThisLine = readfile.ReadLine
‘If Instr(ThisLine,SearchFor) = True Then
writefile.write Replace(ThisLine,SearchFor,ReplaceWith) & vbCRLF
‘Else
‘ writefile.write ThisLine & vbCRLF
‘End If
loop
‘========= Tidy Up
readfile.close
writefile.close
‘========= call message to say «All done»
‘========= popup will disappear by itself after one second.
Popup
Sub Popup
Dim Shell, msg
Set Shell = wScript.CreateObject(«wScript.Shell»)
Msg = «All done»
Timeout = 1
temp = Shell.Popup(Msg, Timeout, «Progress»)
if temp = -1 then
Const OverwriteExisting = TRUE
Set objFSO = CreateObject(«Scripting.FileSystemObject»)
objfso.CopyFile «» & sCurPath & «NewPassword Protect.vbs» , «» & sCurPath & «Password Protect», OverwriteExisting
wScript.Quit
End if
End Sub
‘another thing, you need to be in the same directory as this file for it to work, could someone maybe find a way around this too?
— — — — — frazzle14
Устраняем ошибку Windows Script Host
Исправляем ошибку Windows Script Host
Сразу стоит сказать о том, что если вы писали свой скрипт и при его запуске получили ошибку, то необходимо искать проблемы в коде, а не в системном компоненте. Например, вот такое диалоговое окно говорит именно об этом:
Такая же ситуация может возникнуть и в том случае, когда в коде имеется ссылка на другой скрипт, путь к которому прописан неверно либо данный файл вовсе отсутствует на компьютере.
Далее мы поговорим о тех моментах, когда при старте Windows или запуске программ, например, Блокнота или Калькулятора, а также других приложений, использующих системные ресурсы, появляется стандартная ошибка Windows Script Host. Иногда подобных окон может появиться сразу несколько. Случается такое после обновления операционной системы, которое может пройти как в штатном режиме, так и со сбоями.
Причины такого поведения ОС следующие:
- Неверно выставленное системное время.
- Сбой в работе службы обновлений.
- Некорректная установка очередного апдейта.
- Нелицензионная сборка «винды».
Вариант 1: Системное время
Многие пользователи думают, что системное время, которое показывается в области уведомлений, существует только для удобства. Это не совсем так. Некоторые программы, обращающиеся к серверам разработчиков или к иным ресурсам, могут работать некорректно или вовсе отказаться функционировать по причине расхождений в дате и времени. Это же касается и Windows с ее серверами обновления. В том случае, если будет расхождение в вашем системном времени и времени сервера, то могут наблюдаться неполадки с апдейтами, поэтому на это стоит обратить внимание в первую очередь.
- Нажимаем на часы в правом нижнем углу экрана и переходим по ссылке, указанной на скриншоте.
- Далее идем на вкладку «Время по интернету» и жмем на кнопку изменения параметров. Обратите внимание, что ваша учетная запись должна обладать правами администратора.
В окне настроек устанавливаем галку в указанный на изображении чекбокс, затем в выпадающем списке «Сервер» выбираем time.windows.com и нажимаем «Обновить сейчас».
Если все пройдет успешно, то появится соответствующая надпись. В случае ошибки с превышением времени ожидания просто нажимаем кнопку обновления еще раз.
Теперь ваше системное время будет регулярно синхронизироваться с сервером времени Майкрософт и расхождения не будет.
Вариант 2: Служба обновлений
Windows – это очень сложная система, с множеством одновременно протекающих процессов, и некоторые из них могут повлиять на работу службы, отвечающей за обновление. Высокое потребление ресурсов, различные сбои и занятость компонентов, помогающих апдейту, «заставляют» службу совершать бесконечные попытки выполнить свою работу. Сам сервис также может сбоить. Выход здесь один: отключить его, а затем перезагрузить компьютер.
- Вызываем строку «Выполнить» сочетанием клавиш Win+R и в поле с названием «Открыть» пишем команду, которая позволит получить доступ к соответствующей оснастке.
В открывшемся окне жмем кнопку «Остановить», а затем ОК.
После перезагрузки служба должна запуститься автоматически. Стоит проверить, так ли это и, если она все еще остановлена, включить ее тем же способом.
Если после выполненных действий ошибки продолжают появляться, то необходимо поработать с уже установленными обновлениями.
Вариант 3: Некорректно установленные обновления
Данный вариант подразумевает удаление тех обновлений, после установки которых начались сбои в Windows Script Host. Сделать это можно как вручную, так и с помощью утилиты восстановления системы. В обоих случаях необходимо вспомнить, когда «посыпались» ошибки, то есть после какой даты.
Ручное удаление
- Идем в «Панель управления» и находим апплет с названием «Программы и компоненты».
- Далее переходим по ссылке, отвечающей за просмотр обновлений.
Сортируем список по дате установки, кликнув по шапке последней колонки с надписью «Установлено».
Выбираем нужное обновление, кликаем ПКМ и выбираем «Удалить». Также поступаем с остальными позициями, помня про дату.
- Для перехода к данной утилите кликаем правой кнопкой мыши по значку компьютера на рабочем столе и выбираем пункт «Свойства».
- Далее переходим к «Защите системы».
Нажимаем кнопку «Восстановление».
В открывшемся окне утилиты жмем «Далее».
Ставим галку, отвечающую за показ дополнительных точек восстановления. Необходимые нам поинты будут называться «Автоматически созданная точка», тип – «Система». Из них необходимо выбрать ту, которая соответствует дате последнего обновления (или того, после которого начались сбои).
Жмем «Далее», ждем, пока система предложит перезагрузиться и выполнит действия по «откату» к предыдущему состоянию.
Обратите внимание, что в этом случае могут быть удалены и те программы и драйвера, которые были установлены вами после этой даты. Узнать, произойдет ли это, можно нажав кнопку «Поиск затрагиваемых программ».
Читайте также: Как восстановить систему Windows XP, Windows 8, Windows 10
Вариант 4: Нелицензионная Windows
Пиратские сборки «винды» хороши лишь тем, что они совершенно бесплатны. В остальном же такие дистрибутивы могут принести массу проблем, в частности, некорректную работу необходимых компонентов. В этом случае рекомендации, приведенные выше, могут не сработать, так как файлы в скачанном образе уже были сбойными. Здесь можно только посоветовать поискать другой дистрибутив, но лучше воспользоваться лицензионной копией Windows.
Заключение
Решения проблемы с Windows Script Host довольно просты, и с ними справится даже начинающий пользователь. Причина здесь ровно одна: некорректная работа инструмента обновления системы. В случае с пиратскими дистрибутивами можно дать следующий совет: пользуйтесь только лицензионными продуктами. И да, правильно пишите ваши скрипты.
Источник
Windows script host ошибка как исправить код 800a004c
This forum is closed. Thank you for your contributions.
Answered by:
Question
I’ve been making this script and I’m really stuck on this error! This’ just a saple of the entire thing, as that also has errors! It all goes very well until it gets to line 95 char. 4 (Highlighted in bold), where it comes up with error 800A04C — Path not found.
I’m quite new to this, so I’ve probably made a mess of this!
The comments at the top of the script (in italics) give further data I thought you might need 🙂
‘This is just a sample of the entire script, as I need to get this working first before I can try and fix the
‘other bugs in the rest of it.
‘For the first inputbox, just press enter, for the second input box just type in this: password
‘And for the third input box, type in what you want the password to change into!
‘In the main script, this section changes a password so a user can personalise it or make a new one.
‘I’ve managed to make it work down to line 95 character 4, where it comes up with error 800A004C: Path not found
‘What it does without this bit it nearly what I want from it; to change one of the variables (the password), make it
‘save the changes, then overwrite the origional file and (if needed) rename itself the origional name (Password Protect).
‘I nearly have this cracked, I just need some help on the last hurdles!
‘========= Define Variables
Dim sCurPath
dim fso, text, readfile, contents, x, writefile, SearchFor, ReplaceWith
dim FullFileName, ParentDirName, Filename, NewFilename
Dim Newfldr
set fso = CreateObject(«Scripting.FileSystemObject»)
set args = Wscript.Arguments
If not args.count = 0 then
File = args(0)
End If
‘========= Get user input
sCurPath = CreateObject(«Scripting.FileSystemObject»).GetAbsolutePathName(«.»)
FullFileName=inputbox(«Please input the Full Filename and Path», «Input Filename»,»» & sCurPath & «Password Protect.vbs», file)
‘========= Exit if filename not specified
If FullFileName=»» Then
Wscript.quit
End If
SearchFor=inputbox(«Please input your old password:», «Search For»)
ReplaceWith=inputbox(«Please input your new password:», «Replace With»)
‘========= Determine path and filename components
ParentDirName = fso.GetParentFolderName(FullFileName)
Filename = fso.GetFileName(FullFileName)
NewFilename = ParentDirName & «» & «New» & «» & Filename
‘========= Test if Folder exists
Newfldr = ParentDirName & «» & «New»
set fso = CreateObject(«Scripting.FileSystemObject»)
If fso.FolderExists(Newfldr) Then
Else
MakeFolder
End if
‘========= Make Folder if needed
Function MakeFolder
set folder=fso.CreateFolder(NewFldr)
End Function
set readfile = fso.OpenTextFile(FullFileName, 1, false)
set writefile = fso.CreateTextFile(NewFileName, 2)
‘========= The bit that does the work
Do until readfile.AtEndOfStream = True
ThisLine = readfile.ReadLine
‘If Instr(ThisLine,SearchFor) = True Then
writefile.write Replace(ThisLine,SearchFor,ReplaceWith) & vbCRLF
‘Else
‘ writefile.write ThisLine & vbCRLF
‘End If
‘========= call message to say «All done»
‘========= popup will disappear by itself after one second.
Sub Popup
Dim Shell, msg
Set Shell = wScript.CreateObject(«wScript.Shell»)
Msg = «All done»
Timeout = 1
temp = Shell.Popup(Msg, Timeout, «Progress»)
if temp = -1 then
Const OverwriteExisting = TRUE
Set objFSO = CreateObject(«Scripting.FileSystemObject»)
objfso.CopyFile «» & sCurPath & «NewPassword Protect.vbs» , «» & sCurPath & «Password Protect», OverwriteExisting
wScript.Quit
End if
End Sub
‘another thing, you need to be in the same directory as this file for it to work, could someone maybe find a way around this too?
Источник
Windows script host ошибка как исправить код 800a004c
Общие обсуждения
I need some help fixing this error, I can’t seem to make it go away!
I quite new to this, so I’ve probably made a mess of this. It goes well, and messes up at line 95 char. 4, when it comes up with error 800A004C.
Here it is. (the problem is highlighted in bold)
‘This is just a sample of the entire script, as I need to get this working first before I can try and fix the
‘other bugs in the rest of it.
‘For the first inputbox, just press enter, for the second input box just type in this: password
‘And for the third input box, type in what you want the password to change into!
‘In the main script, this section changes a password so a user can personalise it or make a new one.
‘I’ve managed to make it work down to line 95 character 4, where it comes up with error 800A004C: Path not found
‘What it does without this bit it nearly what I want from it; to change one of the variables (the password), make it
‘save the changes, then overwrite the origional file and (if needed) rename itself the origional name (Password Protect).
‘I nearly have this cracked, I just need some help on the last hurdles!
‘========= Define Variables
Dim sCurPath
dim fso, text, readfile, contents, x, writefile, SearchFor, ReplaceWith
dim FullFileName, ParentDirName, Filename, NewFilename
Dim Newfldr
set fso = CreateObject(«Scripting.FileSystemObject»)
set args = Wscript.Arguments
If not args.count = 0 then
File = args(0)
End If
‘========= Get user input
sCurPath = CreateObject(«Scripting.FileSystemObject»).GetAbsolutePathName(«.»)
FullFileName=inputbox(«Please input the Full Filename and Path», «Input Filename»,»» & sCurPath & «Password Protect.vbs», file)
‘========= Exit if filename not specified
If FullFileName=»» Then
Wscript.quit
End If
SearchFor=inputbox(«Please input your old password:», «Search For»)
ReplaceWith=inputbox(«Please input your new password:», «Replace With»)
‘========= Determine path and filename components
ParentDirName = fso.GetParentFolderName(FullFileName)
Filename = fso.GetFileName(FullFileName)
NewFilename = ParentDirName & «» & «New» & «» & Filename
‘========= Test if Folder exists
Newfldr = ParentDirName & «» & «New»
set fso = CreateObject(«Scripting.FileSystemObject»)
If fso.FolderExists(Newfldr) Then
Else
MakeFolder
End if
‘========= Make Folder if needed
Function MakeFolder
set folder=fso.CreateFolder(NewFldr)
End Function
set readfile = fso.OpenTextFile(FullFileName, 1, false)
set writefile = fso.CreateTextFile(NewFileName, 2)
‘========= The bit that does the work
Do until readfile.AtEndOfStream = True
ThisLine = readfile.ReadLine
‘If Instr(ThisLine,SearchFor) = True Then
writefile.write Replace(ThisLine,SearchFor,ReplaceWith) & vbCRLF
‘Else
‘ writefile.write ThisLine & vbCRLF
‘End If
‘========= call message to say «All done»
‘========= popup will disappear by itself after one second.
Источник
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:InforVISUAL EnterpriseVISUAL Manufacturing»
strStdINIDirectory = «SUSCDCSQLN02visualAdmin654Standard 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_USERSoftwareInfor Global SolutionsVISUAL ManufacturingConfigurationLocal Directory», strLocalUserProfiledirectory
wshell.RegWrite «HKEY_CURRENT_USERSoftwareInfor Global SolutionsVISUAL ManufacturingConfigurationInstallDirectory», strInstallDirectory
end function
‘———————————————
function deletebuildinfo()
‘———————————————
wshell.Run «cmd /C REG DELETE HKCUSoftwareIdentificationotherbuildinformation /va /f»
wshell.Run «cmd /C REG DELETE HKEY_LOCAL_MACHINESoftwareIdentificationotherbuildinformation /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