victordr
asked on
Startup script for terminal users
I have a 2003 terminal server setup so when a user logins to RDP it runs the following program. What i am looking to do is set it so it runs a script that will launch a shortcut from this user's roaming profile instead.
What would be the best way to do this
I am also having an issue when they close the application, sometimes it doesn't logoff.
What would be the best way to do this
I am also having an issue when they close the application, sometimes it doesn't logoff.
make a logon script file named roamingStartUp.vbs
'-----code----
Dim strUser
Dim WshNetwork ,WshShell
Set WshNetwork = WScript.CreateObject("WScr ipt.Networ k")
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
strUser = WshNetwork.UserName 'connected user
WshShell .Run PathToProfileRoot & strUser & "\Application.lnk"
Set WshShell =Nothing
Set WshNetwork =Nothing
'-----code----
Dim strUser
Dim WshNetwork ,WshShell
Set WshNetwork = WScript.CreateObject("WScr
Set WshShell = WScript.CreateObject("WScr
strUser = WshNetwork.UserName 'connected user
WshShell .Run PathToProfileRoot & strUser & "\Application.lnk"
Set WshShell =Nothing
Set WshNetwork =Nothing
Try this code. Change the variable "EXECUTABLE" and "ARGUMENTS" to reflect the path to the executable and passed arguments. Leave ARGUMENTS like it is if you don't intend to pass arguments.
'Path to Navision. %USERNAME% will automatically be replaced with correct value
EXECUTABLE = "\\server\folder$\%username%\folder\file.exe"
ARGUMENTS = ""
int_ReturnCode = 0
Set obj_Shell = WScript.CreateObject("WScript.Shell")
Set obj_FSO = WScript.CreateObject("Scripting.FileSystemObject")
str_path = fun_StringWithUsername(EXECUTABLE) '(fix %username% if present)
If ARGUMENTS <> "" Then
str_RunCmd = str_path & " " & ARGUMENTS
Else
str_RunCmd = str_path
End If
If obj_FSO.FileExists(str_File) = true Then
obj_Run = obj_Shell.Run(str_RunCmd, 1, false)
If varType(obj_Run) = 2 Then int_ReturnCode = obj_Run
End If
Wscript.Quit(int_ReturnCode)
Function fun_StringWithUsername ( str_StringTemp )
str_StringTemp = LCase(str_StringTemp)
If InStr(str_StringTemp, " ") <> 0 Then str_StringTemp = Chr(34) & str_StringTemp & Chr(34) '(enclose in apostrophes (") if string contains space(s))
Set obj_Net = WScript.CreateObject("WScript.Network")
str_UserName = obj_Net.UserName
If InStr(str_StringTemp, "%username%") <> 0 Then
fun_StringWithUsername = Replace(str_StringTemp, "%username%", str_UserName)
Else
fun_StringWithUsername = str_StringTemp
End If
End Function
ASKER
Is will just be a .lnk file. Will this still work?
i do it in the users profile in AD under environment using the start following program at login our two entries are
program file name
C:\WINDOWS\system32\telnet .exe telnet.xxxxxx.com
and start in
C:\WINDOWS\system32
program file name
C:\WINDOWS\system32\telnet
and start in
C:\WINDOWS\system32
ASKER
It isn't launching the .lnk file i have in the user's profile with your script holthd
ASKER
belfegor:
I tried your code also and it isn't working.
WshShell.Run "\\server2\profiles" & strUser & "\navilive.lnk"
Is this correct?
I tried your code also and it isn't working.
WshShell.Run "\\server2\profiles" & strUser & "\navilive.lnk"
Is this correct?
did you try my way? i know it works, we use it for half of our users. if you need gp for some reason ok, but i know this works
ASKER
I have to edit 48 user's to make this change though.
lol. 48 is nothing. i see what you're saying though, but we have like 2000 users and when i changed our mail from mail.domain.com to domain.com, i had to type every email address over manually, so i appreciate whaty ou'er saying. you know whats best though man, if you're under a time crunch, try that and then see if you can fix it with gpo, otherwise good luck.
ASKER
I still need a script though. It has to figure out what the username is to put it to the correct .lnk file in the correct profile folder.
victordr, sorry the script did not work but it's ok when I use it. Try the below script. Edit the "FILE" variable to match the path to the shortcut. Notice that the script will give you a box saying whether or not it found the file or not. Remove the lines starting with "Wscript.Echo" before putting into production.
If you still have problems please post an example path to one of the files you are trying to start.
NB! You must put this in as a LOGON SCRIPT not STARTUP SCRIPT. You're sure your GPO's are setup correctly?
-Daniel
If you still have problems please post an example path to one of the files you are trying to start.
NB! You must put this in as a LOGON SCRIPT not STARTUP SCRIPT. You're sure your GPO's are setup correctly?
-Daniel
Const WindowVisible = 1
Const WindowHidden = 0
Const WaitForProcessTrue = 1
Const WaitForProcessFalse = 0
Set obj_Shell = WScript.CreateObject("WScript.Shell")
Set obj_FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set obj_Net = WScript.CreateObject("WScript.Network")
strUserName = obj_Net.UserName
FILE = "\\server\folder$\" & strUserName & "\folder\file.lnk"
If obj_FSO.FileExists(FILE) = TRUE Then
Wscript.Echo FILE & " found!"
obj_Shell.Run FILE, WindowVisible, WaitForProcessFalse
Else
Wscript.Echo FILE & " WAS NOT FOUND!!!"
End IF
Below is a cleaned up version that does not give you any messages. Once you have tested with the script in my previous post and got it working you just overwrite the line "FILE = ..." in this script and you're good to go.
-Daniel
-Daniel
Const WindowVisible = 1
Const WindowHidden = 0
Const WaitForProcessTrue = 1
Const WaitForProcessFalse = 0
Set obj_Shell = WScript.CreateObject("WScript.Shell")
Set obj_FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set obj_Net = WScript.CreateObject("WScript.Network")
strUserName = obj_Net.UserName
FILE = "\\server\folder$\" & strUserName & "\folder\file.lnk"
If obj_FSO.FileExists(FILE) = TRUE Then
obj_Shell.Run FILE, WindowVisible, WaitForProcessFalse
End IF
Set obj_Shell = Nothing
Set obj_FSO = Nothing
Set obj_Net = Nothing
ASKER
Daniel,
The orginal script is is set to run an .EXE correct? So using a lnk file wouldn't work. I am just trying to understand the code and make sure i am reading it correctly.
The orginal script is is set to run an .EXE correct? So using a lnk file wouldn't work. I am just trying to understand the code and make sure i am reading it correctly.
ASKER
Now i also need to to auto-start IE and have it minimized.. Can i add this to this script?
ASKER
Now i am getting this error.
startuperror.JPG
startuperror.JPG
ASKER
Would this be because i have the terminal server so locked down?
ASKER
Can someone please help me with this? I need to get this resolved? Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just a side note; the third parameter WaitForProcessTrue and WaitForProcessFalse dictates whether or not the script will wait for the executed file (thread) to exit (terminate). If WaitForProcessTrue is used for opening Internet Explorer you will experience a 10 minute (GPO default) delay because the script waits for someone or something to close Internet Explorer manually. Since Windows Explorer is not loaded by default before all logon scripts has finished nobody is able to close the application and you'll get a severe delay.
If WaitForProcessFalse is used it will only slam the command into Run and then proceed with whatever comes next in the script. Be aware of this setting.
-Daniel
If WaitForProcessFalse is used it will only slam the command into Run and then proceed with whatever comes next in the script. Be aware of this setting.
-Daniel
ASKER
I resovled it on my own. I had to use CSCRIPT C:\path to vbs file.
ASKER
Event Source: UPHClean
Event Category: None
Event ID: 1401
Date: 2/15/2011
Time: 1:19:37 PM
User: DOMAIN\Extrude1
Computer: TS1
Description:
The following handles in user profile hive DOMAIN\Extrude1 (S-1-5-21-366032897-207377
Rtvscan.exe (2100)
HKCU\Software\Symantec\Sym
I just loaded UPHClean and got this in the event log.