A question arised on the Microsoft Live-tour how to run powershell-scripts as logon-scripts. The way to do it is the same as how to run powershell-commands from vb-script. You need to create a “wrapper” or call your ps1-script from vb-script through wscript.shell. Like this:

Dim objShell,objFSO,objFile
Set objShell=CreateObject(“WScript.Shell”)
Set objFSO=CreateObject(“Scripting.FileSystemObject”)
‘sökväg till skriptet
If objFSO.FileExists(strPath) Then
set objFile=objFSO.GetFile(strPath)
strCMD=”powershell -nologo -command ” & Chr(34) & “&{” &_ objFile.ShortPath & “}” & Chr(34)
‘WScript.Echo strCMD
‘0 gömmer fönstret
‘1 visar fönstret
objShell.Run strCMD,0
WScript.Echo “Hittar inte ” & strPath
End If

Leave a Reply

Your email address will not be published. Required fields are marked *