supercoqui
asked on
Could someone provide a VBS script for creating a directory and copying shortcuts(*.lnk)
Basically I got a folder named c:\program files\software_modificatio ns
Inside this folder I have various folders A,B,C,D. Each of these folders got different ini files along with other folders suchs as Desktop and Startmenu.
There is a VBS script in the software_modification folder that copies some of the files inside other folders in C:
The main problem is that the desktop folder has a group of shortcuts that I wish to copy to the Allusers desktop and the startmenu folder has a group of shortcuts that I want the script to create a folder named "Afolder" and copy to the allUsers startmenu. A basic copy job.
Everytime I run the script I get the error 800A0035. The error is caused due to the last two lines of each of the selections been incorrect. If I take out the lines related to the links, the problem goes away.
========================== ======Prob lem lines===================== ========== =========
fso.CopyFile "C:\Program Files\software_modificatio ns\A\Start menu\*.lnk ", "C:\Documents and Settings\All Users\Start Menu\Programs\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\A\Deskt op\*.lnk", "C:\Documents and Settings\All Users\Desktop\", true
========================== ===Problem lines===================== ========== ========== =
Here is a copy of the script:
========================== ========== =Original script==================== ========== ===
Option Explicit
dim fso, bValid, sResponse
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
bValid = false
Do
sResponse = InputBox("Please select." & vbCrLf & vbCrLf & "Press 1 for A CONFIGURATION" & vbCrLf & vbCrLf & "Press 2 for B CONFIGURATION" & vbCrLf & vbCrLf & "Press 3 for C CONFIGURATION" & vbCrLf & vbCrLf & "Press 4 for D CONFIGURATION" & vbCrLf & vbCrLf & "Press 5 for E CONFIGURATION", "Select a configuration")
Select Case(sResponse)
Case "1" WScript.Echo "You selected A (1)"
fso.CopyFile "C:\Program Files\software_modificatio ns\A\*.ini ", "C:\Program Files\software\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\A\SYBAS E\INI\*.in i", "C:\sybase\ini\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\A\Start menu\*.lnk ", "C:\Documents and Settings\All Users\Start Menu\Programs\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\A\Deskt op\*.lnk", "C:\Documents and Settings\All Users\Desktop\", true
bValid = true
Case "2" WScript.Echo "You selected B (2)"
fso.CopyFile "C:\Program Files\software_modificatio ns\B\*.ini ", "C:\Program Files\software\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\B\SYBAS E\INI\*.in i", "C:\sybase\ini\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\B\Start menu\*.lnk ", "C:\Documents and Settings\All Users\Start Menu\Programs\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\B\Deskt op\*.lnk", "C:\Documents and Settings\All Users\Desktop\", true
bValid = true
Case "3" WScript.Echo "You selected C (3)"
fso.CopyFile "C:\Program Files\software_modificatio ns\C\*.ini ", "C:\Program Files\software\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\C\SYBAS E\INI\*.in i", "C:\sybase\ini\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\C\Start menu\*.lnk ", "C:\Documents and Settings\All Users\Start Menu\Programs\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\C\Deskt op\*.lnk", "C:\Documents and Settings\All Users\Desktop\", true
bValid = true
Case "4" WScript.Echo "You selected D (4)"
fso.CopyFile "C:\Program Files\software_modificatio ns\D\*.ini ", "C:\Program Files\software\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\D\SYBAS E\INI\*.in i", "C:\sybase\ini\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\D\Start menu\*.lnk ", "C:\Documents and Settings\All Users\Start Menu\Programs\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\D\Deskt op\*.lnk", "C:\Documents and Settings\All Users\Desktop\", true
bValid = true
Case "5" WScript.Echo "You selected E (5)"
fso.CopyFile "C:\Program Files\software_modificatio ns\E\*.ini ", "C:\Program Files\software\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\E\coco\ WINDOWS\*. ini", "C:\coco\windows\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\E\WINDO WS\*.ini", "C:\windows\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\E\SYBAS E\INI\*.in i", "C:\sybase\ini\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\E\Start menu\*.lnk ", "C:\Documents and Settings\All Users\Start Menu\Programs\", true
fso.CopyFile "C:\Program Files\software_modificatio ns\E\Deskt op\*.lnk", "C:\Documents and Settings\All Users\Desktop\", true
bValid = true
Case Else WScript.Echo "You have entered an invalid response. Acceptable values are 1 - 5."
End Select
Loop Until bValid = true
Inside this folder I have various folders A,B,C,D. Each of these folders got different ini files along with other folders suchs as Desktop and Startmenu.
There is a VBS script in the software_modification folder that copies some of the files inside other folders in C:
The main problem is that the desktop folder has a group of shortcuts that I wish to copy to the Allusers desktop and the startmenu folder has a group of shortcuts that I want the script to create a folder named "Afolder" and copy to the allUsers startmenu. A basic copy job.
Everytime I run the script I get the error 800A0035. The error is caused due to the last two lines of each of the selections been incorrect. If I take out the lines related to the links, the problem goes away.
==========================
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
==========================
Here is a copy of the script:
==========================
Option Explicit
dim fso, bValid, sResponse
Set fso = CreateObject("Scripting.Fi
bValid = false
Do
sResponse = InputBox("Please select." & vbCrLf & vbCrLf & "Press 1 for A CONFIGURATION" & vbCrLf & vbCrLf & "Press 2 for B CONFIGURATION" & vbCrLf & vbCrLf & "Press 3 for C CONFIGURATION" & vbCrLf & vbCrLf & "Press 4 for D CONFIGURATION" & vbCrLf & vbCrLf & "Press 5 for E CONFIGURATION", "Select a configuration")
Select Case(sResponse)
Case "1" WScript.Echo "You selected A (1)"
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
bValid = true
Case "2" WScript.Echo "You selected B (2)"
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
bValid = true
Case "3" WScript.Echo "You selected C (3)"
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
bValid = true
Case "4" WScript.Echo "You selected D (4)"
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
bValid = true
Case "5" WScript.Echo "You selected E (5)"
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
fso.CopyFile "C:\Program Files\software_modificatio
bValid = true
Case Else WScript.Echo "You have entered an invalid response. Acceptable values are 1 - 5."
End Select
Loop Until bValid = true
The 800A0035 error is probably File Not Found.
See if this helps you see what your problem might be, although your syntax looks correct:
http://msdn.microsoft.com/en-us/library/e1wf9e7w(VS.85).aspx
Regards,
Rob.
See if this helps you see what your problem might be, although your syntax looks correct:
http://msdn.microsoft.com/en-us/library/e1wf9e7w(VS.85).aspx
Regards,
Rob.
ASKER
Thanks for the reply. It is been executed as an administrator right now. This will be a script for a program I am packaging.
So to write to the AllUsers area I need administrator rights? Is there a way to run the script as an administrator while putting some rights on the script for users not to open and peek into it?
I am planing on putting read, list folder contents and execute rights on the folder where this script will be hosted.
So to write to the AllUsers area I need administrator rights? Is there a way to run the script as an administrator while putting some rights on the script for users not to open and peek into it?
I am planing on putting read, list folder contents and execute rights on the folder where this script will be hosted.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It was extremelly helpful. I was out fo the area for over a month and not able to reply due to a slow internet link. Thanks
Regards,
Rob.