Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Urgent: Help deployment script 2

Status
Not open for further replies.

pnutz

Programmer
May 21, 2003
10
US
Hey there,

Does anyone know how to write an deployment script from vb,
What i need to do is, this is in the client server environment

1)when i deploy the installation package from the active directory through the network to all of the network users i would need to check for these two things..

a) read from the registry if the there is an existing software if there is check for the version and compare it to the one that i'm abt to deploy

How do i go abt doing this?
Thanks!
 
Here is a sample for you. You would obviously need to change the reg path and value being evaluated.

Code:
set oShell = Wscript.CreateObject("Wscript.Shell")

'Check if this fix has run and if so exit
ThisFixInstalled = oShell.RegRead("HKLM\SOFTWARE\MyFixes\patches\NTFSdDriveFix")
If ThisFixInstalled = 1 Then
	WScript.Quit
Else
        Code that you want to execute
End If


I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Even more simple. Most software packages have a specific file they copy or version. What we do is check to see if a file exists. If not, it runs the program.

if not exist "C:\Temp\path.txt" \\server\program.exe
 
pnutz, what have you so far ?
This is not a helpdesk. We are not here to do your job for you. Show us what you have tried already and we can try to help but we are not here to do your work for you.


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
hey there,

Thanks mark for the sample code, i'm new at scripting language...

Anyways i do i display using WScript.echo form Reg_Binary

So far i have tried out your code..

Option Explicit

Dim oShell, Installed


set oShell = Wscript.CreateObject("Wscript.Shell")

'Check if this fix has run and if so exit

Installed = oShell.RegRead("HKEY_LOCAL_MACHINE\software\SS\Version")

If Installed = 1 Then
WScript.Quit
Else

WScript.echo Installed

End If

Thanks!
 
I am not sure I understand your question, but if you are asking how can you view what is set in that reg key then you could do this:

Code:
Installed = oShell.RegRead("HKEY_LOCAL_MACHINE\software\SS\Version")
Wscript.Echo Installed

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
well i have tried that but i would get a type mismatched error i guess it because i have been reading from a REG_BINARY how do i read the values from REG_BINARY


Thanks!

 
You are getting the rror because the regread on the binary produces an array.

Here is an example:

Code:
set oShell = Wscript.CreateObject("Wscript.Shell")
Installed = oShell.RegRead("HKEY_LOCAL_MACHINE\software\Microsoft\Windows\CurrentVersion\Detect\Version")

For Each entry In Installed
Wscript.Echo entry
Next

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Thanks! It works!

is there a way that i can read only the 20 bytes of the registry because that is the version number
 
Is it a specific element of the array?

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
yeah it is the first 20 bytes would result in the version number the value data i mean...

how do i capture that...
 
Pnutz,

Maybe I'm just being dense here. If you echo the entire array...what do you get?

Each line is an element in the array. Is the value you are looking for one of those elements?

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hello pnutz,

Apart from detail of arrangement order, it would be this.
Code:
on error resume next
s=""
for i=0 to Installed(19)
    s=s & chr(Installed(i))
next
if err.number<>0 then s="Value less then 20 bytes long."
err.clear
on error goto 0
wscript.echo s
regards - tsuji
 
Hey there thanks for you suggestion:

What i'm trying to get from my registry is the 0.72R. Below is how my typical registry entry looks like..


Value data:
0000 30 2E 37 36 20 52 00 00 0.72R..

currently with the function below i'n getting the result of 48..

for i= 0 to Installed(19)

test = Installed(i)

next

does anyone know how to read the registry from the above...
Thanks!
 
pnutz,

>Value data:
>0000 30 2E 37 36 20 52 00 00 0.72R..

[1] My guess is you're giving us, due to misunderstanding, wrong number of bytes to inspect. 2E constitutes 1 byte. Hence what you've in mind is 10 bytes.
[2] Depending on the exact spec of "irrelevant bytes", a quick and dirty way to read it is:
Code:
on error resume next
s=""
for i=0 to Installed(9)
    if Installed(i)<>0 then s=s & chr(Installed(i))
next
if err.number<>0 then s="Value less then 10 bytes long."
err.clear
on error goto 0
wscript.echo s
[3] If the spec is actually the offset 2nd to 7th, it is this.
Code:
for i=2 to 7
    s=s & chr(Installed(i))
next
- tsuji

[/code]
- tsuji
 
Thanks it works!

Currently the code goes as such...

Option Explicit

Dim oShell, Installed, entry, s, i


set oShell = Wscript.CreateObject("Wscript.Shell")


Installed = oShell.RegRead("HKEY_LOCAL_MACHINE\software\SS2\Version")


on error resume next

s=""

for i = 0 to 7
s = s & chr(Installed(i))
next

if err.number<>0 then s="Value less then 10 bytes long."

err.clear

on error goto 0

wscript.echo s

This is one helpful post for reading REG_BINARY

One last question how do i check if the software is installed and if its not installed run the application setup...

Can i automatically configure a vbs to run an application setup...

Thanks once again!
 
pnutz,

[1] I see your script retaining i=0 to 7. But, if offsets 0 & 1 are &H00, that would have very detrimental effect on the string s extracted. Hence, you _must_ use the condition Installed(i)<>0 checked or use i-2 to 7.
[2] To check whether the software is installed or not is dependent on how version is created. If non-existence of it implies "not installed" then you can error trap the .regread.

Combining [1] and [2], here is a revision see if it does any good.
Code:
Option Explicit
Dim oShell, Installed, entry, s, i, bInstalled
set oShell = Wscript.CreateObject("Wscript.Shell")
bInstalled = true : s = ""
on error resume next
Installed = oShell.RegRead("HKEY_LOCAL_MACHINE\software\SS2\Version")
if err.number<>0 then bInstalled = false : err.clear
if bInstalled then
    for i = 2 to 7
        if Installed(i)<> 0 then s = s & chr(Installed(i))
    next
    wscript.echo "The software is installed with version being " & s
    if err.number<>0 then
        s="Value is less then 7 bytes long which should not be." & _
            vbcrlf & "Re-install the software is recommended."
        bInstalled = false
        err.clear
    end if
    if strcomp(s, "0.27 R",1)<>0 then
        bInstalled = false
        wscript.echo "Wrong version. Need to re-install."
    end if
end if
on error goto 0
if not bInstalled then
    'script to install the software here
end if
- tsuji
 
hey tsuji,

Thanks for you valueble help..finally got the basic of writting a basic script for deployment purposes. Been A GREAT help :)

for the script to install the software do i just specify the path of where the setup file is located?
 
pnutz,

If something startmenu|run can handle, you can trigger the same with wshshell.run. Something like this
Code:
'continuing with the same script at the place indicated
if not bInstalled then
    oShell.run setup.exe
end if
set oShell=nothing   'just cleanup if so desired
The setup.exe (with path if necessary) will run its course, and the script will end itself.

- tsuji
 
Thanks for stepping in tsuji, I was really thrown by the 20 byte request.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top