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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Software Deployment Through Logon Script 3

Status
Not open for further replies.

roblay22

IS-IT--Management
Aug 11, 2004
28
0
0
GB
Hi All, I'm a network admin but I lack scripting knowledge. I need to deploy some software using a logon script as it doesn't have an msi file I can deploy using group policy. i need a script to check for the existence of the software already, either by checking for a file or a registry key, then if its not there install the software using admin rights, both username and password, for the install. All of which I need to put in a logon script. I don't think this should be to difficult, but I'm not sure, any help would be fantastic.
Cheers
 
Hi roblay,

This is not always as easy at it sounds.
You can try this script:

Set fso = CreateObject("Scripting.FilesystemObject")
Set Shell = WScript.CreateObject("WScript.Shell")
If not Fso.FolderExists ("C:\Program Files\Application") Then
Shell.Run(("%comspec% /C c:\installationsource\setup.exe"),1,1)
End If

Add it as a Startup script, not login Script.

But I think you will get problems, because all system variables and services is not started yet.
For example is not the Application Data path specified.

One other (recommended) way is to use Wise or InstallSheld to create a MSI package for the program.
 
Hi wibbe, Thanks for the quick response, not sure if i'm missing the point but if I ran it as a logon script would I avoid the issue of system services etc not having started?? Also, could the installation source be a network drive- does the line including the installation source support a UNC?? I agree the better way would be to create an MSIpackage, will look into that but in the mean time I'd appreciate any help getting a script sorted.
Cheers
 
Agree with wibbe, because if you run it as a startup script, it will use local system as context. If you use logon script the user must be local administrator, because it will use the context of the locally logged on user...

Don't think that will be any issue, if you're afraid that some services hasn't started you can use a wscript.sleep, but I doubt that it will be nessesary.
 
if you cant be sure about admin rights then you are in a whole lot of trouble.
you dont want to be having local admin or global admin account password in a vbscript file or an exe file or anywhere really where a user can hack it, find out the user name and password and then access to everyones machines.

that is why you have products like SMS and tivoli etc out there.

personally if this is what you need to do on a regular basis and you dont have a deployment tool like the above mentioned then i would create your own service, much like sms and tivoli in some respect. have the service install/run under an admin account and rely on windows built in security. the service can then sit and wait for a flag of file to be dropped with info on what you want to start.

i know this isnt an answer to your question.

otherwise you are left with some dodgy hiding of a runas command of something like that, or as already suggested a startup script with a funky wait cycle
 
Hi Thanks for the responses, I agree with the point on security, hadn't spotted the flaw in my thinking.

