<

Windows 8 and 8.1 Forums

VBSCript support

  1. #1


    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


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


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

  3. #3


    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


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


    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. #5


    Posts : 1
    64-bit Windows-8


    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
VBScript to load user preferences
Hi Everyone, Just wondering if anyone knows of a VBScript or BAT file to load the following preferences when double clicked: Make taskbar icons small Taskbar buttons - never combine Thanks,
General Support
Tech. Support Scam from India support bases.
When I installed Win8 on one computer I need a H.P. printer driver. So I went to H.P. support/download did not find the needed driver so I called their Tech. support. A friendly support guy looked at my system and told me my copy of Microsoft Win8 bought at Best Buy was not a legit copy, also my...
Network & Sharing
VBScript: How do I type in a minimised application
Basically, I want to have a VBScript (Or Similar) which types in a command prompt, but without inturrupting what I am doing at the time. I have the code for it, just it inturrupts me every time it types. Has anyone got a suggestion on how I could do this.
General Support
Not much RT support here, huh?
I spent the last 2 weeks getting acquainted with my new Asus VivoTab RT. I have been looking specifically for RT forums besides those talking about jail breaking it, which I am mostly not interested in. Can't find a lot on the web as far as support goes. Was hoping to find some great posts here....
Tablet and Touch
Error 'Variable undefined:Session' while running VBScript
Hello, Am using windows 8 pro just to check whether it supports all the softwares and languages to install and run it. The first attempt to run vbscript resulted an error with a message 'Variable is undefined:Session'. What does this mean and how to fix this issue in the same os (I want this in...
General Support
vbscript LoadPicture method not working.
Hello, I am using the Windows 8 Consumer Preview to make sure our software will be compatible when it is released. The issue I am having is that the vbscript method LoadPicture is not working. It works correctly in all previous versions of Windows. The rest of the vbscript methods that we use...
Software and Apps

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