Windows 8 and 8.1 Forums


VBSCript support

  1. #1



    Junior Member

    Join Date : Jul 2011
    Posts : 2
    Windows XP

    VBSCript support


    Hi,

    We are using Windows 8 pre version to verify our software support for this OS, and when we run the vbscript file, got the error 'Variable is undefined:Session'
    Our script has this line of code
    UILevel = Session.Property(CustomActionData)

    What is wrong , the same script is executing successfully on all other windows OS

    Please help us to solve this issue

    thanks
      My System SpecsSystem Spec

  2. #2
    WindowsStar's Avatar

    Member

    Join Date : Jan 2010
    Earth - I wish I was on Risa
    Posts : 78
    Windows 7 Enterprise (x64), Windows 8 Enterprise (x64), Windows Server 2012
    USA


    Post the entire script and we will take a look at it. -WS
      My System SpecsSystem Spec

  3. #3



    Junior Member

    Join Date : Jul 2011
    Posts : 2
    Windows XP


    Hi,

    Here is my script

    Option Explicit

    Sub DoStartService()

    Dim objWMIService, objService, UILevel
    Dim colListOfServices, strComputer

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='myService'")
    UILevel = Session.Property("CustomActionData")
    For Each objService in colListOfServices
    err = objService.StartService()
    If (err = 0) Then
    Else
    If ( UILevel <> 2) Then
    MsgBox "StartService failed. Error = " & Err.Number
    End If
    Exit For
    End If
    Next

    End Sub
      My System SpecsSystem Spec

  4. #4
    WindowsStar's Avatar

    Member

    Join Date : Jan 2010
    Earth - I wish I was on Risa
    Posts : 78
    Windows 7 Enterprise (x64), Windows 8 Enterprise (x64), Windows Server 2012
    USA


    Microsoft changed Applications (install, run, and programmed) in Windows 8.

    This is a very old way to check for a started service. You will need to modify the script removing the UILevel = Session.Property("CustomActionData") for testing if the service is started. You can do it like this:

    Option Explicit

    Dim strComputer,strServiceName
    strComputer = "." ' Local Computer
    strServiceName = "myService" ' My Service

    If isServiceRunning(strComputer,strServiceName) Then
    Wscript.Echo "The '" & strServiceName & "' service is running on '" & strcomputer & "'"
    Else
    Wscript.Echo "The '" & strServiceName & "' service is NOT running on '" & strcomputer & "'"
    End If

    ' Function to check if a service is running on a given computer
    Function isServiceRunning(strComputer,strServiceName)
    Dim objWMIService, strWMIQuery

    strWMIQuery = "Select * from Win32_Service Where Name = '" & strServiceName & "' and state='Running'"

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    If objWMIService.ExecQuery(strWMIQuery).Count > 0 Then
    isServiceRunning = true
    Else
    isServiceRunning = false
    End If

    End Function
      My System SpecsSystem Spec

  5.   

  6. #5



    New Member

    Join Date : Mar 2013
    Posts : 1
    64-bit Windows-8
    France


    I too use a simple legacy VBScript that works under 64-bit Win-7 but crashes under 64-bit Win-8. If anyone can suggest what is different in Win-8, I would be grateful.

    The script "create.vbs" ASCOM FITS driver uses a FITS.dll "driver" to capture images under the astronomical ASCOM environment ASCOM - Standards for Astronomy

    This driver is registered using "regsvr32 FITS.dll" which creates Windows Registry entries for the ASCOM camera "CCDSimulator.Camera".

    The script first creates a camera object:

    Set camera = CreateObject("CCDSimulator.Camera")

    then an image object:

    Set image = CreateObject("FITS.Image")

    Under Win-7 it then retrieves the image array from the camera and produces a FITS image with:

    image.ImageArrayVariant = camera.ImageArrayVariant

    But it CRASHES under Win-8 at that line.
    If that line is commented out, a file is produced (without the image data) but including

    image.ExposureInterval = exposuretime

    The image file is written out with:

    image.WriteToFile filename

    Usage for 64-bit Windows using an Administrator shell:
    C:\windows\syswow64\cscript.exe create.vbs testimage.fit

    Short listing for create.vbs script:
    ---------------------------------------
    Sub Main

    filename = WScript.Arguments.Item(0)
    exposuretime = 2 ' seconds

    ' Create the CCD simulator object
    Set camera = CreateObject("CCDSimulator.Camera")
    camera.Connected = True

    ' Expose with the simulator
    WScript.Echo "exposing " & exposuretime & " seconds..."
    exposurestarttime = now
    camera.StartExposure exposuretime, True
    While Not camera.ImageReady
    WScript.Sleep 100
    Wend

    ' Create the ASCOM FITS driver object
    Set image = CreateObject("FITS.Image")

    ' Fetch image array (raw pixel data) from the camera and feed it directly to our image object
    image.ImageArrayVariant = camera.ImageArrayVariant

    ' Set some properties for our new FITS file
    image.ExposureInterval = exposuretime

    ' Finally create the new FITS file
    image.WriteToFile filename

    End Sub
    ---------------------------------------
      My System SpecsSystem Spec

VBSCript support
Similar Threads
Thread Forum
Older ATI card, no support... Pls help! Drivers & Hardware
Building robust USB 3.0 support Windows 8 News
Implications of ARM support in Windows8 General Support

Eight Forums Android App Eight Forums IOS App Follow us on Facebook