/build/static/layout/Breadcrumb_cap_w.png

Why is my script not working.

Ok so here's what I need to do,

I need to copy a shortcut from all users, start menu, programs, general applications folder to current user, start menu, programs, general applications folder, when I run my script I get a permission denied error, code 800A0046. What's wrong with my script folks? Below is the script in question

Script

Dim strAllUsersPgm
Dim strTeammateCitrixSSO
Dim strFile

set wshShell = createobject("Wscript.Shell")
Set wshFileSys = CreateObject("Scripting.FileSystemObject")

strAllUsersPgm = wshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "\Start Menu\Programs\General Applications"

strTeamMateCitrixSSO = wshShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Start Menu\Programs\General Applications"

strFile = strAllUsersPgm & "\Teammate Citrix SSO.lnk"

If wshFileSys.FileExists(strFile) Then

wshFileSys.CopyFile strFile, strTeamMate, True
End If

0 Comments   [ + ] Show comments

Answers (3)

Posted by: murali.bhat 14 years ago
Purple Belt
0
Use this. This line edited from :

wshFileSys.CopyFile strFile, strTeamMate, True

To:

wshFileSys.CopyFile strFile, strTeamMate & "\"

------------------------------------------------------------

Dim strAllUsersPgm
Dim strTeammateCitrixSSO
Dim strFile
set wshShell = createobject("Wscript.Shell")
Set wshFileSys = CreateObject("Scripting.FileSystemObject")
strAllUsersPgm = wshShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "\Start Menu\Programs\General Applications"
strTeamMateCitrixSSO = wshShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Start Menu\Programs\General Applications"
strFile = strAllUsersPgm & "\Teammate Citrix SSO.lnk"
If wshFileSys.FileExists(strFile) Then
IF NOT wshFileSys.FolderExists(strTeamMateCitrixSSO) Then
wshFileSys.CreateFolder(strTeamMateCitrixSSO)
End if
wshFileSys.CopyFile strFile, strTeamMateCitrixSSO & "\"
End If
Posted by: cowley 14 years ago
Orange Belt
0
Thanks, seems to work a treat!
Posted by: anonymous_9363 14 years ago
Red Belt
0
I'd recommend restoring the 'True' argument, so that an existing file gets forcibly overwritten.

I'd also recommend adding some error-trapping. Too many scripts assume that everything will always work whereas good scripts always assume exactly the opposite.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