Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBS script (Win95/98)

    Looking for a straightforward VBS script that will run on older Win95/Win98 systems (and if possible also on newer Win2000, WinXP systems) that will simple set a DWORD value somewhere in HKEY_LOCAL_MACHINESoftware.

    If the key exists, it should be changed or re-set, if the key doesn't exist, it should be created (but I guess that's all automatic).

    Found something like this:

    const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    Set StdOut = WScript.StdOut
    '
    Set oReg=GetObject("winmgmts:{impersonationLevel=imper sonate}!" &_
    strComputer & "rootdefault:StdRegProv")
    '
    strKeyPath = "SoftwareMyKey"
    strValueName = "My DWORD"
    dwValue = 0
    oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

    But I feel there's too much here and this might not work on older systems (I didn't test yet)...

    Anyone?

    Erik Jan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBS script (Win95/98)

    If scripting is available (on Win95, it requires IE 4 or higher, I think) and if it has not been disabled by the network guys, you can use this simple code:

    Dim WSHShell
    Set WSHShell = WScript.CreateObject("WScript.Shell")
    WSHShell.RegWrite "HKEY_LOCAL_MACHINESoftwareMyKeyMyDWord", 0, "REG_DWORD"
    Set WSHShell = Nothing

    Things like winmgmts will certainly not be available on Windows 95/98.

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS script (Win95/98)

    Allow me to wake up this topic a bit... I had this tried on one of my target systems some time ago and just found out that this failed somehow. The system reports being Windows95 ([img]/forums/images/smilies/cool.gif[/img]... it seems that some relevant files must be missing that would allow me to run my quite simple script....

    Any ideas what I could do to fix-this?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBS script (Win95/98)

    As I wrote, scripting will only work under Windows 95 if Internet Explorer 4.0 or higher has been installed.

    The alternative would be to use Windows API calls such as RegSetValueEx; search for this term in this forum, or else in Google.

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: VBS script (Win95/98)

    Are you trying to do something else with this script? If this script only does this then a simple reg file would do the job on Windows 95.

    Do you know how to create a reg file (by exporting the key using regedit)?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  6. #6
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBS script (Win95/98)

    Hans, Andrew,

    I found out a little more about the systems... they have IE3.0 loaded (amazing eh?)... Guess that's the reason why things failed... Am I right to assume that if I do not want to install IE4+, there's not much I can do about this?


    Here's the (edited) relevant parts of the script I'm trying to use:


    Const OverwriteExisting = True
    Const Path="C:"
    Dim Ret
    '
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    '
    If objFSO.FileExists(Path & "Program.exe") Then
    Ret = MsgBox("Program seems to be installed, do you want to uninstall now?", vbQuestion + vbYesNo, "Program Updater")
    If vbNo = Ret Then Wscript.Quit
    UnInstall_Program
    wscript.quit
    End If
    '
    If vbNo=MsgBox("This will install the Program functionality" & vbCRLF & "Continue?", vbQuestion & vbYesNo, "Program Updater") Then Wscript.Quit
    Install_Program
    Wscript.Quit
    '
    '
    Sub UnInstall_Program
    On Error Resume Next
    objFSO.DeleteFile(Path & "Program.exe")
    objFSO.DeleteFile(Path & "Program.cfg")
    objFSO.DeleteFile("C:WindowsStart MenuProgramsStartUpProgram.lnk")
    '
    'Update the registry
    Dim WSHShell
    Set WSHShell = WScript.CreateObject("WScript.Shell")
    WSHShell.RegWrite "HKLMSoftwareyyyxxxzzz", 1, "REG_DWORD"
    Set WSHShell = Nothing
    MsgBox "Program UnInstalled", vbinformation,"Program Updater"
    End Sub
    '
    '
    Sub Install_Program
    '
    objFSO.CopyFile "Program.exe" , Path, OverwriteExisting
    objFSO.CopyFile "Program.cfg" , Path, OverwriteExisting
    objFSO.CopyFile "Program.lnk" , "C:WindowsStart MenuProgramsStartUp", OverwriteExisting
    '
    'Update the registry
    Dim WSHShell
    Set WSHShell = WScript.CreateObject("WScript.Shell")
    WSHShell.RegWrite "HKLMSoftwareyyyxxxzzz", 0, "REG_DWORD"
    Set WSHShell = Nothing
    MsgBox "Program Installed", vbinformation,"Program Updater"
    End Sub

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VBS script (Win95/98)

    Win95 with IE 3 is getting a bit long in the tooth - IE4 added a lot of functionality. If a .reg file won't do the job, try the API route. Scripting won't work on IE3.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •