Windows pops up dialog asking how to run VBS scripts on some PCs


  1. Posts : 425
    Windows 10
       #1

    Windows pops up dialog asking how to run VBS scripts on some PCs


    I have a mixture of Windows to 1809 and 21H2 PCs. Upgrading all to 21H2.
    I have created a scheduled task which runs a script called connect.vbs, which contains the following;

    Code:
    Dim WinScriptHost
    Set WinScriptHost = CreateObject("WScript.Shell")
    WinScriptHost.Run "C:\Tools\login.cmd", 0
    Set WinScriptHost = Nothing
    Which runs the login script. The sole purpose of the vbs script is to hide to dos box that otherwise shows if calling the login script directly.

    On some PCs at boot up Windows will ask how I want to open the vbs file. I select the script processor and it runs the script. But instead of remembering that, it asks me on every start up. To make matters worse, it doesn't do it on all PCs. Some 1809, some 21H2... I can't find any common denominator.

    .VBS is present on the pathext envrionment variable.
    assoc .vbs shows;

    Code:
    C:\Users\Tanya>assoc .vbs
    .vbs=VBSFile
    How vbs files are executed seems correct too..

    Code:
    C:\Users\Tanya>ftype | find /I "VBS"
    VBSFile="%SystemRoot%\System32\WScript.exe" "%1" %*
    wscript.exe exists in %systemroot%\system32

    Any ideas? Thanks
      My Computer


  2. Posts : 829
    Windows 7
       #2

    Scheduled tasks don't take into account file type associations, it's not the Explorer shell.

    You need to explicitly call WScript.exe script.vbs as the run command. This is true for PowerShell scripts (powershell -f script.ps1) and batch (cmd /c batch.cmd).
      My Computer


  3. Posts : 425
    Windows 10
    Thread Starter
       #3

    garlin said:
    Scheduled tasks don't take into account file type associations, it's not the Explorer shell.

    You need to explicitly call WScript.exe script.vbs as the run command. This is true for PowerShell scripts (powershell -f script.ps1) and batch (cmd /c batch.cmd).
    Thanks for that I'll give it try. Will let you know how it goes.

    Do you have any ideas on why this error is occuring on some but not all PCs when they are all calling the script the same way?
      My Computer


  4. Posts : 829
    Windows 7
       #4

    File type associations (FTA's) changed a bit in later Windows versions, due to security concerns (to prevent bad actors from secretly replacing programs). If you've upgraded older machines, it may be a little late to compare the before & after settings.

    But invoking wscript.exe from Scheduled Tasks, makes it works across all Windows platforms.
      My Computer


  5. Posts : 425
    Windows 10
    Thread Starter
       #5

    garlin said:
    File type associations (FTA's) changed a bit in later Windows versions, due to security concerns (to prevent bad actors from secretly replacing programs). If you've upgraded older machines, it may be a little late to compare the before & after settings.

    But invoking wscript.exe from Scheduled Tasks, makes it works across all Windows platforms.
    I haven't upgraded all of them. I have some 1809 that work, some that dont and also some 21H2 that work and some that dont. Anyway,
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 11:02.
Find Us




Windows 10 Forums