STA issue with DataGridView
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
STA issue with DataGridView
We are working on it. We will post as soon as a permanent solution is available.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
STA issue with DataGridView
I see this did not make it into the 1.1 release, so I have started to use a workaround, just thought I would post it, if other people need it..(The reason I need this, is that I have to publish a lot my "scripts" to Terminal Services for regular users to use, and I am loading in a lot data from SQL, and users expect to be able to copy/paste)So I have adatapted a script from Jeffrey Hicks to start the .ps1 file instead of creating an .EXEDim objShell,objFSO,objFileSet objShell=CreateObject("WScript.Shell")Set objFSO=CreateObject("Scripting.FileSystemObject")'enter the path for your PowerShell ScriptstrPath="C:Scriptsexamplscript.ps1"'verify file existsIf objFSO.FileExists(strPath) Then'return short path name set objFile=objFSO.GetFile(strPath) strCMD="powershell -nologo -sta " & Chr(34) & "&{" &_ objFile.ShortPath & "}" & Chr(34) 'Uncomment next line for debugging 'WScript.Echo strCMD 'use 0 to hide window objShell.Run strCMD,0Else'Display error message WScript.Echo "Failed to find " & strPath WScript.Quit End If