Mysticalice Posted April 27, 2007 Posted April 27, 2007 (edited) First off, i'm not even sure if this is the right forum to ask this question on, but i searched for "WSH help" and got a few results from this forum, so i thought it would be worth a try Thanks in advance for any help you can give me. I'm trying to create a login file that will link a user's startup folder to their desktop as a shortcut. Here's what I have:Set oWS = WScript.CreateObject("WScript.Shell") sLinkFile = "C:Documents and Settings%username%DesktopStartup.LNK" Set oLink = oWS.CreateShortcut(sLinkFile) oLink.TargetPath = "C:Documents and Settings%username%Start MenuProgramsStartup" oLink.Save I've put the above in a text file, and saved as *whatever*.vbs When i try to run it, I get an error message saying:Unable to save shortcut C:Documents and Settings%username%DesktopStartup.LNK Code: 80070003 Source: WshShortcut.Save If I change the sLinkFile to the user's username, for example:sLinkFile = "C:Documents and SettingsmarysmithDesktopStartup.LNK" then it works right away when i double click on the script, and the folder, linked to the user's startup directory, is created. Seems it doesn't like it only when i use the "%username%" in slinkfile. What am i doing wrong? Any help appreciated Regards Edited July 30, 2013 by Mysticalice
Xenobiologist Posted May 6, 2007 Posted May 6, 2007 Hi, you can do it with Autoit. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
November Posted May 7, 2007 Posted May 7, 2007 First off, i'm not even sure if this is the right forum to ask this question on, but i searched for "WSH help" and got a few results from this forum, so i thought it would be worth a try Thanks in advance for any help you can give me.I'm trying to create a login file that will link a user's startup folder to their desktop as a shortcut. Here's what I have:Set oWS = WScript.CreateObject("WScript.Shell") sLinkFile = "C:\Documents and Settings\%username%\Desktop\Startup.LNK" Set oLink = oWS.CreateShortcut(sLinkFile) oLink.TargetPath = "C:\Documents and Settings\%username%\Start Menu\Programs\Startup\" oLink.SaveI've put the above in a text file, and saved as *whatever*.vbsWhen i try to run it, I get an error message saying:Unable to save shortcut C:\Documents and Settings\%username%\Desktop\Startup.LNKCode: 80070003Source: WshShortcut.SaveIf I change the sLinkFile to the user's username, for example: sLinkFile = "C:\Documents and Settings\marysmith\Desktop\Startup.LNK"then it works right away when i double click on the script, and the folder, linked to the user's startup directory, is created.Seems it doesn't like it only when i use the "%username%" in slinkfile.What am i doing wrong?Any help appreciatedRegards~LorenzoHi,Just for a little trouble shooting :Open a dos windows and type:echo %username%Does it give the username name?If not double check ths system environment variablesCheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font]
MHz Posted May 7, 2007 Posted May 7, 2007 (edited) set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo "UseName is " & WshShell.ExpandEnvironmentStrings("%username%") In VBScript, you need to expand environmental strings. Edited May 7, 2007 by MHz
November Posted May 7, 2007 Posted May 7, 2007 set WshShell = WScript.CreateObject("WScript.Shell") WScript.Echo "UseName is " & WshShell.ExpandEnvironmentStrings("%username%") In VBScript, you need to expand environmental strings. Ohhhhh Damn VBS Thats why i love autoit... hehehehe Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now