Why oShell.Run not work

后端 未结 2 1069
萌比男神i
萌比男神i 2021-01-07 06:38

This code not work

set oShell = WScript.CreateObject (\"WScript.shell\")
oShell.Run \"%appdata%\\Test.bat\",0,False

But this code work

2条回答
  •  孤街浪徒
    2021-01-07 07:37

    set WshShell = WScript.CreateObject("WScript.Shell")
    WScript.Echo "WinDir is " & WshShell.ExpandEnvironmentStrings("%WinDir%\system32")
    

    And running it

    C:\Users\User>cscript "C:\Users\User\Desktop\New Text Document.vbs"
    Microsoft (R) Windows Script Host Version 5.812
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    WinDir is C:\Windows\system32
    

    If it doesn't work there ask at www.superuser.com why your system is misconfigured.

提交回复
热议问题