Jump to content

Tip for running WPI from network-share...


Recommended Posts

If you want to run WPI from a network-share I found a simple solution.

pre-condition is that you don't use absolute path-names in your commands - you have to use variables like %CDROM% or %WPIPATH%.

If you use such variables you can use the following Script to run WPI from a network-share.

@ECHO OFF

::This should be the path to WPI on the share
SET SHARE=\\SERVER\SHARE

::mount share to a free drive and change directory to it. After Script it finished the drive will be unmounted
PUSHD "%SHARE%"
START /wait WPI.hta
POPD

That's all

Greetings

Al

Link to comment
Share on other sites


WOAH! Never knew this command existed!! I could have used this a long time ago! Just for completeness, here is what PUSHD does:

PUSHD [path | ..]

path Specifies the directory to make the current directory.

If Command Extensions are enabled the PUSHD command accepts
network paths in addition to the normal drive letter and path.
If a network path is specified, PUSHD will create a temporary
drive letter that points to that specified network resource and
then change the current drive and directory, using the newly
defined drive letter. Temporary drive letters are allocated from
Z: on down, using the first unused drive letter found.

Awesome tip! Thanks

Edited by JuMz
Link to comment
Share on other sites

Thanks for your reply - I forgot that PUSHD needs enabled command extensions because they are enabled by default at my system.

With this script the extension will be enabled for the execution.

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

SET SHARE=\\SERVER\SHARE

TITLE Running WPI from "!SHARE!"...

PUSHD "!SHARE!"
ECHO.Mounting "!SHARE!" to "!CD!"...

PUSHD WPI
ECHO.Starting WPI...
START /wait wpi.hta
POPD

ECHO.Unmounting network-drive...
POPD

Greetings

Al

Link to comment
Share on other sites

I forgot that PUSHD needs enabled command extensions because they are enabled by default at my system.

[...]

SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

[...]

* Very good trick indeed.

- Please note that extensions are enabled by default on ALL winXP systems.

So if you didn't change it, no worry.

Now, you're true, we can just keep 'SETLOCAL ENABLEEXTENSIONS' at the top of the script to be sure.

- On the other hand, I don't recommand enabling delayed expension (off by default) if you don't require it.

In some situations this can bring more mess than solve issues. You script doesn't require it.

Also note that even with ENABLEDELAYEDEXPANSION, you can still use '%' as a variable marker: only those marked with '!' have their expansion delayed, though.

* There may be another issue when using WPI from a network share if WPI itself is on the share:

you need to lower the security in order to run unsigned programs (WPI itself) without the "Open file" security Warning.

SET "KEYD=HKCU\Software\Microsoft\Internet Explorer\Download"
SET "KEYP=HKCU\Software\Microsoft\Windows\CurrentVersion\Policies"
REG add "%KEYD%" /v "CheckExeSignatures" /d "no" /f
REG add "%KEYD%" /v "RunInvalidSignatures" /t "REG_DWORD" /d 1 /f
REG add "%KEYP%\Attachments" /v "SaveZoneInformation" /t "REG_DWORD" /d 1 /f
REG add "%KEYP%\Associations" /v "LowRiskFileTypes" /d ".cmd;.exe;.hta;" /f

- From my experience, if you run WPI at RunOnceEx, you need to run the above script from T12: running it just before WPI @RunOnceEx fails.

- It may be a good idea to reverse to higher security for HKCU, HKU/.DEFAULT and the Default User's hive once the programs are installed. For example in cleanup.cmd from RunOnceEx.

- In the "LowRiskFileTypes", put whatever extension(s) you use from the share, outside of WPI: WPI deals with the inside ones.

* Also, you CAN use WPI from a network share with absolute paths:

you just have to map the network drive to that path:
NET USE Z: \\DJE\XPCD\install

and then in WPI, have your commands like:

Z:\myprog.exe -switch

But it may be less convenient than your method. Which I'm gonna investigate further right now.
:thumbup

Link to comment
Share on other sites

  • 3 months later...

You can enter authentication using the net use command. Net use will map the share to a specified drive with the authentication you want. Here's the syntax.

The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[username@dotted domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]

//An example
NET USE z: \\MyNAS\public MyPassword /USER:MyNAS\Admin

Edited by zorphnog
Link to comment
Share on other sites

  • 1 month later...

Just a modified version of my script:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

SET SHARE=
IF NOT "%~1"=="" SET SHARE=%~1

IF "%SHARE%"=="" (
TITLE Running local WPI...
CALL :RUN
) ELSE (
TITLE Running WPI from "!SHARE!"...
PUSHD "!SHARE!"
ECHO.Mounting "!SHARE!" to "!CD!"...
CALL :RUN
ECHO.Unmounting network-drive...
POPD
)

GOTO :END

:RUN
PUSHD WPI
ECHO.Starting WPI...
START /wait wpi.hta
POPD
GOTO :END

:END

