Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iHow to copy files to c:\windows (Permission Denied)

Status
Not open for further replies.

jluciano

Programmer
Mar 13, 2001
2
US
I am writing my first VBScript in Win98 SE to do a simple software install. The first copy (CopyFolder) works just fine, but on the second copy (CopyFile) I get:

Windows Script Host
Line: 14
Error: Permission Denied
Code: 800A0046
Source: Microsoft VBScript runtime error

How do I fix this?

Here is the script:

-----------------------------------------------------------
<code>
' VB Script to install IrfanView on Drive C:

' Define variables
Dim fso, Irfan_folder, Irfan_ini, MyVar

Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set Irfan_folder = fso.GetFolder(&quot;\Irfanview&quot;)
Set Irfan_ini = fso.GetFile(&quot;\IrfanView\i_view32.ini&quot;)

' Copy IrfanView Folder to C:
fso.CopyFolder Irfan_folder, &quot;C:\&quot;

' Copy IrfanView .ini file to C:\Windows
fso.CopyFile &quot;\IrfanView\IrfanView.lnk&quot;, &quot;C:\Windows&quot;

MyVar = MsgBox (&quot;IrfanView Install is complete.&quot;,0,&quot;Install Success!&quot;)
</code>
------------------------------------------------------------------------------------------

Thanks.
 
Hey, i don't see where you are getting the file:

&quot;IrfanView.lnk&quot;

I think you should get the file &quot;IrfanView.lnk&quot; in this statement:

Set Irfan_ini = fso.GetFile(&quot;\IrfanView\IrfanView.lnk&quot;)

fso.CopyFile Irfan_ini, &quot;C:\Windows&quot;

This puppy should work...
:)
Aladdin420


 
Aladdin420,

Thanks for taking the time to answer my post. The file name in the sample code should have been: &quot;i_view32.ini&quot;, but that's not the real problem I discovered that the syntax in VBS statements evidently requires the ending &quot;\&quot; on a folder name. The following code lines DO work:

Set Irfan_ini = fso.GetFile(&quot;\IrfanView\i_view32.ini&quot;)
Irfan_ini.copy(&quot;C:\Windows\&quot;)

And this is what I have in my working live script.

Alternatively, the following replacement line should work in the original code sample:

fso.CopyFile &quot;\IrfanView\i-view32.ini&quot;, &quot;C:\Windows\&quot;
^ Note backslash

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top