View Full Version : Execute vbScript and Use Results as Conditions
NitLions
05-03-2007, 08:42 AM
I have a vbScript that runs and will be conditioned to run only on a Win 2K3 Server OS. My question is, how can/should I alter the following script so that I can maybe set AutoPlay properties to be used as conditions for other controls.....
Dim aWebSvcExtRestrictionList
Dim extension, sExt, Found
aWebSvcExtRestrictionList = Array()
Set IIsWebServiceObj = GetObject("IIS://localhost/W3SVC")
' Store original value:
aWebSvcExtRestrictionList = IIsWebServiceObj.WebSvcExtRestrictionList
'Troubleshooting...
' For each extension record,
'For Each i in aWebSvcExtRestrictionList
'MsgBox(i)
'Next
Found = 0
For extension = 0 to UBound(IIsWebServiceObj.WebSvcExtRestrictionList)
sExt = IISWebServiceObj.Get("WebSvcExtRestrictionList")(extension)
If (0 < (InStr(sExt, "Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dl l"))) Then
Found = 1
If ("0" = Left(sExt, 1)) then
MsgBox "The ASP.NET v2.0 Web Service Extension needs to be enabled in " & vbCrlf & _
"Internet Information Services, Web Service Extensions for Adept " & vbCrlf & _
"Explorer to function properly!", 48, "Enable ASP.NET 2.0..."
elseif ("1" = Left(sExt, 1)) then
'Do nothing
Found = 1
'MsgBox "ASP.NET v2.0 Extension is enabled!"
else
MsgBox "Please check to ensure ASP.NET v2.0 Extension is enabled!"
end if
end if
Next
If Found = 0 then
MsgBox "It does not appear that the ASP.NET 2.0 Web Service Extension is present" & vbCrLf & _
"on this Server. Please add this extension in Internet Information Services," & vbCrLf & _
"Web Service Extensions by pointing to aspnet_isapi.dll in the following folder:" & vbCrlf & _
vbCrlf & _
"<Windows Folder>\Microsoft.Net\Framework\v2.0.50727" & vbCrLf & _
vbCrlf & _
"This can also be added via Add/Remove Windows Components. Once installed, " & vbCrLf & _
"please ensure this extension is enabled!", 48, "ASP.NET 2.0 Web Extension Needed..."
end if
If the ASP.NET 2.0 web extension is missing or disabled/prohibited, I would like to add this information to my needed Prerequisites page.
Any help is greatly appreciated!!
I would guess I could use File.Open or Shell.Execute actions, but I don't know if there is a way to actually have the script and my AutoPlay wrapper talk to each other - pass information back.
:eek:
NitLions
05-03-2007, 09:31 AM
Or is there a way to alter my vbscript to cause it to error out if the extension is either not present or prohibited? Then, I could use Application.GetLastError maybe? If I get an error back from the script, I could notify the user on my Prerequisites page that work is needed regarding this extension.
Am I reaching?
Usually the replies are pretty quick in this forum. I'm hoping that the lack of early replies doesn't mean this can't be done! :lol
NitLions
05-03-2007, 10:50 AM
I wonder if I can use vbScripts err.raise to send an error under certain conditions. I'll play around with this this afternoon, but if anyone has and ideas, feel free to let me know.....
:yes
NitLions
05-04-2007, 01:18 PM
OK, I know when I'm not wanted :p !
Bummer, I was hoping there was a way to do this in AutoPlay :huh !
NitLions
05-09-2007, 07:53 AM
Here's what I may do. I've altered my vbScript to simply create empty .txt files under certain conditions. I then check for the existence of the files via AutoPlay (File.DoesExist) and can condition my requirements based on that.
I do have one question...
I'm using a File.Open to execute the vbScript. I have to investigate this further, but I don't know if I have to wait for this to execute to completion before my files are created for check with File.DoesExist. Is there any way of waiting with the File.Open action. I was toying around with Application.Sleep and I'm currently in what appears to be a working state. I want to comment this out and retest to see if its actually needed.
My code in this area is basically:
File.Open(.....
Application.Sleep(3000);
if File.DoesExist(.....
Any info on this part of my issue would be greatly appreciated!!
THANKS MUCH in advance!!!
wasim21k
05-09-2007, 08:12 AM
i think i miss understood so i removed my answer
holtgrewe
05-09-2007, 08:42 AM
I'm not sure I fully understand - you're trying to pass information between an AMS project and VBS?
Their probably is a solution out there somewhere; however one way would be to pass the info into a text file or db file. Each AP can share the data.
If I'm off-base here, just ignore this post.
HTH
NitLions
05-09-2007, 09:06 AM
Yes, I need to execute a vbScript, in this case, to detect if the ASP.NET Web Service Extension is present and/or enabled. I don't know how to pass back what I found so I initially tried to raise user defined errors in the script then detect these in AP, but that didn't work as the return was always 0.
The weak thing I figured to do was simply create key condition files (.txt) if certain conditions were met in the script. Then, I could check for the existence of lack thereof in AP as needed.
It seems to work for me, for now, but I have to test removing the Application.Sleeps to see if the AP script moves to fast for my File.DoesExist actions or if the files will be found if created immediately after the vbScript runs.
holtgrewe
05-09-2007, 09:37 AM
NitLions
Instead of the Application.Sleep, you could use a timer event to check the results in the .TXT files every few seconds. Display your results in the AMS AP as the .txt files are created/populated.
After an inordinate amount of time you can display whatever error messages are needed in the AMS AP.
It sounds like that may work for you. Maybe someone else in the forum has a better idea.
NitLions
05-09-2007, 09:58 AM
It does seem that the Application.Sleep is needed for my current scheme to work properly. It appears there is a timing issue if not used. For example, if I don't use the .Sleep, my vbScript runs and a ASPDisabled.txt file is created in the user's text folder. The Next button on my Welcome Page fires the script and detects if any files were created. Page.Jump actions will then direct the user properly.
What seems to have happened in this case is that the File.DoesExist action runs and doesn't find it because it may not have been created by the script at that point. Now, if I run my wrapper again, the file is already there so I am directed to my Prerequisites Page properly.
I currently have the .Sleep set for 3 seconds. If there is an alternative to using sleep, I'm open to any and all suggestions!!
holtgrewe
05-09-2007, 10:37 AM
NitLions
I skimmed over the part where you were jumping pages. The timed event in AMS is page oriented. There is a global timer plugin that is available:
http://www.indigorose.com/forums/showthread.php?t=18980&highlight=worm+timer+plugin
If that's not an option maybe setting up the timed event on each page so that each page is looking for completion of the VBScript.
HTH
NitLions
05-09-2007, 01:01 PM
What I have is the script running from the Next button on the welcome page. If one of the conditional files exists, I set a flag which will be used in Page.Jump conditions. For example:
if Needs = 1 then
Page.Jump("Prereqs")
else
Page.Jump("Install Page")
end
Then, in the Prereqs page's OnShow script I run the script and check for the files again to change labels, enable different buttons, show different graphics, etc.. Then further, in the OnTimer script, I run the script and check so that the prereqs page can be refreshed if this particular requirement has been met.
In typing this, however, I just realized that I really don't need to run the vbScript again in the OnShow script. That may be my solution. I will test simply removing that to see if that gets me over the hump!
NitLions
05-09-2007, 01:36 PM
Removing the script re-run and file.doesexist actions from the OnShow script of my Prereqs page seems to have remedied the timing issue.
I do have another quick question though. Currently, this is a vbScript. I wonder if there will be any problem in running this through APMS's File.Open action with regards to script blocking. ??
I guess, worst case, I can create a small.exe to use instead.
Any input on THIS part of my scenario would be greatly appreciated!
:lol
NitLions
05-09-2007, 01:53 PM
Also, is there any drawback in using Application.Sleep()? I guess I still need it in my Welcome Page's Next button click script as the timing issue appears again if I remove it for test.
NitLions
05-09-2007, 02:38 PM
OK, hopefully I didn't waste too many people's time, but I've taken the easy way out. I converted the vbScript to a VB app (.exe). This way, I can use the File.Run with the wait parameter. This change will hopefully ease my vbscript blocking fears as well as render the need for Application.Sleep useless.
THANKS AGAIN FOR ALL THE SUGGESTIONS!!
:)
wasim21k
05-10-2007, 03:45 AM
no you dont have to have exe file to run script you can run vb scrip as well.
File.Run("cmd.exe","test.vbs", "\\autoplay\\docs\\", SW_Shownormal, false);
in this case i m runing cmd.exe to opne dos and then point my working folder to autoplay\docs and from there i m calling test.vbs.
or other way you can creat batch file and from batch file call your script and use file.run("urbatchfile.cmd" bla bla bla bal bla );
should work
NitLions
05-10-2007, 08:52 AM
Ah, good way to use File.Run to execute the vbScript. I will definitely keep that in mind!!
THANKS!
wasim21k
05-10-2007, 10:34 AM
you welcom,
NitLions, do you know much about vb script?
NitLions
05-10-2007, 12:55 PM
As far as vbScripting goes, I know the basics. For more complex tasks, I research, post to forums, etc.
Why do you ask?
wasim21k
05-11-2007, 03:04 AM
coz i have a script and using that script i can change wins address on pc but wins ip address is in that vb script i just want to change it so user can enter wins ip address.
and other thing i was try to find some script on web that how i can change internet explorer connection settings using some script (proxy settings for all connections and exceptions as well).
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.