Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Sign in to follow this  
shorterxp

Pointers on how to do this command?

Recommended Posts

Posted (edited)

Hi,

Its known, once app is installed, a key is formed in registry for its uninstall. Can one refer to this info using a command line, in say, a batch script?

Need/scenario: An app may not be installed in its default directory AKA user defines other than default C:\ during install, so this causes errors if 'extras' are subsequently installed (should those refer to a default / non dynamic location).

Is it possible? I trust a coder guru to show me the way,

image.jpg

Edited by shorterxp

Share this post


Link to post
Share on other sites

If you want to read a reg key from a batch file, you can use "reg query", for example :

for /f "usebackq tokens=2,* skip=2" %%L in (
    `reg query "HKCU\Software\Hotnuma\MovEdit" /v appDir`
) do set appdir=%%M

set movlist=%appdir%\movlist.exe

In this example, I read an "appDir" value located in "HKCU\Software\Hotnuma\MovEdit" and put the result in an appdir variable. Then I use the variable to set an absolute "movlist" path.

:P

  • Upvote 1

Share this post


Link to post
Share on other sites
Posted (edited)

Ok I found the SS64 page regarding /FOR.

Now that I look at it, the command when written is not within a .bat or .cmd but executed from within SFX self extraction.

Update: SFX is proving more difficult. 

Normally, SFX places files in %programfiles% but this isn't ideal as stated. SFX self extract can execute commands before extraction, (good), however the Wizard is problematic, when I enter %appdir% in Path To Extract, absolute path (header option) greys out. The absolute path option is only available when common windows variables are entered, i.e. %user profile% etc.

Plan B, I propose to extract files to temp folder, run example.cmd, which contains /FOR script, and command to move freshly extracted files to wherever %appdir% is. Problem here is, shortcut creation, something SFX would otherwise do isn't done. Apparently a, .vbs script can create shortcut without external help. However .vbs will not remember %appdir% because it is independent of cmd.

SO, Plan C is to make the entire process (/for, move and create shortcut) a .vbs script and then place that within SFX archive, which will be called/exe'd after extraction. Can the /For command be used in .vbs?

Edited by shorterxp

Share this post


Link to post
Share on other sites

IS the %appdir% variable a drive letter? Or a folder? I assume the former...

Share this post


Link to post
Share on other sites
Posted (edited)

"appdir" in the example is a path like "C:\Blah\Blah\Folder" but you can read any value in the registry and name the variable the way you like.

I'm not sure exactly what you try to do but maybe you can try to extract sfx files with the command line version of 7zip. I'm not sure if it works, just an idea. :P

https://sevenzip.osdn.jp/chm/cmdline/commands/extract.htm

I don't know exactly what the good options are but there is probably one to set an output directory.

Maybe something like :

7z e archive.zip -oC:\Blah\Folder -y

 

Edited by hotnuma

Share this post


Link to post
Share on other sites

IS there another/for command like appDir that returns Drive letter only?

Share this post


Link to post
Share on other sites
Posted (edited)
for /f "usebackq tokens=2,* skip=2" %%~di in (
    `reg query "HKCU\Software\Shorterxp\app" /v appDir`
) do set filedrive=%%~di

Echo %filedrive%

?

 

Sorry I know not how to code,

Edited by shorterxp

Share this post


Link to post
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

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×