The powerhell script drops when I call powerhell using vbs.

Asked 2 years ago, Updated 2 years ago, 93 views

I would like to call the powerhell from vbs as below, but the powerhell opens for a moment and the Inputbox does not appear.If you run it alone, it will start without any problems.

I tried to change the argument of the Run method in vbs from '0' to '1' or from 'true' to 'false', but the event did not change.I don't know the cause, so please let me know.

SetobjWShell=CreateObject("Wscript.Shell")
result=objWShell.Run("%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe-File.\hoge\hoge.ps1", 0, true)
WScript.Quit(result)
 [void] [System.Reflection.Assembly]: Load("Microsoft.VisualBasic, Version=8.0.0.0, Culture=Neutral, PublicKeyToken=b03f5f7f11d50a3a")
$INPUT=[Microsoft.VisualBasic.Interaction]: InputBox("Enter.", "Confirm")
System.Windows.Forms.MessageBox::Show("Accepted", "Confirm")

powershell vbs

2022-09-30 15:39

1 Answers

On Error Resume Next

SetobjWShell=CreateObject("Wscript.Shell")
result=objWShell.Run("%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe - WindowStyle Hidden-File.\hoge.ps1", 1, true)

WScript.Quit(result)


2022-09-30 15:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.