17
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VBAからpowershellコマンドを実行

Last updated at Posted at 2015-10-25

VBAからpowershellスクリプトを呼び出したかったので作成。

ネットで検索していろいろな方法を試してみたけどこれでやっと成功しました。

Dos窓からpowershellを呼び出します。画面は非表示です。

Public Function callPowershell(ByVal cmdStr As String)
'@@powershellコマンドを実行
    Dim Wsh
    Set Wsh = CreateObject("Wscript.shell")
    
    Wsh.Run "powershell -ExecutionPolicy RemoteSigned -Command " & cmdStr, 0
End Function

ブログでも紹介してます→http://anosonote.hatenablog.com/entry/2015/10/25/171619

17
30
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?