Jump to content

Silly simple batch file question


Recommended Posts

Dang it - magic incantation needed here, and I'm missing it.

As part of the pdfFactory install, I want to remove the default Start Menu folder, and to load the following into the Default User hive ... This is done in the RunOnceEx.cmd batchfile

REG LOAD "HKU\CUSTOM" "C:\Documents and Settings\Default User\NTUSER.DAT"
REG ADD HKU\CUSTOM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v pdfFactory /t REG_EXPAND_SZ /d "cmd.exe /C rd /q /s \"%userprofile%\Start Menu\Programs\pdfFactory Pro\"" /f
REG UNLOAD "HKU\CUSTOM"

Note the %userprofile% there. That's what I want in the key, so when a new user is created, the new userid is replaced in there.

But bloody batchfile insists on putting in the current user when this command is run, so the effective command looks like :

REG ADD HKU\CUSTOM\Software\Microsoft\Windows\CurrentVersion\RunOnce /v pdfFactory /t REG_EXPAND_SZ /d "cmd.exe /C rd /q /s \"c:\Documents and Settings\Administrator\Start Menu\Programs\pdfFactory Pro\"" /f

Which is NOT what I want.

How do I "protect" the %userprofile% string in there from replacement in the batchfile ?

D.

Link to comment
Share on other sites


First of all, you have a leading \... that'll mess up your path...

ie:

rd /q /s \"%userprofile%\Start Menu\Programs\pdfFactory Pro\"" /f

should be

rd /q /s "%userprofile%\Start Menu\Programs\pdfFactory Pro\"" /f

Unless there's a specific reason for it.

And to insert %userprofile% in your batch file... write %%userprofile%%.

ie:

rd /q /s "%%userprofile%%\Start Menu\Programs\pdfFactory Pro\"" /f

Link to comment
Share on other sites

jcarle -

Thanks - the %%userprofile%% is what I was looking for !

There isn't a leading \ in there - that's escaping the double-quotes, to make sure that they are in the key.

"cmd.exe /C rd /q /s \"%userprofile%\Start Menu\Programs\pdfFactory Pro\""

D.

Link to comment
Share on other sites

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