Put this script (RunWPI.cmd) to WPI-parent-directory (in WPI it's called %ROOT%).

If you start the script without arguments your local WPI will be started - but if you start the script with an share (e.g. \\SERVER\SHARE) as argument, WPI will be started from SHARE (\\SERVER\SHARE must contains WPI).

Best regards

Al

Link to comment
Share on other sites

  • 3 weeks later...

I would like use WPI for batch software install in network share, here is my network like:

\\Server\Share\PerfectDISK

...................... \Nero

...................... \RegFiles

...................... \WPI\Audio

...................... \WPI\Common

...................... \....

...................... \WPI\runWPI.cmd

...................... \WPI\WPI.hta

and i copy Al script, and set "share=\\Server\share" in runWPI.cmd file (in network WPI root folder- No cd-rom), when i startup runWPI.cmd , the network map worked OK, but no installration action at all. must be something wrong in cmd1 map path

:wacko: Would you please someone can help me :hello:

<< sample config.js >>

....

....

pn=1;

prog[pn]=['PerfectDisk'];

desc[pn]=[''];

uid[pn]=['PERFECTDISKVER80'];

dflt[pn]=['yes'];

cat[pn]=['Applications'];

forc[pn]=['no'];

cmd1[pn]=['"Z:\\PerfectDisk\\setup.exe"'];

pn++;

...

...

Edited by ty628659
Link to comment
Share on other sites

At first I would suggest to use %ROOT% instead of Z:

pn=1;
prog[pn]=['PerfectDisk'];
desc[pn]=[''];
uid[pn]=['PERFECTDISKVER80'];
dflt[pn]=['yes'];
cat[pn]=['Applications'];
forc[pn]=['no'];
cmd1[pn]=['"%ROOT%\\PerfectDisk\\setup.exe"'];
pn++;

because %ROOT% is the upper level to the WPI-Dir (WPI\..\) - so you can be sure the everytime the correct path to your apps is used.

An if an app is not correctly installed have a look WPI_Log.txt

Al

Link to comment
Share on other sites

  • 5 months later...

Has there been any changes in the new WPI on how to run it from a network? i.e. I map a drive letter , say 'Z' to the root of my installation source which contains the WPI folder:

(sharename)Z:

\WPI

\I386

\Applications

...etc

My config.js has entries like : "%CDROM%\Applications\appname\appinstaller.exe"

I want to make ONE version of WPI that can be ported to either network installs or CD/DVD/USBKEY based installs....

How should I proceed or what should I change....

mapping the drive to the share above does NOT seem to work for me...WPI fails to install...

Edited by JuMz
Link to comment
Share on other sites

At first I would suggest to change %CDROM% to %ROOT% because %ROOT% is the upper-level of the WPI-folder.

With this setting you can start WPI from every place.

If you want to start WPI from a network-share you can use this batch-file

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

SET SHARE=
IF NOT "%~1"=="" SET SHARE=%~1

IF "%SHARE%"=="" (
TITLE Running local WPI...
PUSHD "%~dp0"
CALL :RUN
POPD
) ELSE (
TITLE Running WPI from "!SHARE!"...
PUSHD "!SHARE!"
ECHO.Mounting "!SHARE!" to "!CD!"...
CALL :RUN
ECHO.Unmounting network-drive...
POPD
)

GOTO :END

:RUN
PUSHD WPI
ECHO.Starting WPI...
START /wait "%WINDIR%\mshta.exe" wpi.hta
POPD
GOTO :END

:END

Put this file in your share-folder (where wpi, i386, applications, ... exist).

If you start this batch file locally it will start you wpi.

if you start it from the share it should start wpi from the share - if there are problems copy the file to the remote-pc and change the line SET SHARE= to SET SHARE=\\YOUR_SERVER\YOUR_WPI_SHARE and it should work.

Al

Edited by AlBundy33
Link to comment
Share on other sites

Thank you! All I needed to do was change %CDROM% to %Root% and it now works via network and CDROM. Now to test USB...

BTW, can PUSHD take username / password for network share?

Edited by JuMz
Link to comment
Share on other sites

As far as I know: no. :-(

PUSHD is like CD but it can handle UNC-paths - and as far as I know there is no possibility to add username and password to an UNC-path.

"net use" can take username and password but with this command you have to determine a free drive-letter by yourself.

Al

Link to comment
Share on other sites

ahh I see. I know net use * will auto assign the drive letter...the question is....can I somehow obtain which drive letter it chooses...

USB key works! Yes!

Edited by JuMz
Link to comment
Share on other sites

You can do it so:

FOR /F "tokens=2" %%D IN ('net use * "!SHARE!"^|FINDSTR /I Laufwerk') DO SET DRIVELETTER=%%D

This is my output of net use * "!SHARE!"

Laufwerk T: ist jetzt mit \\home\system verbunden.

Der Befehl wurde erfolgreich ausgeführt.

So you have to change the "Laufwerk" in my first command to the first letter before the drive-letter - this word is used to find only the first line of the output.

token=2 means to take the second word of the output.

Al

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