I have a problem with part of my script which is testing for the existence of a registry key, the reason for this is because I can't guarantee that the software will always be installed in the same location. My code is below
/Code
Set SH = CreateObject("WScript.Shell")
Key = SH.Regread("HKLM\Software\Adobe\Acrobat Reader\")
If Key = True Then
WScript.Quit
Else
SH.Run "c:\AdobeReader7.exe",1
WScript.Sleep 3000
SH.SendKeys "{ENTER}"
End If
WScript.Quit
/Code end

But I get an error msg saying

Unable to open the registy key "HKLM\Software\Adobe\Acrobat Reader\" for reading
Code: 80070002

Can anyone help please (note - I'm only using acrobat reader to test the script)
 
You might want to take a look at IExpress to create your own MSI package. It is already installed on your system. click Start Run and type IEXPRESS then click OK.

I hope you find this post helpful.

Regards,

Mark
 
This looks interesting is there a help file?

Only the good die young, me I'm here forever :)
 
roblay22,

First the existence of a reg key or not is not reflected in the left-hand-side return (your variable key) being true or false. But on the os shows or not a runtime error. Second, even a runtime error is resulted, for nt-series, you have to make sure it is not the error purporting "Unable to open registy key" exactly what you saw. (It also means that your testing m/c does have acrobat installed.)

Some detail is discussed in a previos thread.
where you'll find a script block testing the existence of a key.

The basic of doing thing is like this. (It can easily be made into a function.)
Code:
dim bExists
ssig="Unable to open registry key"
skey="HKLM\Software\Adobe\Acrobat Reader\"

set wshshell= createobject("wscript.shell")
on error resume next
sdefault=wshshell.regread(skey)
if err.number<>0 then
    if right(strKey,1)="\" then    'skey is a registry key
        if instr(1,err.description,ssig,1)<>0 then
            bExists=true
        else
            bExists=false
        end if
    else    'skey is a registry valuename
        bExists=false
    end if
    err.clear
else
    bExists=true
end if
on error goto 0
if bExists=vbFalse then
    wscript.echo skey & " does not exist."
else
    wscript.echo skey & " exists."
end if
Just change the echo part to take further action like installation if the key does not exist.

regards - tsuji
 
I have not found an IExpress help file, but a google search on it does turn up quite a few sites with info on it.

I hope you find this post helpful.

Regards,

Mark
 
Thanks for the help guys, I now have my script up and running installing the software if necessary.
Cheers
 
Hi Roblay,

Can I take a view on how you work it our for software deployment, im a newbie on the scrip, what syntax should i put on the echo to install my software?

Thanks
Solec
 
Hi Solec,
Below is the Full script that I've used, it works well, I've put comments in to let you know whats happening.

dim bExists
ssig="Unable to open registry key"

set wshShell= Wscript.CreateObject("WScript.Shell") 'CHECK REGISTRY KEY FOR EXISTENCE OF APP
strKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Zultys\MXIE\" 'EDIT REGISTRY KEY ACCORDINGLY
on error resume next
present = WshShell.RegRead(strKey)
if err.number<>0 then
if right(strKey,1)="\" then 'strKey is a registry key
if instr(1,err.description,ssig,1)<>0 then
bExists=true
else
bExists=false
end if
else 'strKey is a registry valuename
bExists=false
end if
err.clear
else
bExists=true
end if
on error goto 0
if bExists=vbFalse then 'APP INSTALL 'INSTALL APP IF RESULT OF REGISTRY CHECK IS FALSE
wshshell.Run "\\Wemail1\shared\Client_Setup.exe" 'EDIT INSTALL PACKAGE LOCATION ACCORDINGLY
Wscript.sleep 40000
wshshell.SendKeys " "
end if


this install is nice and simple and only needs one keypress, the lines at the bottom specify a waiting period to allow the machine to decompress the package etc then is sends a space bar press to continue the installation, you can add additional pauses and keypresses as needed by your install package.
Hope this helps.
 
Just a quick tip for ya that I found useful...

when you do a wshshell.run instead of having the machine sleep, do a wait on return.

I used to have machines running installs & some were quick whilst others chugged away.. I found that sleeping was causing issues for some machines cos they were too slow & even sleeping for ages was a pain.

at the top of your script put in
bWaitOnReturn = True

then change your line
wshshell.Run "\\Wemail1\shared\Client_Setup.exe" 'EDIT INSTALL PACKAGE LOCATION ACCORDINGLY

to

wshshell.Run "\\Wemail1\shared\Client_Setup.exe",1,bWaitOnReturn
you can get rid of your sleep then & the space will be pressed when the shell command has finished..

the ,1, is visible, if you don't want it visible change it to ,0,

I find it much tidier !
Regards
Alex


Computer games don't affect kids, I mean if they affected us as kids then we'd all be running around in darkened rooms listening to wierd music & munching pills !
 
Roblay ,

thanks so much it worked!!! :).

Woolsdog,


I havent tried your suggestion but i know that it will work too., thanks so much all for the input.


Regards

Solec
 
Hello All, I need your expertise again, i'm having error when im deploying my new viruscan08,

The error is:

Error: Invalid root in registry key " HKEY_LOCAL_MACHINE\Network Associates\Talkback\"
Code: 80070002
Source: WshShell.RegRead.
What does this mean? Please help.Thanks!
 
Sorry my copy and paste won't work (added SOFTWARE)

Error: Invalid root in registry key " HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\Talkback\"
Code: 80070002
Source: WshShell.RegRead.
What does this mean? Please help.Thanks!

Still won't work
 
>Error: Invalid root in registry key " HKEY_LOCAL_MACHINE\Network Associates\Talkback\"
It means the key does not exist. In this case, it may be Talkback under Network Associates, or the key Network Associates under HKLM.
 
Thanks Tsuji, Thats the Reg key (TalkBAck) in Vir 8, if it exist it will not install if not it will installl just like the above script that roblay posted, in other forums they say it has somethin to do with Regread?
 
solec,
Are "they" right then? Just curious. (I can think of highly worked-on cases where it may give out wrong signal. But we are talking about normal way of treating registry.)
- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top