Jump to content

logon script for remote desktop


-= MD =-

Recommended Posts


I dont think that it is possible. What are you trying to do ?

You could use a batch command or VBS script. Eiither to run when yyou logon or double click it. As when you connect to a RD that is already running it will have already loaded up all the system/user settings.

hail hail

Link to comment
Share on other sites

All profiles should have their own independent "Startup" folder, as well as a shared one under the "All Users" profile. As long as no one else is using you username/password, and you copy the script to "C:\Documents and Settings\<YOUR USERNAME>\Start Menu\Programs\Startup" you should be the only one that runs the script after login.

Link to comment
Share on other sites

What he means is he wants a script that runs if he logs in with remote desktop, but which does not run if he logs on locally. You might try (assuming you have XP) expanding the options in the connection dialog, and there's a program tab where you could put your batch/VBS file.

Link to comment
Share on other sites

What you need is a utility that you can call from the batch file that can tell if your remote or not and pass a errorlevel.

Like a hypothetical program called chkrmt.exe - i.e:

echo ... welcome to my PC

echo ... determining status
chkrmt.exe
if errorlevel=1 goto REMOTE

echo ... welcome local user
<bunch of stuff here>
goto :EOF

:REMOTE
echo ... wecome remote user
<bunch of stuff here>
goto :EOF

Link to comment
Share on other sites

start - run - mstsc - options - programs

alternatively...

enter in your host etc and then save the connection. Then create a batch file that remotely kills the processes, something like pskill would do the job (www.sysinternals.com) and then launch the RDC connection

Link to comment
Share on other sites

@-= MD =-

Of course is this possible. First of all create a new remote user and activate logon script.

Logon.gif

Place this *.vbs script in the following directory %WinDir%\System32\Repl\Import\Scripts.

In the following code (I use this) you can see that I start/stop services, load programs, make mappings, change proxy settings, change host file settings and redirect data directory to a different drive.

'****************************************************************************************
' NAME    : Logon.Vbs
' AUTHOR  : Robert Collewijn
' DATE    : 29-3-2001
'
' COMMENT  : This Script is for making network and printer connections.
'      Place this script in the following directory.
'      %WinDir%\System32\Repl\Import\Scripts
'
'****************************************************************************************
Option Explicit
' On Error Resume Next

'*** Define Script title ****************************************************************
Dim sVersion, sTitleLng, sTitleSht, vFileName, vPositie, vName

sVersion  = " v1.5"                    ' Define Version
sTitleLng  = "R.Collewijn - Hardware Diagnostic"      ' Define Long title
sTitleSht  = "Hardware Diagnostic"              ' Define Short title

vFileName  = Wscript.ScriptName              ' Script Name difineren
vPositie  = InStrRev(vName, ".")
If vPositie > 0 Then vFileName = Left (vFileName, sPositie -1)


'*** Define Object variable *************************************************************
Dim sUserDrive

sUserDrive  = "E:"                      ' Define default user drive

'*** Define Object variable *************************************************************
Dim wnw, wsh, fso              

Set wnw = WScript.CreateObject("WScript.Network")
Set wsh = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")


'*** Remove Network Connections *********************************************************

   Dim cDrive, sDrive, vDrv      
   
   For cDrive = 26 To 5 Step -1
   sDrive = Chr(cDrive + 64) & ":"
   If fso.DriveExists(sDrive) Then
     Set vDrv = fso.GetDrive(sDrive)
     If vDrv.drivetype = 3 Then                ' If it is a network drive
     wnw.RemoveNetworkDrive sDrive            ' Remove mapping
 End If
     End If
     Set vDrv = Nothing
   Next


'*** Create network connection **********************************************************
Dim sUser, sCUser, sUserDir
 
sUser = wnw.UserName                    ' Curent usernaam
sCUser = UCase(sUser)                    ' Curent username in uppercase
sUserDir  = sUserDrive & "\Documents and Settings\" & sUserDir & "\"

'--- Restore shell folders --------------------------------------------------
Dim sSFRoot, sUSFRoot, aFRoot, oItem
sSFRoot = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\"
sUSFRoot = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\"

aFRoot = Array(sSFRoot, sUSFRoot)

For Each oItem In aFRoot
 wsh.RegWrite oItem & "Cookies", sUserDir & "Cookies"
 wsh.RegWrite oItem & "Desktop", sUserDir & "Desktop"
 wsh.RegWrite oItem & "Favorites", sUserDir & "Favorites"
 wsh.RegWrite oItem & "History", sUserDir & "Local Settings\History"
 wsh.RegWrite oItem & "Local AppData", sUserDir & "Local Settings\Application Data"
 wsh.RegWrite oItem & "Local Settings", sUserDir & "Local Settings"
 wsh.RegWrite oItem & "My Music", sUserDir & "My Documents\My Music"
 wsh.RegWrite oItem & "My Pictures", sUserDir & "My Documents\My Pictures"
 wsh.RegWrite oItem & "My Video", sUserDir & "My Documents\My Video"
 wsh.RegWrite oItem & "Personal", sUserDir & "My Documents"
  wsh.RegWrite oItem & "Templates", sUserDir & "Templates"
Next


'--- Restore settings for remote network ------------------------------------
If (sCUser = "XXXXXX" Or sCUser = "XXXXXXX") Then
 wnw.MapNetworkDrive "F:", "\\DESKTOP\SHARE_1$", , sUser
 wnw.MapNetworkDrive "G:", "\\DESKTOP\SHARE_2$", , sUser
 wnw.MapNetworkDrive "H:", "\\DESKTOP\SHARE_3$", , sUser
 'enz...
End IF


'--- disable proxy settings -------------------------------------------------
wsh.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0 ,"REG_DWORD"
wsh.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", "about:blank"


'--- Change hosts file ------------------------------------------------------
Dim sCurrentDate, sHostsFile

sCurrentDate = Date
sCurrentDate = FormatDateTime(sCurrentDate,1)
Set sHostsFile = fso.CreateTextFile("c:\windows\system32\drivers\etc\hosts", True)
 sHostsFile.WriteLine "# This HOSTS file is automatic generated on " & sCurrentDate
 sHostsFile.WriteLine "# by Network Connection scripting tool written by Robert Collewijn."
 sHostsFile.WriteBlankLines  2
 sHostsFile.WriteLine "127.0.0.1         localhost"
 sHostsFile.WriteBlankLines  1
 sHostsFile.WriteLine "xxx.xxx.xxx.xxx   Example           # Desktop Example"
 sHostsFile.Close
Set sHostsFile = Nothing


'--- Start/stop program's ---------------------------------------------------
wsh.Run "C:\Windows\Logi_mwx.exe", 2, False
wsh.Run "C:\Progra~1\DiskCl~1\dclean.exe -q", 2, False
wsh.Run "C:\Progra~1\Networ~1\VirusS~1\shstat.exe", 2, False
wsh.Run "C:\Progra~1\Networ~1\Common~1\Update~1.exe /StartedFromRunKey", 2, False
wsh.Run "Net stop services", 2, False

'*** End ********************************************************************************

Link to comment
Share on other sites

Just looking a Group Policy for another reason and came across this. Dont know if it is what you want but a handy find.

To run RD with a cerrtain app only. As in the original TS do this.

START / RUN / GPEDIT.MSC

USER CONFIGURATION / ADMINISTRATIVE TEMPLATES / WINDOWS COMPNENTS / TERMINAL SERVICES / START A PROGRAM ON CONECTIOIN.

This would let you only run MS Word for example.

hail hail

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...