none
Error when launching vbscript at windows startup RRS feed

  • Question

  • I have a thin client running WES 7 Standard trying to launch a powerpoint file without loading the shell(explorer). I've done this with other applications like IE and Citrix Apps but am getting an error that I don't understand. Below is the script i'm using.

    Set WshShell = Wscript.CreateObject("WScript.Shell")
    
    CMD = "C:\slideshow.pptx /F"
    strComputer = "."
    WshShell.Run CMD,3,True 
    
    
    Do While (1)
    
         Set objWMIService = GetObject("winmgmts:" _
             & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
         Set colProcesses = objWMIService.ExecQuery _
             ("Select * from Win32_Process Where Name = 'pptview.exe'")
    
         If colProcesses.Count = 0 Then
             WshShell.Run CMD,3,True
         End If
    
         Wscript.Sleep (2000)
    
    Loop

    I've tried various combinations in the CMD field for launching the file. These include using a batch file to pointing to powerpoint viewer and using the command line switches to launch file. Every method so far gives me error dialog from the viewer saying there was an error accessing "the location of the powerpoint file." I have placed this file all over windows and get the same error and even tried this with an administrator account. I suspect it may have to do with the way I am launching this script but do not understand why as I can launch it manually and it works no problem.

    I launch the script by modifying the the HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit key to point to a userinit.bat file.

    @echo off
    if not exist c:\%username%.lck goto Reg
    Start c:\windows\system32\applaunch.vbs 
    exit
    goto End
    :Reg
    start C:\WINDOWS\system32\userinit.exe
    :End
    Exit
    Any ideas why I am getting this error? Any suggested alternatives? I am getting close to conceding and setting it up to launch after explorer loads because this particular machine and it's purpose won't be within easy reach of people accessing it but I do use this method for other functions where we do not want explorer access available at all. i.e no start menu/taskbar loaded


    Wednesday, March 5, 2014 12:19 AM

Answers

  • A long time ago renaming the extensions of powerpoint files from ppt to pps worked for me in that manner, that the powerpoint was shown without loading the whole powerpoint program.

    Try to rename the slideshow.pptx to slideshow.pps and call it direct. Maybe that will work as you wish.

    • Marked as answer by JasonRTR Thursday, March 6, 2014 6:29 PM
    Wednesday, March 5, 2014 8:00 AM

All replies

  • And the exact error message is...?

    (Remember, we can't see your screen)

    Bill

    Wednesday, March 5, 2014 12:29 AM
    Moderator
  • I listed it.

    There was an error accessing "location of powerpoint file"

    Using the latest modification of the script(same that I posted above) the exact error is

    There was an error accessing C:\slideshow.pptx.

    The dialog box is listed as Microsoft PowerPoint Viewer so that is what is throwing out the error if I'm not mistaken.

    • Edited by JasonRTR Wednesday, March 5, 2014 12:38 AM added screenshot
    Wednesday, March 5, 2014 12:34 AM
  • You should not be running this: "start C:\WINDOWS\system32\userinit.exe"

    It is a program run by the system when you log into Windows.  It is not a user utility.


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, March 5, 2014 12:58 AM
    Wednesday, March 5, 2014 12:58 AM
  • Why would you use a VBScript to run a powerpoint file?  Just run the file in you batch file.

    Office programs cannot be successfully run under the WMI service which is what you are trying to do.  It must be run under a full user session.  See the Microsoft documentation for Office products.


    ¯\_(ツ)_/¯

    Wednesday, March 5, 2014 1:01 AM
  • What you are trying to do is not supported on Windows.

    You mention a thin client.  This has nothing to do with thin clients.  Thin clients are just dumb monitors that run a remote RDP session.

    If you are connecting to a terminal server there is a configuration in GP or in the terminal server configuration that let you specify an alternate shell.  If you are running this as a remote to a workstation then you need to specify the shell in the user profile.  THis can be done through group policy or via a registry edit.

    You cannot use a script for this and you cannot use an Office program without Explorer.  Office requires Explorer to run which is why you are getting that error.

    Redirecting userinit for the whole machine will likely create many bad side effects as it is a fundamental process.  It is called multiple times during logon.  Replacing it with a batch file will cause you script to be executed multiple times.  Usually userinit is called at least three times.  In a domain with Group Policy it can be called a dozen times.  I am pretty sure the only reason for it being in the registry is to allow for debugging.

    Another this folder.ng to knowis that userinit has to complete before many things in Office will work correctly dependin on you implementation.

    You can load the powerpoint viewer and directly launch that with the file name from the
    "startup"  .  You can also try and set the powerpoint viewer as the alternate shell.  It just might work because it is designed to run completely stand alone with no Office and is used in kiosks which generally run without Explorer.  You can also try to use IE to launch the ppt as it can host this with the viewer installed.  It can be set to fullscreen and it will re-launch  when exited just like Explorer does,


    ¯\_(ツ)_/¯

    Wednesday, March 5, 2014 1:14 AM
  • A long time ago renaming the extensions of powerpoint files from ppt to pps worked for me in that manner, that the powerpoint was shown without loading the whole powerpoint program.

    Try to rename the slideshow.pptx to slideshow.pps and call it direct. Maybe that will work as you wish.

    • Marked as answer by JasonRTR Thursday, March 6, 2014 6:29 PM
    Wednesday, March 5, 2014 8:00 AM
  • Forgive me for using a misnomer for describing the device i'm using. It's a tiny device with flash memory.

    Why am I using VBScript? Because I need the application to relaunch without user intervention if it should ever close.

    The userinit.bat file that you said should not be running start C:\windows\system32\userinit.exe... I do believe that is what windows does on it's own when a user logs in no? All that bat file is doing is allowing me to execute my vbscript for a specific without affecting any other user that logs into windows.

    I will try launching the viewer as a shell. I don't want to use startup because then that provides access to explorer because explorer has to load before anything in startup runs yes?

    The rest also doesn't make sense to me. I'm not saying you're wrong it's just that I don't understand why I can open task manager after my script has executed, manually execute the vbscript again and then have it lauch my powerpoint file and execute as it should. This is with explorer.exe having not loaded nor userinit.exe.

    Wednesday, March 5, 2014 8:02 AM
  • Sorry, TL;DR.

    How about explaining precisely what you want to do, not how you want to do it?

    It also helps to whittle down your script to the absolute minimum amount of code needed to reproduce the problem and post the minimal script. The goal is to make the problem reproducible for others.

    Bill

    Wednesday, March 5, 2014 4:26 PM
    Moderator
  • Well at this point it's not a script issue. JRV is likely right that it is an Office issue. I don't understand it and very much would like too but that would fall out of the scope of this particular forum. Reason I say it's not a script issue is because I took the script out of the equation and continue to get the same error. I created a shortcut to launch the file that works when I execute it but if I ask windows to execute via adding it to the startup folder I'm right back to where I started.

    In hindsight I'm willing to bet it's the configuration of Windows. As mentioned before it is Windows 7 Embedded Standard and unfortunately I have to use the configuration that was pre-loaded so there is likely some component missing that is causing me these errors. Sadly I have not been able to convince my superiors that we need to purchase a license so we can use the toolkit to customize our own images instead of using the OEM build/license

    Wednesday, March 5, 2014 10:37 PM
  • Office is not supported on Windows embedded.  I am surprised that it runs at all.  Don't you mean you are trying to run it on a remote server?

    Windows embedded does not support the full automation model and it does not use Explorer that is on standard Windows.

    Embedded is designed as a platform for simple things like thin clients.  It on runs limited versions of IE and other tools.  It is not designed to be run as a stand alone system.


    ¯\_(ツ)_/¯

    Wednesday, March 5, 2014 11:58 PM
  • Correct but it does support the Office viewers which is all I'm trying to run. http://www.microsoft.com/windowsembedded/en-us/catcatalog.aspx
    Thursday, March 6, 2014 12:30 AM
  • Oddly enough Peter's suggestion worked.
    Thursday, March 6, 2014 6:30 PM