VBS error


  1. Posts : 966
    Windows 7 Enterprise
       #1

    VBS error


    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
    <line 27>  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


  2. Posts : 4,772
    Windows 7 Ultimate - 64-bit | Windows 8 Pro - 64-bit
       #2

    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


  3. Posts : 966
    Windows 7 Enterprise
    Thread Starter
       #3

    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!

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


  4. Posts : 1
    win7
       #4

    Hi Xarden,
    I have the same problem here. Can you please post your cod?
    Best regards,
    Antonio
      My Computer


  5. Posts : 966
    Windows 7 Enterprise
    Thread Starter
       #5

    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


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 12:23.
Find Us