VBS error

xarden

New member
Guru
Local time
12:02 AM
Messages
905
Location
Auckland
Hi guys, I hope Im putting this in the right place...
I've got a script that I'll be including to my pre-sysprep scripts...
Basically, I need it to change the folder permissions on the \oobe\info\backgrounds\ folder so I can copy out company image there. Custom logon background...

However, im getting a funky error message:
Code:
Script: W:\exists.vbs
Line: 27
Char: 1
Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript Runtime error

My Script is:
Code:
strFolderInfo = "C:\windows\system32\oobe\info\backgrounds"
strImageFile = "W:\images\Win7\files\images\background.jpg"
 
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set mySHL = CreateObject("WScript.Shell")
if not myFSO.FolderExists(strFolderInfo) then
 myFSO.CreateFolder(strFolderInfo)
 WScript.Echo("Create Info Folder")
else
 WScript.Echo("Folder already Exists")
end if
 
intRunError = mySHL.Run("%COMSPEC% /c Echo Y| cacls " & strFolderInfo & " /t /c /g Everyone:F ", 2, True)
   If intRunError <> 0 Then
   Wscript.Echo "Error assigning permissions for " & strHomeFolder
   End If
intRunError2 = mySHL.Run("%COMSPEC% /c Echo Y| attrib -R " & strFolderInfo,2,TRUE)
   If intRunError2 <> 0 Then
   Wscript.Echo "Error Applying Attributes "  & strUser & " to home folder " & strFolderInfo 
   End If
[B]<line 27>[/B]  intCopyError = myFSO.CopyFile(strImageFile, strFolderInfo, True)
   If intCopyError <> 0 Then
 WScript.Echo("Error: " & intCopyError)
   Else
 WScript.Echo("Background Image Copied.")
   End If
I know the actual image is meant to be named BackgroundDefault.jpg, but this is for testing at the moment...
Also, the <line 27> is not in the script, its just for your quick reference.
W:\ is a mapped network share

Can someone point me in the right direction as to why this is not working as expected?
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
Hello !!

I'm not a programer but according to error seems like the permission is denied to that location. I guess try to disable your UAC then try to run the script again. Also Take Ownership of the location "C:\windows\system32\oobe\info\backgrounds" Maybe the whole System32 folder.

Hope this helps,
Captain
 

My Computer

Computer Manufacturer/Model Number
Samsung NP550P5C-S02IN
OS
Windows 7 Ultimate - 64-bit | Windows 8 Pro - 64-bit
CPU
Intel® Core™ i7 Processor 3,610QM (2.30Hz, 6MB L3 Cach
Memory
8 GB
Graphics Card(s)
NVIDIA® GeForce® GT 650M 2GB Graphics, Optimus™ techno
Sound Card
SoundAlive™ JBL 3 Speakers (With sub-Woofer)
Monitor(s) Displays
39.62cm (15.6) SuperBright 300nit HD+ LED Display
Screen Resolution
1,600 x 900, Anti-Reflective
Hard Drives
1TB S-ATA II Hard Drive (5,400RPM)
Thanks Capt'n.
UAC is always off.
Added
Code:
intRunError = mySHL.Run("%COMSPEC% /c Echo Y| takeown.exe /F " & strFolderInfo, 2, True)
   If intRunError <> 0 Then
   Wscript.Echo "Error assigning permissions for " & strFolderInfo
   End If
to take ownership.
However I still got the error.

But...

After coming back from lunch with a clear calm head, suffixing a slash to the end of the strFolderInfo path made it work! :party:

Looks like we cant copy file1 into file2, unless you specify that file2 is actually a folder.
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
Hi Xarden,
I have the same problem here. Can you please post your cod?
Best regards,
Antonio
 

My Computer

OS
win7
Two parts attached.
You'l need to edit the vbs file and change the strImageFile path to whatever your image is.

However!
Read my other post here before you do it.
 

My Computer

OS
Windows 7 Enterprise
CPU
Intel Pentium Dual E2200 @2.2GHz
Motherboard
Gigabyte II-G31
Memory
4GB
Graphics Card(s)
Palit GForce 9500GT 1GB
Sound Card
onBoard
Hard Drives
WesternDigital: 250GB + 1TB + 1TB + 2TB
PSU
450W
Case
CoolerMaster CM690
Cooling
Corsair H50
Mouse
Logitech MX518
Back
Top