Terminal Server Question - Passing Parameters
am 18.10.2005 22:54:05 von no spam
Dear Access 2003 Users,
Is there any way to launch Terminal Server from Access and pass along
the user name that is in a text box? I believe mstsc.exe can be
passed an IP address (/v), but can you also pass along a username or
password that sits on a form? Thank you.
Kevin
Re: Terminal Server Question - Passing Parameters
am 19.10.2005 13:24:15 von Terry Kreft
If you run mstsc with the /? switch it tells you the command line switches
available
---------------------------
Usage
---------------------------
Remote Desktop Connection
MSTSC [] [/v:] [/console]
[/f[ullscreen]]
[/w: /h:] | /Edit"ConnectionFile" | /Migrate | /?
-- specifies the name of an .rdp file for the
connection.
/v: -- specifies the terminal server to which you want
to connect.
/console -- connects to the console session of a server.
/f -- Starts the client in full-screen mode.
/w: -- specifies the width of the Remote Desktop screen.
/h: -- Specifies the height of the Remote Desktop screen.
/edit -- Opens the specified .rdp file for editing.
/migrate -- migrates legacy connection files that were created with
Client Connection Manager to new .rdp connection files.
/? -- generates this Usage message.
---------------------------
OK
---------------------------
From which you can see there isn't an option to pass in the user name.
.... but we can do a hack on a file and pass that as a parameter to mstsc.
What follows is horrible cludgy code with loads of areas of improvement but
it does work (on my system at least).
Replace the values for PATH_NAME and PATH_NAME_1 with valid values
' **************************************
' Code Start
Function mstscfile(UserNAme As String)
Dim intff As Integer
Dim arrIn() As Byte
Dim arrOut() As Byte
Dim strout As String
Dim intX As Integer
Dim strOne As String
Dim strUserName As String
Dim strThree As String
' Replace the value of these consts with valid values
Const PATH_NAME = "C:\yourpath\your.RDP"
Const PATH_NAME_1 = "C:\yourpath\your_new.RDP"
intff = FreeFile()
Open PATH_NAME For Binary Access Read Lock Read As intff
ReDim arrIn(0 To LOF(intff) - 1)
Get #intff, , arrIn
Close #intff
ReDim arrOut(0 To UBound(arrIn) - 2)
For intX = 2 To UBound(arrIn)
arrOut(intX - 2) = arrIn(intX)
Next
strout = arrOut
strOne = Left(strout, InStr(strout, "username:s:") + Len("username:s:") -
1)
strUserName = Mid(strout, Len(strOne) + 1, InStr(Len(strOne), strout,
vbCrLf) - (Len(strOne) + 1))
strThree = Mid(strout, Len(strOne) + Len(strUserName) + 1)
strUserName = UserNAme
strout = strOne & strUserName & strThree
strout = Chr(255) & Chr(254) & StrConv(strout, vbUnicode)
intff = FreeFile()
Open PATH_NAME_1 For Binary Access Write Lock Write As intff
ReDim arrOut(0 To LenB(strout))
arrOut = StrConv(strout, vbFromUnicode)
Put #intff, , arrOut
Close #intff
Shell ("mstsc """ & PATH_NAME_1 & """")
End Function
' Code End
' **************************************
--
Terry Kreft
"No Spam" wrote in message
news:84oal1516g1khvgrisprcl5qs08bc7csnf@4ax.com...
> Dear Access 2003 Users,
>
> Is there any way to launch Terminal Server from Access and pass along
> the user name that is in a text box? I believe mstsc.exe can be
> passed an IP address (/v), but can you also pass along a username or
> password that sits on a form? Thank you.
>
> Kevin