Solved

VScript or Bat Script to Register DLL File as Administrator

Posted on 2013-02-05
4
497 Views
Last Modified: 2013-02-28
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?
0
Comment
Question by:holemania
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Expert Comment

by:choward16980
ID: 38856024
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
0
 
LVL 16

Expert Comment

by:choward16980
ID: 38856038
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
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 38857269
Hi, on your \\serverA1\ERP\sscvix.dll file, grant Domain Computers read rights, then try running this script as a "Startup script" instead of a login script.

Regards,

Rob.

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

strArchitecture = GetOSArchitecture(objWMIService)

Set objShell = CreateObject("WScript.Shell")

If strArchitecture = 32 Then
	objShell.Run "C:\Windows\System32\Regsvr32.exe /s ""\\serverA1\ERP\sscvix.dll""", 0, True
Else
	objShell.Run "C:\Windows\SysWOW64\Regsvr32.exe /s ""\\serverA1\ERP\sscvix.dll""", 0, True
End If

Function GetOSArchitecture(objRemote)
	' TITLE: GetOSArchitecture
	' DESCRIPTION: This function will use a WMI query to determine the system
	'	architecture of the target computer
	' INPUT:
	'	objRemote must be an object that is bound to the WMI service on the target machine
	'	Make a call such as Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	'	and pass objWMI to this function
	' OUTPUT:
	'	A string value being 32 or 64
	Set colOS = objRemote.ExecQuery("SELECT OSArchitecture FROM Win32_OperatingSystem",, 48) 
    For Each objOS In colOS 
        intAddressWidth = objOS.OSArchitecture
    Next
    If intAddressWidth = "32-bit" Then intAddressWidth = 32
    If intAddressWidth = "64-bit" Then intAddressWidth = 64
    GetOSArchitecture = intAddressWidth
End Function

Open in new window

0
 

Author Closing Comment

by:holemania
ID: 38938579
Thank you.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question