Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Windows Username Substitution

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,52108
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Windows Username Substitution
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Windows Username Substitution - 9/21/2007 5:13:18 AM   
  buechler66

 

Posts: 2
Score: 0
Joined: 9/21/2007
Status: offline
Hi.  I'm trying to use the following script to create an icon on the users Desktop.  In line 4 I attempt to use the %USERNAME% variable, but this line errors out when I run the script.  Is this the proper way to substitute for the user's desktop directory?  Any help would be greatly appreciated.  Thanks.

___________________________________________________________________________________________________________

'Create a WshShell Object
Set WshShell = Wscript.CreateObject("Wscript.Shell")
'Create a WshShortcut Object
Set oShellLink = WshShell.CreateShortcut("C:\Documents and Settings\%USERNAME%\My Documents\TTMS Menu (Web).lnk")
'Set the Target Path for the shortcut
oShellLink.TargetPath="C:\Program Files\Internet Explorer\iexplore.exe"
'Set Arguments for Target Path for the shortcut
oShellLink.Arguments="http://springfield01:7777/forms/frmservlet?config=ttmsmenu&userid=%orauser%/%orapass%@fc"
'Set Working Directory for the shortcut
oShellLink.WorkingDirectory = "c:\"
'Set HotKey
'oShellLink.Hotkey = "ALT+SHIFT+T"
oShellLink.WindowStyle = 2

oShellLink.IconLocation = "c:\ttmsapps\compiled\ttmsdataview.exe, 0"
'Save the shortcut
oShellLink.Save
'Clean up the WshShortcut Object
Set oShellLink = Nothing
 
 
Post #: 1
 
 RE: Windows Username Substitution - 9/21/2007 5:21:14 AM   
  dm_4ever


Posts: 2723
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
For the user's desktop...

Set oShellLink = WshShell.CreateShortcut(WshShell.SpecialFolders("Desktop") & "\TTMS Menu (Web).lnk")

you can check the path by doing something like:

Set WshShell = Wscript.CreateObject("Wscript.Shell")
WScript.Echo WshShell.SpecialFolders("Desktop") & "\TTMS Menu (Web).lnk"

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to buechler66)
 
 
Post #: 2
 
 RE: Windows Username Substitution - 9/21/2007 5:35:48 AM   
  buechler66

 

Posts: 2
Score: 0
Joined: 9/21/2007
Status: offline
You rock!  Thanks so much for the reply.

(in reply to buechler66)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Windows Username Substitution Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts