Link to home
Start Free TrialLog in
Avatar of holemania
holemania

asked on

VScript or Bat Script to Register DLL File as Administrator

I need help registering  a dll file as administrator.  I can right click the cmd and then "Run as Administrator".  This would allow me to register, however, my issue is that I need to register this for over 100+ PC.

So I need help to do this as a login script.  Normally this is how I would register the dll file.

This is for 64-bit OS:
C:\Windows\SysWOW64\Regsvr32.exe "\\serverA1\ERP\sscvix.dll"

This is for 32-bit OS:
C:\Windows\System32\Regsvr32.exe "\\serverA1\ERP\sscvix.dll"


So need help with determining which OS is on that PC as well as registering that dll file as administrator.  Any ideas?
Avatar of Chris H
Chris H
Flag of United States of America image

Below I've pasted Oberwald's solution for a VBS that runs batch file as elevated.
http://social.technet.microsoft.com/Forums/eu/ITCG/thread/310e57f9-2367-4293-9f97-53d0e077aacc

Here is a script that forces UAC elevation:
'---------------------------------------
'Elevate this script before invoking it.
'25.2.2011 FNL
'---------------------------------------
bElevate = False
if WScript.Arguments.Count > 0 Then If WScript.Arguments(WScript.Arguments.Count-1) <> "|" then bElevate = True
if bElevate Or WScript.Arguments.Count = 0 Then ElevateUAC
'******************
'Your script goes here
'******************

'-----------------------------------------
'Run this script under elevated privileges
'-----------------------------------------
Sub ElevateUAC
    sParms = " |"
    If WScript.Arguments.Count > 0 Then
            For i = WScript.Arguments.Count-1 To 0 Step -1
            sParms = " " & WScript.Arguments(i) & sParms
        Next
    End If
    Set oShell = CreateObject("Shell.Application")
    oShell.ShellExecute "wscript.exe", WScript.ScriptFullName & sParms, , "runas", 1
    WScript.Quit
End Sub
Have you looked at the RUNAS command in Vista and WIndows 7?  It's probably more suited to what you're looking for.  The only problem is if you used a batch file for this, you'll need to put an admin level password plain text inside it.  This will require you to give your users execute NTFS permissions and remove read NTFS permission.
Untitled.png
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of holemania
holemania

ASKER

Thank you.