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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Argument mismatch

Status
Not open for further replies.

Count430

Programmer
Apr 26, 2002
127
0
0
US
Hello all,

I wanted to adda subrouting to an existing script and when I added the following code, I received the "argument mismatch" error

Code

' This is a template for writing a subroutine that the "Execute Script"
' action will call on the client.
'------------------------------------------------------------------------------------------------
Sub ExecutePowerUser(Pub, Act)
' Pub is a reference to the Publication.
' Act is a reference to the Action.
' To set a return value just uncomment one of the next two lines.
' Act.ReturnValue = "Some value"
' Act.ReturnValue = 0
exe = """c:\program files\Windows Media Player\MediaPlayer_CU.EXE"""
args = ""
wait = True

WriteLog("Executing "&exe)

retval = RunCommand(exe, args, wait)

WriteLog("Return value "&retval)

If ( retval <> 0 ) Then
WriteLog("Error executing "&exe&" "&args)
WriteLog("retval: "&retval)
StopServices=False
End If

Act.ReturnValue = retval

End Sub

'-----------------------------------------------------------------------------------------------------
' This sub routine removes shortcuts from the specified locations
'-----------------------------------------------------------------------------------------------------


Sub Cleanup(Pub, Act)
Dim fileSysObj
Set fileSysObj = CreateObject("Scripting.FileSystemObject")
fileSysObj.DeleteFile "c:\documents and settings\"&iMobile.user&"\desktop\Windows Media Player.lnk" ' optional second parameter "Force" which is needed to delete read only files.
'fileSysObj.DeleteFile "c:\documents and settings\"&iMobile.user&"\Application Data\Microsoft\Internet Explorer\Quick Launch\Windows Media Player.lnk"
End Sub

Any assistance is greatly appreciated...
 
Which line produces the 'Argument mismatch' error? Presumably the error is echoed to a DOS window, in which case it'll display something like this:
Code:
H:\Scripts\scriptname.vbs(98, 4)
From that, tell us which line of the code the error is referring to.

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Hi JJ,

It's referring to the sub routine Cleanup, here's the complete script, you can ignore most of the code, maybe I'm calling the sub routine incorrectly

===========================================================

' client script
Sub OnPreInstallFirst(Pub)
End Sub

Sub OnPreInstall(Pub)
' Set the ICED_InstalledSoftware key name here
iMobile.SetMacro "ICEDNAME", "Windows_Media_Player"

' Now set the CURRENTDATE macro
dtNow = Now
If ( Hour(dtNow) < 12 ) Then
sAMPM = "AM"
Else
sAMPM = "PM"
End If
sCurrentDate = WeekdayName(Weekday(dtNow),True)&" "&Right("0"&Month(dtNow),2)&"/"&Right("0"&Day(dtNow),2)&"/"&Right("0"&Year(dtNow),2)&" "&Right("0"&Hour(dtNow),2)&":"&Right("0"&Minute(dtNow),2)&":"&Right("0"&Second(dtNow),2)&" "&sAMPM
iMobile.SetMacro "CURRENTDATE", sCurrentDate
End Sub

Sub OnPostInstallFirst(Pub)
' add your post installation script here for the first time the pub is downloaded
End Sub

Sub OnPreInstall(Pub)
' add your pre-installation script here for each time the pub is downloaded
End Sub

Sub OnPostInstall(Pub)
' add your post installation script here for each time the pub is downloaded
End Sub

'------------------------------------------------------------------------------------------------
' This is a template for writing a subroutine that the "Execute Script"
' action will call on the client.
'------------------------------------------------------------------------------------------------
Sub ExecutePowerUser(Pub, Act)
' Pub is a reference to the Publication.
' Act is a reference to the Action.
' To set a return value just uncomment one of the next two lines.
' Act.ReturnValue = "Some value"
' Act.ReturnValue = 0
exe = """c:\program files\Windows Media Player\MediaPlayer_CU.EXE"""
args = ""
wait = True

WriteLog("Executing "&exe)

retval = RunCommand(exe, args, wait)

WriteLog("Return value "&retval)

If ( retval <> 0 ) Then
WriteLog("Error executing "&exe&" "&args)
WriteLog("retval: "&retval)
StopServices=False
End If

Act.ReturnValue = retval

End Sub

'-----------------------------------------------------------------------------------------------------
' This sub routine removes shortcuts from the specified locations
'-----------------------------------------------------------------------------------------------------


Sub Cleanup(Pub, Act)
Dim fileSysObj
Set fileSysObj = CreateObject("Scripting.FileSystemObject")
fileSysObj.DeleteFile "c:\documents and settings\"&iMobile.user&"\desktop\Windows Media Player.lnk" ' optional second parameter "Force" which is needed to delete read only files.
'fileSysObj.DeleteFile "c:\documents and settings\"&iMobile.user&"\Application Data\Microsoft\Internet Explorer\Quick Launch\Windows Media Player.lnk"
End Sub

Function RunCommand(exe, args, wait)
Dim sh
RunCommand = 0
Set sh = CreateObject("WScript.Shell")
RunCommand = sh.run(exe & "" & args, 0, wait)
End Function

'------------------------------------------------------------------------------------------------
' This function will write to the log.
' Example: WriteLog("Successful registry update with")
'------------------------------------------------------------------------------------------------

Function WriteLog(messagetext)
iMobile.LogEntry 1,(Messagetext)
End Function



 
Forgive me if I'm being dim, but I can't see where the Cleanup subroutine is being called from.

Also, you've got two subroutines called
Code:
Sub OnPreInstall(Pub)

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top