When running the VBS unzip code batch in Win 10, I'm getting the error below. What can be a reason for this, given it was reported working before by others? Changing target directories or explicitly setting them doesn't affect the error.
@echo off
setlocal enabledelayedexpansion
cd /d %~dp0
set vbs="%temp%\_.vbs"
call :UnZipFile "E:\Temp\" "%USERPROFILE%\Downloads\archive.zip\"
exit /b
:UnZipFile <ExtractTo> <newzipfile>
if exist %vbs% del /f /q %vbs%
>%vbs% echo Set fso = CreateObject("Scripting.FileSystemObject")
>>%vbs% echo If NOT fso.FolderExists(%1) Then
>>%vbs% echo fso.CreateFolder(%1)
>>%vbs% echo End If
>>%vbs% echo set objShell = CreateObject("Shell.Application")
>>%vbs% echo set FilesInZip=objShell.NameSpace(%2).items
>>%vbs% echo objShell.NameSpace(%1).CopyHere(FilesInZip)
>>%vbs% echo Set fso = Nothing
>>%vbs% echo Set objShell = Nothing
cscript //nologo %vbs%
if exist %vbs% del /f /q %vbs%
::error
VBScript runtime error: Object required: 'objShell.NameSpace(...)'
EDIT: changed .zip file location, now the script works. The error reason was user Download folder moved to a different volume compare to default %USERPROFILE%\Downloads. The script seems to have issues working properly with system folder symlinks.
This batch hybrid is based on the VBS script suggested here by Noodles. It does file unzipping job fairly well, while having the advantage of not requiring a standalone VBS file compare to the original batch, or abandoning the batch script completely in favor of VBS. It does require a target directory for unzipped files to exist.
The VBS method seems to have issues with symlinks or locating a current folder path, if you moved the user Downloads folder from its default location. Use absolute paths in cscript arguments in this case instead of environmental variables.
This code unzips.
Here's a debugging version. Run it with CScript.
This is the output
Showing I didn't have permission to create it.
Showing the file didn't exist.
This is when it works.
C:\Windows\system32>cscript //nologo "C:\Users\User\Desktop\David\Documents\Assorted\Scripts\UnZip - Copy.vbs" C: \symbols c:\file.zip C:\symbols Is Drive False Is Folder True Is File False c:\file.zip Is Drive False Is Folder False Is File True
file.zip Compressed (zipped) Folder True True symbols File folder False True wkernel32.pdb False True wntdll.pdb False True
I've change options to not recurse. See The list here.
https://msdn.microsoft.com/en-us/library/windows/desktop/bb775799%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396