NOTS3W Posted May 24, 2007 Posted May 24, 2007 (edited) Updated: I still need help with this line in CleanUp.cmd:COPY "%windir%\System32\calc.exe" "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch" /YThe destination folder doesn't exist before the command gets executed. See my second post below.Thanks.------------------------------------------------------------------------I have three commands in my CleanUp.cmd file that do not execute. They are interspersed with other commands that run as expected. Is there any reason why these commands shouldn't work?::Append additional folders to Path environment variable for command promptset PATH=%PATH%;c:\;d:\;d:\dosutils;\d:\dosapps;d:\dosapps\qb45::Add items to Quick LaunchCOPY "%windir%\System32\calc.exe" "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch" /Y::Delete this fileDEL CleanUp.cmdEXITI do have some reg tweaks that run from cmdlines.txt at T-12. One of them turns on the Quick Launch toolbar. All of that should be done by the time I copy Calc.exe to the Quick Launch folder. The command does work if I run it after installation.I cannot figure out why these commands are not working during installation. Can anyone help?Thanks.Ray Edited May 26, 2007 by NOTS3W
NOTS3W Posted May 26, 2007 Author Posted May 26, 2007 Okay, I figured out the path situation (I was going about that all wrong) and how to delete CleanUp.cmd after it exits. But I still need some help with the copy problem. The folder I'm trying to copy to, "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch", does not yet exist at the time CleanUp.cmd tries to copy calc.exe into it. IE7 gets installed from a RyanVM Addon which I *think* happens at T-13 if I'm understanding the unattended timeline correctly. So shouldn't the folders exist by the time CleanUp.cmd runs from GUIRunOnce? Is there somewhere else I can run a Copy command and be sure it occurs AFTER the folders exist?
Yzöwl Posted May 26, 2007 Posted May 26, 2007 You do not copy executables to the 'quick launch' directory; you create shortcuts to executables there!Also you'd be better off using '%AppData%' instead of '%UserProfile%\Application Data'
Martin H Posted May 26, 2007 Posted May 26, 2007 Hi NOTS3W Try this line at the end of your batch file :reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v cleanup /d %systemdrive%\install\cleanup.cmd /fOr if you just use 'GuiRunOnce' without any batch file :cmd /c reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v cleanup /d %systemdrive%\install\cleanup.cmd /fIf you don't have 'cleanup.cmd' in '%systemdrive%\install\', then change the path in the above line.When GuiRunOnce(i.e. HKLM\...\RunOnce), RunOnceEx, RunOnce and Run(and several more that i don't care to go on listing) are used by themselves in an unattended environment, then they are executed before the explorer.exe(i.e. when you see the desktop) is completely loaded, and this means that some things aren't set up yet at that time(i have tried nearly all the keys in 10 VMware sessions). When you then set your 'cleanup.cmd' to run from another one of the "run-type" reg keys, then for some strange reason, then that key will wait to execute untill explorer.exe is fully loaded(but not if that key was the only used key i.e. if it wasen't called from another key). I have had this problem also, but that was about not being able to delete the 'Links' folder + '*.url' shortcuts in the Favorites folder from RunOnceEx, but when i changed my RunOnceEx.cmd file to let 'cleanup.cmd' run from any of the other "run-type" reg keys, then it worked, but when i tried to only use 'runOnce' and not RunOnceEx at all, then it didn't, because of the above strange issue.
gunsmokingman Posted May 26, 2007 Posted May 26, 2007 Here is a VBS script that will creare a shortcut of Calc in the QuickLaunch Folder.Save as Add_Calc_QL.vbsDim Act, ObjShortCut, QuickLaunch, StrCalcSet Act = CreateObject("WScript.Shell")QuickLaunch = Act.ExpandEnvironmentStrings("%AppData%\Microsoft\Internet Explorer\Quick Launch")StrCalc = Act.ExpandEnvironmentStrings("%SystemRoot%\system32\calc.exe")Set ObjShortCut = Act.CreateShortcut(QuickLaunch & "\calc.lnk")ObjShortCut.TargetPath = StrCalcObjShortCut.SaveThis is for those who want to use a cmd promtSave as Add_Calc_QL.cmd@Echo OffCLSColor B1Mode 65,3Title Add Calc ShortCutSet QLSC=%SystemDrive%\QLCalc.vbsEcho Dim Act, ObjSC, QuickLaunch, StrCalc > %QLSC%Echo Set Act = CreateObject("WScript.Shell") >> %QLSC%Echo QuickLaunch = Act.ExpandEnvironmentStrings("%%AppData%%\Microsoft\Internet Explorer\Quick Launch") >> %QLSC%Echo StrCalc = Act.ExpandEnvironmentStrings("%%SystemRoot%%\system32\calc.exe") >> %QLSC%Echo Set ObjSC = Act.CreateShortcut(QuickLaunch ^& "\Calc.lnk") >> %QLSC%Echo ObjSC.Description = Act.ExpandEnvironmentStrings("%%UserName%%") ^& " Open Calc.exe" >> %QLSC%Echo ObjSC.TargetPath = StrCalc >> %QLSC%Echo ObjSC.Save >> %QLSC%start/w %QLSC%Echo.Echo Completed Adding Calc.exe To QuickLaunchping -n 3 127.0.0.1>nulDel %QLSC%
NOTS3W Posted May 26, 2007 Author Posted May 26, 2007 Thanks, gunsmokingman.I've just started reading about the creation of shortcuts and planned to use a shortcut for this (and other things) rather than making a complete copy of the exe for each new appearance. I don't know anything about how to place a vbs script into my unattended file set, but I will try the cmd version.What would be very helpful is a command line script that mimics Windows' GUI Create Shortcut. When Windows creates a shortcut, it knows where the icon file is, etc. You don't have to provide any parameters. Maybe there's already a script to do this and I just haven't gotten there yet, but it would be great to have a routine that takes a single argument, the full path to the executable, and could create a shortcut in the same folder like Windows does. Then you could move the shortcut to wherever you want it. Or an optional second argument might specify where the shortcut should be placed so you could create and move it in one step. In my very limited research into this so far, I've seen scripts that require as many as four parameters to create a shortcut and others that hard code the executable details into each shortcut creation routine.My real problem at the moment, though, is that the destination folder doesn't exist. I brute forced my way around that by checking for the existence of each folder and creating it if it didn't already exist:if not exist "%UserProfile%\Application Data\." md "%UserProfile%\Application Data"if not exist "%UserProfile%\Application Data\Microsoft\." md "%UserProfile%\Application Data\Microsoft"if not exist "%UserProfile%\Application Data\Microsoft\Internet Explorer\." md "%UserProfile%\Application Data\Microsoft\Internet Explorer"if not exist "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\." md "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch"COPY "%windir%\System32\calc.exe" "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch" /YIt ain't pretty and it's only temporary until I can figure out how to delay the copy until the destination is created. Right now, it's in CleanUp.cmd but even that's too early.Ray
NOTS3W Posted May 26, 2007 Author Posted May 26, 2007 Yzowl,Understood and agreed. I was just testing with a small program to see how to put something into the Quick Launch folder and be able to see it appear on the QL toolbar. I'm still working on how to create a shortcut.Thanks for the tip on %AppData%.Ray
NOTS3W Posted May 26, 2007 Author Posted May 26, 2007 Martin,I use nLite and enter %SystemDrive%\CleanUp.cmd in the RunOnce section and I copy CleanUp.cmd to $OEM$\$1.At the bottom of WINNT.SIF, nLite includes[GuiRunOnce]"%SystemRoot%\System32\nLite.cmd"nLite.cm_, in turn, contains my %SystemDrive%\CleanUp.cmd command.I think that meets your condition of running GUIRunOnce without a batch file other than cleanup.cmd itself.If I understand correctly, I should putcmd /c reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v cleanup /d %systemdrive%\cleanup.cmd /finto nLite's RunOnce command list and it will be executed in place of my CleanUp.cmd which will itself only be run after explorer is loaded. I'll try that today. If it works, it's a pretty painless solution.Thanks.Ray
Martin H Posted May 26, 2007 Posted May 26, 2007 (edited) Hi NOTS3W Just open 'WINNT.SIF' and under 'GuiRunOnce', then delete the line that nLite had made and instead insert this line :cmd /c reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v cleanup /d %systemdrive%\CleanUp.cmd /fPS. I am not 100% certain that this will work, though...Edit: Oh, sorry - i didn't even know that 'reg' was an actual executable(*.exe), and just thought that it was an internal cmd.exe command, but in that case, then there's no need for the extra 'cmd /c'... Edited May 27, 2007 by Martin H
NOTS3W Posted May 26, 2007 Author Posted May 26, 2007 Martin,That's probably not a good idea since nlite.cmd still needs to run in guirunonce. It also installs the .NET environment from there. I tried the other option I thought might work (above) and nLite inserted the line into nLite.cmd as expected and everything worked just fine. Thanks for your advice.In the meantime, I found shortcutter.exe which seems to work great to make simple shortcuts from a batch file. I'll try that with a new installation this evening.Ray
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