Jump to content

Calling VBS gurus


Recommended Posts

I am having a little trouble using VBS to parse a reg entry for me. I'm attempting to have this file launch WPI, because I only want to edit WPI config in one spot on my Multiboot DVD, so I have a VBS file in the $OEM$\$$ dir, so it's easily accessible, which then is launched from [GuiRunOnce], which in turn runs WPI.hta.

I am attempting to have the VBS file read and parse "HKLM\Software\Microsoft\Setup\Sourcepath", but since it's a multiboot DVD, it's not just "d:\", it's "d:\setup\xp\pro". Therefore, I want the script to cut off the end, after the first 3 characters.

My research suggests that the string.slice method should work, but it gives an error that "Object Required."

My code is the following, so if anything might help to make this actually work, I'd appreciate it.

Dim WshShell, testpath, key, fullpath, sliced
key="HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\Sourcepath"
Set WshShell = WScript.CreateObject("WScript.Shell")
testpath=WshShell.RegRead(key)
sliced = testpath.slice(0,2)
fullpath = sliced & "wpi\wpi.hta"
WSHShell.Run fullpath

I know this reads the reg key fine because my previous code used the path, hence my previous debugging. The following looks for the file in "d:\setup\xp\pro\wpi\wpi.hta" instead of the required "d:\wpi\wpi.hta"

Dim WshShell, testpath, key, fullpath, sliced
key="HKLM\Software\Microsoft\Windows\CurrentVersion\Setup\Sourcepath"
Set WshShell = WScript.CreateObject("WScript.Shell")
testpath=WshShell.RegRead(key)
fullpath = testpath & "wpi\wpi.hta"
WSHShell.Run fullpath

Thanks in advance.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...