Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSTSC link from Access 1

Status
Not open for further replies.

Beowulf005

Technical User
Apr 5, 2005
640
I has an Access database of servers, passwords, ets for a help desk. What I would like to have is the ability to launch MSTSC by clicking on the server name. The trouble I am finding with examples online is with the naming reference.
Looking to make a link or button that would open the server listed as
Site [red]A[/red] server[red]A[/red]fileprint
Site [red]B[/red] server[red]B[/red]fileprint

I have a field for site name, then a concatenate field name fullservername.

When frustrated remember, in the computer world there is almost always a backdoor.
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Code:
Private Sub ConnectToServer(ByVal sServer As String)
    Try
        Dim sCommand As String = _
          System.Environment.GetEnvironmentVariable("SystemRoot") & _
          "\system32\mstsc.exe"
        System.Diagnostics.Process.Start(sCommand, _
               GetArgumentsForServer(sServer))
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub
I need to add to the end of the \system32\mstsc.exe [red]v:/servera[/red] based on the value of a field within the displayed form.
I am linking this code to a button on the form.

When frustrated remember, in the computer world there is almost always a backdoor.
 
Ok found better code (I think -at least it runs mstsc now)
Code:
Private Sub Command6_Click()
Dim stAppName As String

stAppName = "c:\windows\system32\mstsc.exe"
Call Shell(stAppName, 1)

End Sub

Is there a way to add a variable to the end of the stappname = path?

IE
c:\windows\system32\mstsc.exe v:/"value of fullservername field on current form"

Or make the stappname ="access field"

When frustrated remember, in the computer world there is almost always a backdoor.
 
Ok made some modifcations to the code but now it will not run
Code:
Private Sub command6_click()
    Dim atAppName As Integer
    atAppName = CurrentDb.OpenRecordset("SELECT (site_query.remote) from (site_query)")
    Call Shell(atAppName, 1)
Exit Sub

server_query.remote is =
Code:
SELECT site.ID, site.site, "c:\windows\system32\mstsc.exe /v:site" & [red][server][/red] & "SFP01" AS Remote
FROM site;
[red]server[/red] is where [red]A or B[/red] as shown in the orginal post

When frustrated remember, in the computer world there is almost always a backdoor.
 
Is there a way to add a variable to the end of the stappname = path?
Yes, something like:
Code:
Private Sub Command6_Click()
Dim stAppName As String

stAppName = "c:\windows\system32\mstsc.exe [red]v:/" & yourfullservernamefield[/red]
Call Shell(stAppName, 1)

End Sub
Hope this helps

Andy
---------------------------------
[green]' Signature removed for testing purposes.[/green]

 
Still hitting the wall...

I think my problem is I am getting all the values for a field not just the "current" value displayed on the form.
Current code
Code:
Option Compare Database
    Dim rs As DAO.Recordset
    Set rs = db.OpenRecordset("Districts_Query", dbOpenDynaset)
    Option Explicit

Private Sub command6_click()
    stAppName = [Remote]
    Call Shell(stAppName, 1)
End Sub

Getting error --Invalid outside procedure.

When frustrated remember, in the computer world there is almost always a backdoor.
 
You're getting that error because you're trying to assign a value to your rs variable outside of a procedure (and that is invalid, hence the error). Once that's fixed, seems you are using Option Explicit you'll have to declare your stAppName variable or you'll get another error.

As I have no idea what you want to do with your recordset I'm going to exclude it from this example (just put the code for it back in when the recordset needs to be populated, e.g. on the click of a button or load of the form). Here's a cleaned up version of your current code:
Code:
Option Compare Database
Option Explicit

Dim rs As DAO.Recordset

Private Sub command6_click()

    Dim stAppName As String

    stAppName = [Remote]
    Call Shell(stAppName, 1)
    
End Sub
Hope this helps

Andy
---------------------------------
[green]' Signature removed for testing purposes.[/green]

 
Sweet It works now. Thanks for the help.

When frustrated remember, in the computer world there is almost always a backdoor.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top