.bat file to deploy database from server
-
- PlatinumLounger
- Posts: 5425
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: .bat file to deploy database from server
The simple answer is No!
You can reference a local PC file as C:\some-dir\filename.ext - and the same if you happen to be logged on at a server.
You can reference a remote file as \\servername\c$\some-dir\filename.ext
And alternative way is to map a drive to a share on the PC or server
net use x: \\servername\c$ (since C$ is the administrative share - you need to be an administrator to do this!)
and then reference it as
x:\some-dir\filename.ext
When you're running a BATch file via the Task Scheduler, it is best to specify the full path in the form
\\servername\c$\some-dir\filename.ext
You can reference a local PC file as C:\some-dir\filename.ext - and the same if you happen to be logged on at a server.
You can reference a remote file as \\servername\c$\some-dir\filename.ext
And alternative way is to map a drive to a share on the PC or server
net use x: \\servername\c$ (since C$ is the administrative share - you need to be an administrator to do this!)
and then reference it as
x:\some-dir\filename.ext
When you're running a BATch file via the Task Scheduler, it is best to specify the full path in the form
\\servername\c$\some-dir\filename.ext
John Gray
If you are having problems with solitude, you are not alone.
If you are having problems with solitude, you are not alone.
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: .bat file to deploy database from server
Oh alright, I thought C$ indicated the C: drive
So what's the difference between referencing
\\%pcname%\c$\RSM\Database
and referencing
C:\RSM\Database
?
And isn't pcname the name you can get by right-clicking the My Computer icon on the pc desktop and selecting the Computer Name tab?
Also, if FindStr is supposed to take parameters 1 and 2 from where they have been supplied in the table at the beginning of the file, why isn't the syntax
set forcmds=findstr /1/2 "::##" %~f0
?
So what's the difference between referencing
\\%pcname%\c$\RSM\Database
and referencing
C:\RSM\Database
?
And isn't pcname the name you can get by right-clicking the My Computer icon on the pc desktop and selecting the Computer Name tab?
Also, if FindStr is supposed to take parameters 1 and 2 from where they have been supplied in the table at the beginning of the file, why isn't the syntax
set forcmds=findstr /1/2 "::##" %~f0
?
-
- PlatinumLounger
- Posts: 5425
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: .bat file to deploy database from server
It does, in practice. But if you are being pedantic, C: indicates the C drive of the computer you are logged on to, whereas c$ indicates the administrative share for C:. In practice they are identical - provided you are talking about the machine at which you are logged on.grovelli wrote:Oh alright, I thought C$ indicated the C: drive
If you are logged onto the computer, the answer is "no difference", but if you are running on the server or another PC, the first form enables you to access that file on another PC, from the server or a different PC.grovelli wrote:So what's the difference between referencing
\\%pcname%\c$\RSM\Database
and referencing
C:\RSM\Database
?
And isn't pcname the name you can get by right-clicking the My Computer icon on the pc desktop and selecting the Computer Name tab?
The content of the environment variable %pcname% is assigned by the BATch file.
You may be thinking of the built-in variable %computername% which contains the computer name of the computer on which you are running. (To find lots more predefined environment variables, go into a Command Prompt window and type SET and press Enter)
Mainly because that's not the correct form of parameters for FINDSTR! Do FINDSTR /? in a Command Prompt window, and be baffled by the flexibility of the command...grovelli wrote:Also, if FindStr is supposed to take parameters 1 and 2 from where they have been supplied in the table at the beginning of the file, why isn't the syntax
set forcmds=findstr /1/2 "::##" %~f0
?
Nobody ever said that writing BATch files was easy!
John Gray
If you are having problems with solitude, you are not alone.
If you are having problems with solitude, you are not alone.
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: .bat file to deploy database from server
Thanks John, it ain't easy for sure
:: TABLE of PC names and users for the copy
:: must have "::##" prefix followed by space, PCname, space, username
::## RoadWarrior1 Gladys
::## RoadWarrior2 Mabel
::## RoadWarrior3 Tarquin
What I'm interested in finding out is how do you come by those PCnames?
Yes but it's hard-coded into the batch file:The content of the environment variable %pcname% is assigned by the BATch file.
:: TABLE of PC names and users for the copy
:: must have "::##" prefix followed by space, PCname, space, username
::## RoadWarrior1 Gladys
::## RoadWarrior2 Mabel
::## RoadWarrior3 Tarquin
What I'm interested in finding out is how do you come by those PCnames?
-
- 4StarLounger
- Posts: 482
- Joined: 24 Jan 2010, 15:02
- Location: Colorado, USA
Re: .bat file to deploy database from server
I'm a bit late to the party on this discussion, but the subject has come up from time to time in the past. You might find this front end on c drive (Access 2000) old thread over at WindowsSecrets of interest. The approach that most of people settle on is a batch file on the workstation where the front-end resides that copies down a new version each time the PC is booted. The solution we use (deployed on over 1000 workstations in various countries) is to use a small VB app that is used to start a database, and checks to see if the database (or any components such as the user security workgroup file, add-ins, or ActiveX controls) have been updated, and if so downloads the latest version from the deployment server. And it does make a world of difference in terms of the effort of maintaining a database which changes over time.
Wendell
You can't see the view if you don't climb the mountain!
You can't see the view if you don't climb the mountain!
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: .bat file to deploy database from server
Hi Wendell,
is your app available for us mere mortals?
I'm still interested in what John has to say here because batch files can be useful in situations other than updating frontends and also whether someone can tell me what PowerShell might offer in batch files'place.
is your app available for us mere mortals?
I'm still interested in what John has to say here because batch files can be useful in situations other than updating frontends and also whether someone can tell me what PowerShell might offer in batch files'place.
-
- PlatinumLounger
- Posts: 5425
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: .bat file to deploy database from server
Ah! The user supplies them, out of their knowledge of their domain, and hard-codes them into that table.grovelli wrote:Yes but it's hard-coded into the batch file:The content of the environment variable %pcname% is assigned by the BATch file.
:: TABLE of PC names and users for the copy
:: must have "::##" prefix followed by space, PCname, space, username
::## RoadWarrior1 Gladys
::## RoadWarrior2 Mabel
::## RoadWarrior3 Tarquin
What I'm interested in finding out is how do you come by those PCnames?
Because I use a list of PC names and other Stuff in many BATch files, I use a separate file as follows, which I read into every BATch file which requires it.
My PCs are all called PCnn, and the file looks like:
Code: Select all
;PC MAC address Usual User Location Manufacturer & Model
;one (one 'word') (one word) (two words) (two or three words)
;--- ------------ -------------- -------------- --------------------
PC06 008087FE02B4 spare back office Dell Dimension 4100
PC13 ... etc
John Gray
If you are having problems with solitude, you are not alone.
If you are having problems with solitude, you are not alone.
-
- 4StarLounger
- Posts: 482
- Joined: 24 Jan 2010, 15:02
- Location: Colorado, USA
Re: .bat file to deploy database from server
I am not sure whether it is still available - my ex-partner designed it, but is now doing other things. You can read a bit about it here and you could try contacting him from the link on that page. There is a modest licensing fee, but I don't know the details.
Wendell
You can't see the view if you don't climb the mountain!
You can't see the view if you don't climb the mountain!
-
- 5StarLounger
- Posts: 1148
- Joined: 08 Feb 2010, 21:27
Re: .bat file to deploy database from server
I am coming in very late on this.
That way of deploying the latest FE on sign on can be really slow when you get a lot of people signing on at the same time. I proposed that for my latest client and they said that had been tried before and it was too slow for them. They went for the batch file of copying FE's overnight.
That way of deploying the latest FE on sign on can be really slow when you get a lot of people signing on at the same time. I proposed that for my latest client and they said that had been tried before and it was too slow for them. They went for the batch file of copying FE's overnight.
-
- 4StarLounger
- Posts: 482
- Joined: 24 Jan 2010, 15:02
- Location: Colorado, USA
Re: .bat file to deploy database from server
That is very true, and for that reason we do it only when there is an update designated by the administrator. We do allow a user to specify a full download if for some reason their front-end is corrupt, but as long as the master copy hasn't changed, no copy down is done.
Wendell
You can't see the view if you don't climb the mountain!
You can't see the view if you don't climb the mountain!
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: .bat file to deploy database from server
A couple of questions for John:
in your example, you read
call :process %%a %%b
but where is the process routine? (I see a call to the DateTime routine and I see it at the bottom of your example)
set source=\\%server%\rest-of-path\%dbname%
Does the syntax stay the same if rest-of-path has spaces in it?
in your example, you read
call :process %%a %%b
but where is the process routine? (I see a call to the DateTime routine and I see it at the bottom of your example)
set source=\\%server%\rest-of-path\%dbname%
Does the syntax stay the same if rest-of-path has spaces in it?
-
- Administrator
- Posts: 78660
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: .bat file to deploy database from server
The line
call :process %%a %%b
jumps to the :process label a bit further down:
:process a single PCname and username
set pcname=%1
set username=%2
It passes %%a as the first argument %1 and %%b as the second argument %2. The label is a single word (without spaces); the text after it "a single PCname and username" is a comment and will be skipped.
call :process %%a %%b
jumps to the :process label a bit further down:
:process a single PCname and username
set pcname=%1
set username=%2
It passes %%a as the first argument %1 and %%b as the second argument %2. The label is a single word (without spaces); the text after it "a single PCname and username" is a comment and will be skipped.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 5425
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: .bat file to deploy database from server
Excellently stated, Hans.
If rest-of-path has one or more spaces in it, then the whole path must be enclosed in double-quotes.
As in
set source="\\%server%\rest of path\%dbname%"
This is probably the greatest source of problems in a BATch file...
If rest-of-path has one or more spaces in it, then the whole path must be enclosed in double-quotes.
As in
set source="\\%server%\rest of path\%dbname%"
This is probably the greatest source of problems in a BATch file...
John Gray
If you are having problems with solitude, you are not alone.
If you are having problems with solitude, you are not alone.
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: .bat file to deploy database from server
Thanks Hans & John
I see the variable %%a in
for /f "tokens=1-2 delims=:# " %%a in ('%forcmds%') do (
but where's %%b?
I also see a comment that reads
:: look for string V--V in this BATch file
but where's the V--V string?
That explains it.The label is a single word (without spaces); the text after it "a single PCname and username" is a comment and will be skipped.
I see the variable %%a in
for /f "tokens=1-2 delims=:# " %%a in ('%forcmds%') do (
but where's %%b?
I also see a comment that reads
:: look for string V--V in this BATch file
but where's the V--V string?
-
- PlatinumLounger
- Posts: 5425
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: .bat file to deploy database from server
%%b is a positional variable set up by "tokens=1-2", the one after "%%a".grovelli wrote:I see the variable %%a in
for /f "tokens=1-2 delims=:# " %%a in ('%forcmds%') do (
but where's %%b?
if I had used %%f then the second token would be %%g.
And so on
The magic word is "comment"! I was simply using V--V to point down to the four characters on the next line ::##grovelli wrote:I also see a comment that reads
:: look for string V--V in this BATch file
but where's the V--V string?
John Gray
If you are having problems with solitude, you are not alone.
If you are having problems with solitude, you are not alone.
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: .bat file to deploy database from server
What should I put after the equals sign in
set server =
set source = "\\%server%\foldername\%dbname%
when I want to reference a folder on a server disk which is partitioned in two drives O: and U: that have the same address?(see attached jpg)
set server =
set source = "\\%server%\foldername\%dbname%
when I want to reference a folder on a server disk which is partitioned in two drives O: and U: that have the same address?(see attached jpg)
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78660
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: .bat file to deploy database from server
set server=itc980srv01.itc.itcgr.net
obviously. Uffici or common would be (part of) the folder name.
obviously. Uffici or common would be (part of) the folder name.
Last edited by HansV on 02 Feb 2011, 14:58, edited 1 time in total.
Reason: to remove spaces before and after = (thanks to John for pointing out my mistake)
Reason: to remove spaces before and after = (thanks to John for pointing out my mistake)
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 5425
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: .bat file to deploy database from server
Please don't put a blank either side of the = sign in SET commands! Unhappiness can occur (since there is a difference between "something" and " something"...)
John Gray
If you are having problems with solitude, you are not alone.
If you are having problems with solitude, you are not alone.
-
- Administrator
- Posts: 78660
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: .bat file to deploy database from server
Sorry about that (you can see that I'm not a batcher...)
I will correct my previous reply.
Thanks!
I will correct my previous reply.
Thanks!
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 528
- Joined: 26 Jan 2010, 15:14
Re: .bat file to deploy database from server
:-)
Quite a few potholes along the way.
so I guess the correct syntax is:
set server=itc980srv01.itc.itcgr.net
set source="\\%server%\U$\foldername\%dbname% (for a folder on the Common disk)
Quite a few potholes along the way.
so I guess the correct syntax is:
set server=itc980srv01.itc.itcgr.net
set source="\\%server%\U$\foldername\%dbname% (for a folder on the Common disk)