Jump to content
The Uniform Server Community

[Solved] Running from D:


fredt
 Share

Recommended Posts

I think this wasn't solved so far... If I'm wrong, plz erase this post !

 

My Uniform server directory is located on D:\Progz\Uni1 - so Server_Start.bat will try to launch from C: when I double-click it... and won't work. So I had to open a prompt,

D:

cd progz\uni1

server_start

 

I found a nice solution on jsifaq, http://www.jsifaq.com/SUBU/tip10400/rh10486.htm and http://www.jsifaq.com/SUBA/tip0400/rh0494.htm.

 

I now have:

%~dp0diskw\home\admin\program\pskill.exe Apache.exe

IF NOT ERRORLEVEL 1 goto started

set Disk=%1

IF "%Disk%"=="" set Disk=w

rem create the disk

subst %Disk%: "%~dp0diskw"

IF ERRORLEVEL 1 goto hint

set apachepath=\usr\local\apache2\

set apacheit=%Disk%:%apachepath%bin\Apache.exe -f %apachepath%conf\httpd.conf -d %apachepath%.

set programit=%Disk%:\home\admin\program\

set closeit=%programit%close.bat %Disk%

 

And it works PERFECT !

 

.... did I mention I LOVE UNIFORM SERVER ?

 

FredT

Link to comment
Share on other sites

  • 1 year later...

Thanks

Hi,

 

I am new to uniserver after using xampp and easyphp. I was attracted to use uniserver since it could be used for production purposes as well.

 

I am using uniserver under production and have the following query.

 

1. I am running win2003 under hp proliant server and intend to use joomla for cms. This is an intranet solution and the application will be used by the internal users only. I am planning to run uniserver under another drive (say e: since c: has very less space-80gb and do not want to disturb c as well) and would like to know your suggestions and advise.

 

2. After installing the uniserver at e: the server was running and i took care of all the unsecure elements and then stopped the server. After starting again it gave me a warning something like it is unable to decipher drive or not in the format like a:b:c:d and pointed me to config.inc.php line 16. But the server is running and i am able to view the joomla site. What should i do to resolve this warning/error?

 

3. Should i change the bat file as suggested in this topic (like %¬DPO)?

 

Thank you for your time.

 

Regards

Link to comment
Share on other sites

This may be of interest:

 

Uniform Server will run on any drive from any folder, simply double-click on the relevant batch file. Well not in “fredt” case, his solution is neat and uses a very powerful batch command %~ I use this in conjunction with two other commands, before I expand on this do you really need to use it!

 

Working directory: When you open a command prompt and navigate to the Uniform Server folder for example D: and then cd progz\uni1 this is referred to as your Current working Directory. Any relative paths in the start batch file are referenced to this (CD current directory or current folder they are the same thing). Type in “server_start” the operating system looks in the Current Directory to find the file and runs it.

 

Now back to the explorer window, when you double click on the file server_start.bat it opens a command prompt and should automatically set the current directory to that where the file is located. In “fredt” situation the OS thinks the current directory is in C clearly a problem.

 

Test batch file: To check that you have this problem create a test batch file “test.bat” copy the following lines and save it in the folder where the server start and stop files are located:

 

echo off
echo ==================
echo Current path  = %CD%
echo Real bat path = %~dp0
echo ==================
pause

 

It prints out the current path (Current Directory) using %CD% and the path where the batch file is located using %~dp0. On a local machine the only difference in paths will be a back slash at the end for Real bat path. If these are different then there is a problem.

 

If the paths are the same (apart from the back slash) you do not have a problem. Just for fun you can simulate the problem. Open a command prompt this normally defaults to c, type the full path including the file name for the test file e.g. “G:\UniServer3\Uniform Server\test.bat” Note because of the space in the file name you do need to wrap it in quotes. The paths will be different, now that is not fun it’s serious.

 

You can use %~dp0 to change the current working directory, but if you want to run this say remotely across file servers then what happens if you think you are still in the old current directory. These is getting a little bit heavy, not intended I do ramble on but think save old location, create a new working directory corresponding to batch file location when finished restore to old working directory.

 

Push and pop, some real old micro terminology; push, save where you came from and pop, zap back to where you came from, add this to where you think you are and you have a real solution.

 

The code is boarding on a real no brainer:

pushd %~dp0

Your Batch File Code

popd

 

Well “pushd” pushes the Current Directory onto a memory stack (Where you came from).

 

“%~dp0” This forces the CD to the current location of the batch file you are running. It includes the full path not just the drive letter (if its remote that’s included).

“popd” Restores the previously pushed directory.

 

If you missed the point, two lines of code that can get you out of deep smelly stuff even across file servers.

 

Its not a panacea, however you do know that the code you are running in your batch file will be relative to its real location, further you know where you came from hence can return to that known point.

 

Start every batch file with: pushd %~dp0

End it with: popd

 

OK you get the idea; it’s very powerful but not backwards compatible with the dark ages of steam.

 

Now we are talking real engineers, they could bore a hole, for a piston that would accommodate its expansion under extreme temperatures and still work to perfection.

 

I do apologise for the long post.

 

All the best

Ric

:D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...