Simple script but errors, suggestion?

Author Message
67_dbc

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 6/24/2011
  • Status: offline
Simple script but errors, suggestion? Friday, June 24, 2011 4:53 AM (permalink)
0
My current work using VBS is lacking but i tried to simplify the best I could. Only problem is from the script the folders won't create
 
Here is my script:
 
Explicit
'Declare Variables and constantsDim objShell, objFSO
'Create objectsSet objShell = CreateObject("WScript.Shell")Set objFSO = createobject("scripting.filesystemobject")
'=============================================================================================================================='Main body'==============================================================================================================================On Error Resume Next


'Create the C:\Program Files\bginfo\bginfo folderIf not objFSO.FolderExists("C:\Program Files\bginfo\bginfo") Then objFSO.CreateFolder("C:\Program Files\bginfo\bginfo")End IfIf not objFSO.FolderExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\bginfo") Then objFSO.CreateFolder("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\bginfo")End If
'Copy the bginfo filesobjFSO.CopyFile(objShell.CurrentDirectory & "\Bginfo.exe", "C:\Program Files\bginfo\")objFSO.CopyFile(objShell.CurrentDirectory & "\bginfo.bgi", "C:\Program Files\bginfo\")objFSO.CopyFile(objShell.CurrentDirectory & "\IPv4Only.vbs", "C:\Program Files\bginfo\")objFSO.CopyFile(objShell.CurrentDirectory & "\IPv6Only.vbs", "C:\Program Files\bginfo\")
'Copy the Shortcut to Program FilesobjFSO.CopyFile(objShell.CurrentDirectory & "\ PC Info.lnk", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Bginfo")
 
So what I am doing wrong that prevents the folders from being created?
 
Sorry this is simple for a lot of you but confusing for me.
 
Thanks!
 
#1
    ehvbs

    • Total Posts : 3321
    • Scores: 110
    • Reward points : 0
    • Joined: 6/22/2005
    • Location: Germany
    • Status: offline
    Re:Simple script but errors, suggestion? Friday, June 24, 2011 5:21 AM (permalink)
    0
    Take out the EVIL Global On Error Resume Next and let VBScript tell you, what goes wrong.
     
    Code like this
    objFSO.CopyFile( objShell.CurrentDirectory & "\Bginfo.exe", "C:\Program Files\bginfo\" )
    will get you
    Microsoft VBScript compilation error: Cannot use parentheses when calling a Sub
    <message edited by ehvbs on Friday, June 24, 2011 5:33 AM>
     
    #2
      67_dbc

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 6/24/2011
      • Status: offline
      Re:Simple script but errors, suggestion? Friday, June 24, 2011 8:15 AM (permalink)
      0
      Awesome. Got it to work. Fat fingers and a suggestion helped.
       
      How about this
      How can i apply this on XP without creating a new script?
      Here is what i did with Windows 7 but if path doesn't exist on XP what could I use to say if XP do the following:
       
      Windows 7
      If not objFSO.FolderExists("C:\Program Files\bginfo") Then objFSO.CreateFolder("C:\Program Files\bginfo")End If
      If not objFSO.FolderExists("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\BGinfo") Then objFSO.CreateFolder("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\BGinfo")End If
       
      So how can i say if C:\ProgramData\Microsoft\Windows\Start Menu\Programs doesn't exist because this is for Windows 7
      Create C:\Documents and Settings\All Users\Start Menu\Programs for XP
       
      Suggestions?
       
      #3
        ehvbs

        • Total Posts : 3321
        • Scores: 110
        • Reward points : 0
        • Joined: 6/22/2005
        • Location: Germany
        • Status: offline
        Re:Simple script but errors, suggestion? Saturday, July 02, 2011 8:36 AM (permalink)
        0
        objFSO.CreateFolder("C:\Program Files\bginfo")
        Obese fingers?

         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9