Jump to content

Ideas needed to get rid of cd check


Recommended Posts


  • 2 weeks later...

In a batchfile the variable %~dp0 contains the directory of the batch. So you can call WPI from anywhere and put it in any location.

Was it something like this you thought of kelsenellenelvian?

EDIT: I forgot to mention that this way doesn't work for UNC pahts. So if you want to call from a network share, you have first to connect the share to a drive letter.

Edited by Doc Symbiosis
Link to comment
Share on other sites

I figured out a way using the %~dp0 that Doc Symbiosis also mentioned. Using this method cut down the WPI.cmd code a little, the RunOnceEx.cmd a little bit, and generate.js uses a different file to identify the cd. It will also elimiate the need for the "Launch From CD" option.

BUT.....there is always a but.....

As of this posting, when running it from the harddrive for testing, a couple paths get "confused". I am still working on that and am getting close.

AND.....there is always an and......

you will have to launch WPI.cmd from RunOnceEx.cmd, not from within the winnt.sif file. (That may change as code is modified) But this is the ideal way of doing it anyay.

Stay tuned

Link to comment
Share on other sites

This AutoIT script returns the directory this script is launched from:

$dir=@ScriptDir

$result = $dir
MsgBox(0, "", $result)

Will look into a replacment for the wpi.cmd with a compiled .exe from AutoIT. Attached is the compiled code statement above.

Edited by lawrenca
Link to comment
Share on other sites

Another mod today after a bit of feedback.

-added logic to detect Network Drive (mapped or not) and whether run from CD-ROM

-Fixed problem with not updated environment variable

1. Assumes you are administrator on machine to make the registry entries required by WPI. Will add code for check with message to cancel later.

2. Assumes you have Z as an available drive to Map...you can change this in the AutoIT script if you wish.

3. Still need to add some tweaks for error handling.

4. Need to modify the generate.js file to accomodate the newly imported %wpipath% and also add references to apps in config.js

Removed code from wpi.au3 and attachments for new reply found at:

http://www.msfn.org/board/index.php?s=&sho...ndpost&p=459322

Edited by lawrenca
Link to comment
Share on other sites

Sorry for the add, just wanted to pass on test details:

Used WPI 4.3.8 Full version (Thanks Kel!)

Also wanted to thank Doc Symbiosis for his ideas on mounting network share.

Testing details...All Successful!

Only mounts Network drive if accessed via Network Neighborhood (or equivalent)...not if share is already mapped or if run from local source to include CD/DVD.

Non-Mounted Network Drive (accessed through browsing Network Neighborhood)... wpipath = Z:\Install

Mounted Network Drive (showed as my local M:)... wpipath = M:\Install

Created an .iso image and ran from virtual cd drive... wpipath = Virtual CD Drive (V:\ for my case)

Burned to CD and ran from physical DVD drive... wpipath = R:\Install (R:\ is my recorder drive)

Please pass any feedback as I believe this is worth pursuing.

Will be working on a section to map network drive on first available drive, so user will not have to worry about whether the drive letter is available.

Tony

Edited by lawrenca
Link to comment
Share on other sites

I wrote an alternative WPI.cmd and modified the generate.js in the nearly same way like like lawrenca.

So I added the function:

function FindSWPath()
{
position = "generate.js"
swpath = WshShell.regRead("HKCU\\Software\\WPI\\SWPath");
swpath = swpath +'\\'
return swpath;
}

and in the function replpath(u) I added these two lines

swdir = FindSWPath();
rs = rs.replace(/%swpath%/gi, swdir);

The WPI.cmd uses the %~dp0 variable. If it is called through UNC path, It automatically connects the share to the last free drive letter, because I had some trouble to run installations with UNC path. The Network drive is disconnected within next logout. So here's the batch

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET wpidir=%~dp0

IF %wpidir:~0,2%!==\\! (
REM Get the name of the share, assuming that it is not longer than 50 characters
FOR /F "tokens=1,2* delims=\" %%i IN ('ECHO %~dp0') DO (
SET share=\\%%i\%%j
SET wpipathpart=%%k
)
)

IF %wpidir:~0,2%!==\\! (
REM connect to the last free drive letter and write it to drvlet
FOR /f "usebackq tokens=2* eol=" %%i IN (`net use * %share% /PERSISTENT:NO`) DO (
SET drvlet=%%i
GOTO endfor
)
:endfor
SET wpidir=%drvlet%\%wpipathpart%
)
)

REM Remove the last backslash in the path
SET wpidir=%wpidir:~0,-1%

REM Change to wpipath, so that the reg commands also run on W2k systems, because reg.exe is containd in the WPI-folder
CD /D %wpidir%

REM Write the app-path to the regsitry
REG ADD HKCU\SOFTWARE\WPI /v SWPATH /t REG_EXPAND_SZ /d "%wpidir%\Install" /f >NUL

REM Font installation - the smooth and customizable way.
start "" /wait "%wpidir%\Tools\fonts\fontinstaller.exe"

REM Start WPI and wait for its end
start /wait WPI.hta

REM Remove the key from registry
REG DELETE HKCU\Software\WPI /F >NUL

ENDLOCAL

I know, the double if command isn't so nice, but I couldn't figure out, how I can assign the values to the variables, so that they have their values already in the if construction.

Now in config.js you can use %SWPATH% as variable.

I wrote this for WPI 4.3.5, didn't test it jet with the new version.

By the way, I didn't catch the case, that no drive letter is free, but I don't hink that this is necessary.

generate.js

Wpi.cmd

Edited by Doc Symbiosis
Link to comment
Share on other sites

Doc Symbiosis,

Sorry if I didn't give you the credit in the original post but tried to catch it here:

http://www.msfn.org/board/index.php?s=&sho...ndpost&p=457757

...I used your idea from a ways back but must have had an early project...did not have your final wpi.cmd...Your's tested great on my systems and even found an empty Drive Letter to mount, which is the next step that I was working on with my autoit script (almost done). Thanks! This is just what WPI needs to get rid of the uncertainty of startup directory, cd, and relative path.

Thanks!

Link to comment
Share on other sites

Nothing to be sorry about lawrenca. I'm glad, when I see that people use some of my ideas( makes one a little proud. I think, that's what this forum is for, to share ideas and put together a many puzzles.

I wrote the final version today, cause I'm lying in bed with mononucleosis and so have a lot of time.

Till now, I didn't needed this, cause I'm always running WPI from a fixed network share, but I was ached to write this since kelsenellenelvian first post.

Link to comment
Share on other sites

Script to replace wpi.cmd...

1. Doc's works great above, finished my autoit script for completeness...had to do it.

2. When accessed via network path (non-mapped drive), will mount to first available drive letter starting from z to a (can be modified in autoit script. Placed all registry entries into script as well but obviously could be taken out and continue to use the .reg files provided by Kel...same thing.

Remember to use the %wpipath% for application install (BTW, the wpi.exe should be used to start WPI or you will revert back to the defaults in the original scripts.

Example for config.js entry:

prog[pn]=['ResHacker']
picw[pn]=['128']
pich[pn]=['128']
textl[pn]=['Bottom']
texti[pn]=['1']
cat[pn]=['Application Category']
cmd1[pn]=['"%wpipath%\\Install\\ResHacker\\ResHacker.exe"']
dflt[pn]=['yes']
gcond[pn]=['FileExists(\'%programfiles%\\\')']
configs[pn]=['yes']
pn++

Edited by lawrenca
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...