locked
writing runonce fails RRS feed

  • Question

  • So, I have looked at some examples and created this sniplet:

    Set objWinShell = CreateObject( "WScript.Shell" )
    fncWriteRegistryValue """HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\InstallEASY""",_
      """" & strScriptDir & "\Install.cmd""",_
      """Reg_SZ"""
    ...

    Function fncWriteRegistryValue(strValueName,strValue,strValueType)
     WScript.Echo "strValueName: " & strValueName
     WScript.Echo "strValue: " & strValue
     WScript.Echo "strValueType: " & strValueType
     objWinShell.RegWrite strValueName, strValue, strValueType
     '  Also when I write it all out...  it fails
    '   objWinShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\InstallEASY",_
      "P:\EASY\Install.cmd",_
      "Reg_SZ"  
    End Function

    When it runs it fails with "invalid procedure call or argument"

    I added the WScript.Echo to see what the input is looking like, and to me it seems correct.  Possible a very simple explanation, so i hope some is willing to put me on the correct direction.

    Tuesday, March 29, 2016 3:45 PM

Answers

  • This forum isn't really the place to ask questions about software deployment. I would recommend asking the vendor of the software. In general, scripting and trying to (ab)use the RunOnce registry key to install software isn't recommended, but -- again -- this really isn't the right place to ask your question.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Bill_Stewart Monday, May 16, 2016 6:41 PM
    Tuesday, March 29, 2016 8:22 PM

All replies

  • Why all the extra embedded quotes? This works:


    Dim WshShell
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\InstallEasy", "P:\EASY\Install.cmd", "REG_SZ"
    

    But this makes it appear that you are trying to use this registry key to install software.

    RunOnce probably isn't the way to do whatever it is you're trying to do.


    -- Bill Stewart [Bill_Stewart]

    Tuesday, March 29, 2016 6:06 PM
  • Hi Bill. Thx for replying.

    It indeed is to install sw.  This script installs several components.  One of them needs a reboot before it can proceed.  So it needs to be started again after the reboot.  If there is any other way, please do educate me.

    If I run it plain as you described, yes it runs fine.  But where it starts to fail is when I start using variables that hold the correct values and send them towards a function that should do the reg.writing.  That combination I can not get to work.  And I do not prefer hard coding these kind of things.  What is the function for then...

    Tuesday, March 29, 2016 8:04 PM
  • This forum isn't really the place to ask questions about software deployment. I would recommend asking the vendor of the software. In general, scripting and trying to (ab)use the RunOnce registry key to install software isn't recommended, but -- again -- this really isn't the right place to ask your question.


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by Bill_Stewart Monday, May 16, 2016 6:41 PM
    Tuesday, March 29, 2016 8:22 PM
  • Sorry Bill.  I do not agree...  We missed a connection with each other.  This is not a question about installing software.  But the failing of my script to fill RunOnce using FUnctions and Variables.

    Thx

    Tuesday, March 29, 2016 9:11 PM
  • I'm not sure I understand your question, then. You don't need to add extra quotes to pass a parameter to a subroutine in VBScript. Here is an example:


    Sub TestSub(ByVal S)
      WScript.Echo "Parameter: " & S
    End Sub
    
    TestSub "Hello, world"
    ' Script output: Parameter: Hello, world
    


    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by Bill_Stewart Wednesday, March 30, 2016 3:04 AM
    Tuesday, March 29, 2016 9:37 PM
  • Hi Bill,

    Well, thx for trying.  You are indeed right.  Do not need al thos quotes.
    But I found it (I think).  It is all about encoding I guess.

    When I created a new VBS file and typed all code manually... it worked...  Code is EXACT the same but copy/past code failed and the typed code works...  Made me grazy!!

    Thx anyway!

    Tuesday, March 29, 2016 11:17 PM