Jump to content

Recommended Posts

Posted (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" /Y

The 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 prompt
set PATH=%PATH%;c:\;d:\;d:\dosutils;\d:\dosapps;d:\dosapps\qb45

::Add items to Quick Launch
COPY "%windir%\System32\calc.exe" "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch" /Y

::Delete this file
DEL CleanUp.cmd
EXIT

I 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 by NOTS3W

Posted

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?

Posted

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'

Posted

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 /f

Or 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 /f

If 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.

Posted

Here is a VBS script that will creare a shortcut of Calc in the QuickLaunch Folder.

Save as Add_Calc_QL.vbs

Dim Act, ObjShortCut, QuickLaunch, StrCalc
Set 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 = StrCalc
ObjShortCut.Save

This is for those who want to use a cmd promt

Save as Add_Calc_QL.cmd

@Echo Off
CLS
Color B1
Mode 65,3
Title Add Calc ShortCut
Set QLSC=%SystemDrive%\QLCalc.vbs
Echo 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 QuickLaunch
ping -n 3 127.0.0.1>nul
Del %QLSC%

Posted

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" /Y

It 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

Posted

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

Posted

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 put

cmd /c reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /v cleanup /d %systemdrive%\cleanup.cmd /f

into 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

Posted (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 /f

PS. 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 by Martin H
Posted

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

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...