/build/static/layout/Breadcrumb_cap_w.png

vbscript in a custom action

first the disclaimer: I'm new to installshield, and vbscript, not new to scripting (go autoit!)...
I've got a feeling this is a real newb type question, and that I maybe should be posting in the Package Development forum (feel free to slap me if that's the case)

I've got a vbscript, that on it's own works, just copying a file before the install, I've pasted it into a custom action and it doesn't work. I get the 1720 error. when I look at the application eventlog, it tells me the problem's at line 20, that's where I'm instantiating the "scripting.filesystemobject" object. Can I not use the FSO from within a custom action?

the error from eventlog:
Product: Petty Cash.TEST -- Error 1720.There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action PSE_BACKUP_PETTYCASH script error -2146827788, Microsoft VBScript runtime error: Variable is undefined: 'WScript' Line 22, Column 1,

the script:
'==========================================================================
'
' VBScript Source File
'
' NAME: backup_petty_cash.vbs
'
' AUTHOR: Emmanuel Pleshe , Puget Sound Energy
' DATE : 4/5/2005
'
' COMMENT:
'
'==========================================================================
Option Explicit
Dim objFSO, sSource, sDest, iDateTime

iDateTime = (Hour(Now)) & ":" & (Minute(Now)) & " " & (Day(Now)) & "-" & (Month(Now)) & "-" & (Year(Now))
sSource = "C:\program files\SAP Tools\pettycash.xls"
sDest = "C:\program files\SAP Tools\PettyCash Backup " & iDateTime & ".xls"

'WScript.Echo sDest

Set objFSO = WScript.CreateObject("scripting.filesystemobject")
If (objFSO.FileExists(sSource)) Then
objFSO.CopyFile sSource, sDest, 1
End If



If the FSO just won't work, what's the best alternate route? Learn InstallScript?

Thank you in advanced for any help,

Emmanuel

0 Comments   [ + ] Show comments

Answers (2)

Posted by: Robo Scripter 19 years ago
Orange Senior Belt
0
Try this:

***************************************************************************
Option Explicit
Dim objFSO, sSource, sDest, iDateTime

iDateTime = (Hour(Now)) & ":" & (Minute(Now)) & " " & (Day(Now)) & "-" & (Month(Now)) & "-" & (Year(Now))
sSource = "C:\program files\SAP Tools\pettycash.xls"
sDest = "C:\program files\SAP Tools\PettyCash Backup " & iDateTime & ".xls"

'WScript.Echo sDest

Set objFSO = CreateObject("scripting.filesystemobject")
If (objFSO.FileExists(sSource)) Then
objFSO.CopyFile sSource, sDest, 1
End If


***************************************************************************
Posted by: Emmanuel Pleshe 19 years ago
Senior Yellow Belt
0
coolness, that works!

So, no need for the wscript. from within packages, that's the key, huh?
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
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