Question

Unregister, copy, then register an OCX file through login script as an administrator (500) points

Asked by: RAMCIT

Hello Experts,
I need to create a login script that will unregister an ocx file, then copy down a new one, then register said new one. My problem is not the commands in the script but how to run it as a user with sufficient rights. Some users that are made to execute the script below are nowhere near local admins, they are very restricted users. Basically what I need is a "run as" command within the script.

This is what I have so far


regsvr32 -u "%systemroot%\Downloaded Program Files\phone.ocx"

copy "\\10.168.0.62\activex\phone.ocx" "%systemroot%\Downloaded Program Files" /y

regsvr32 "%systemroot%\Downloaded Program Files\phone.ocx"

Thanks!

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-01-05 at 06:57:54ID22112248
Tags

ocx

,

register

Topic

Windows Networking

Participating Experts
1
Points
500
Comments
55

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Regsvr32
    I have some activex control projects I've compiled to ocx's but that's all. I've noticed that somehow, these are showing up in the projec's components window (three entries all called project1). I would like to remove them and was wondering if there's a way to do it from with...
  2. Unregister ActiveX exe
    How do I unregister an out-of-process ActiveX exe? Regsvr32 doesn't work, because of course this is an .exe, not a dll or ocx.
  3. ocx file
    Given a .ocx file (e.g. foo.ocx) and nothing else (no docs), how can i determine what functionality it provides? thru MS VC++?
  4. OCX
    How to check, that an OCX is registered properly ?
  5. Unregistering
    How to unregister a dll entry from system registery?
  6. Register OCX
    Hi, experts. Please help me. How can I find if certain .dll or .ocx is registered and if not, register it from certain directory. Thanks anywhere.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: sirbountyPosted on 2007-01-05 at 07:06:02ID: 18251595

One method comes to mind...use schtasks, if you're using xp clients...

deploy a batch file with those commands in it, and you can set the task to run as an admin account without exposing any admin credentials...

If that would work for you, post back and I'll show you how to script it...

 

by: RAMCITPosted on 2007-01-05 at 07:07:41ID: 18251603

i wouldn't be exposing admin credentials either way, I running all my scripts hidden :)

 

by: RAMCITPosted on 2007-01-05 at 07:09:51ID: 18251621

well the thing is that we would need to update this OCX whenever we make a release of our in-house application... and we never really schedule that, it is released as needed. Thanks for the idea tho

 

by: sirbountyPosted on 2007-01-05 at 07:16:27ID: 18251690

The source still sits on your network though, doesn't it?
I'm against using runas for this type of solution...for that purpose...
But, if you insist...
(not fully tested, so try it out and let me know - or you can wait till I post back that I've tested it here)


Dim oShell
Set oShell = WScript.CreateObject ("WScript.shell")

set strReg="%systemroot%\Downloaded Program Files\phone.ocx"
strAdmin="Domain\Admin"
strPW="Password"

oShell.run "cmd /c runas /user:" & strAdmin & "regsvr32 -u " & strReg
wscript.Sleep 1000
oShell.SendKeys strPW

oShell.Run "copy "\\10.168.0.62\activex\phone.ocx" "%systemroot%\Downloaded Program Files" /y"
WScript.Sleep 5000

oShell.run "cmd /c runas /user:" & strAdmin & "regsvr32 " & strReg
wscript.Sleep 1000
oShell.SendKeys strPW

set oShell=Nothing

 

by: RAMCITPosted on 2007-01-05 at 07:18:35ID: 18251713

I am not very familiar with vbs scripts unfortunately, could you please let me know what I need to configure in your script?

Thanks so much!

 

by: sirbountyPosted on 2007-01-05 at 07:21:37ID: 18251741

Based on your initial post, you'd simply need to provide

strAdmin="Domain\Admin"
strPW="Password"

for the actual values, where Domain is your domain name, Admin is the admin account, and Password is that password...testing it here now...

 

by: sirbountyPosted on 2007-01-05 at 07:27:53ID: 18251780

Not working out...stand by...

 

by: RAMCITPosted on 2007-01-05 at 07:31:02ID: 18251811

ok, standing by

 

by: sirbountyPosted on 2007-01-05 at 07:37:58ID: 18251881

Slight correction - added comments as well....save as NewOCXreg.vbs

'NewOCXreg.vbs

Dim oShell, oEnv 'Declarations
Set oShell = WScript.CreateObject ("WScript.shell") 'connect to shell
Set oEnv = oShell.Environment("Process") 'connect to environment

set strReg="%systemroot%\Downloaded Program Files\phone.ocx"  'path to ocx
strAdmin="Domain\Admin" 'Admin logon name
strPW="Password" 'Admin password

'Unregister file
oShell.run "cmd /c runas /user:" & strAdmin & " " & chr(34) & "regsvr32 -u " & strReg & chr(34)
wscript.Sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.slee 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to unregister the file

'Copy file
oShell.Run "copy "\\10.168.0.62\activex\phone.ocx" "%systemroot%\Downloaded Program Files" /y"
WScript.Sleep 10000 'wait 10 seconds for the file to be copied

'Register file
oShell.run "cmd /c runas /user:" & strAdmin & " " & chr(34) & "regsvr32 " & strReg & chr(34)
wscript.Sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.slee 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to register the file

set oEnv=Nothing
set oShell=Nothing


Any questions, let me know.
Please test it on a test machine before deploying...

 

by: RAMCITPosted on 2007-01-05 at 08:27:13ID: 18252423

I seem to be getting a syntax error at line 20 and char 20, is that because of the comment?

error code 800A03EA

 

by: sirbountyPosted on 2007-01-05 at 08:32:28ID: 18252487

One problem, I misspelled sleep:

wscript.slee 2000 'wait 'should be sleep

but that doesn't look like line 20
Presumably it's the copy...

oShell.Run "copy "\\10.168.0.62\activex\phone.ocx" "%systemroot%\Downloaded Program Files" /y"

Shell the shell :)

oShell.Run "cmd /c copy "\\10.168.0.62\activex\phone.ocx" "%systemroot%\Downloaded Program Files" /y"

and it should work...

 

by: RAMCITPosted on 2007-01-05 at 09:15:55ID: 18252932

eek

now I'm getting a syntax error in line 20 Char: 27

 

by: RAMCITPosted on 2007-01-05 at 09:17:03ID: 18252940

Looks like char 27 is the beginning of the server location between the " and the \\

 

by: sirbountyPosted on 2007-01-05 at 11:17:35ID: 18253985

27 appears to be the other misspelled spleep...

wscript.slee 2000 'wait

wscript.sleep

Sorry about that - I cut and pasted that section... : \

 

by: RAMCITPosted on 2007-01-05 at 11:22:04ID: 18254024

still getting error
Line: 20
Char: 27

this is how it looks (changed admin/pass) :

'NewOCXreg.vbs

Dim oShell, oEnv 'Declarations
Set oShell = WScript.CreateObject ("WScript.shell") 'connect to shell
Set oEnv = oShell.Environment("Process") 'connect to environment

set strReg="%systemroot%\Downloaded Program Files\phone.ocx"  'path to ocx
strAdmin="domain\admin" 'Admin logon name
strPW="password" 'Admin password

'Unregister file
oShell.run "cmd /c runas /user:" & strAdmin & " " & chr(34) & "regsvr32 -u " & strReg & chr(34)
wscript.Sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to unregister the file

'Copy file
oShell.Run "cmd /c copy "\\10.168.0.62\activex\phone.ocx" "%systemroot%\Downloaded Program Files" /y"
WScript.Sleep 10000 'wait 10 seconds for the file to be copied

'Register file
oShell.run "cmd /c runas /user:" & strAdmin & " " & chr(34) & "regsvr32 " & strReg & chr(34)
wscript.Sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to register the file

set oEnv=Nothing
set oShell=Nothing

 

by: sirbountyPosted on 2007-01-05 at 11:24:33ID: 18254047

OH - now I see it...

You can't have multiple quotes...have to use chr instead...

This
oShell.Run "cmd /c copy "\\10.168.0.62\activex\phone.ocx" "%systemroot%\Downloaded Program Files" /y"

should be

oShell.Run "cmd /c copy \\10.168.0.62\activex\phone.ocx " & chr(34) & "%systemroot%\Downloaded Program Files" & chr(34) & " /y"

 

by: RAMCITPosted on 2007-01-05 at 11:26:30ID: 18254072

error on like 7, char 1 now lol

 

by: sirbountyPosted on 2007-01-05 at 11:33:54ID: 18254131

Odd - I see nothing wrong there..let me retest this...

 

by: RAMCITPosted on 2007-01-05 at 11:50:07ID: 18254254

Thanks much, you're really going above and beyond, it is much appreciated.

 

by: sirbountyPosted on 2007-01-05 at 12:28:24ID: 18254570

<Smack>...sorry about that...

Set strReg = "%systemroot%\Downloaded Program Files\phone.ocx" 'path to ocx

should be

strReg = "%systemroot%\Downloaded Program Files\phone.ocx" 'path to ocx

 

by: RAMCITPosted on 2007-01-05 at 12:30:09ID: 18254579

error

Line 15
Char 1

 

by: sirbountyPosted on 2007-01-05 at 12:32:32ID: 18254591

Did you add the 'p' on sleep?

line 15 seems to be
wscript.sleep 2000

 

by: sirbountyPosted on 2007-01-05 at 12:57:13ID: 18254746

Still there?

 

by: RAMCITPosted on 2007-01-05 at 13:45:54ID: 18255093

ok the script runs but I get a regsvr32 error that reads:

LoadLibrary(C"\Windows\downloaded" failed - the specified module could not be found

 

by: sirbountyPosted on 2007-01-05 at 13:59:41ID: 18255183

Just got tricky...alright - let me see what I can do about that...

 

by: RAMCITPosted on 2007-01-05 at 14:02:54ID: 18255205

thanks again

 

by: sirbountyPosted on 2007-01-05 at 14:04:59ID: 18255217

Just so you know...
The problem stems from the fact that Downloaded Program Files contains spaces.
So that throws off the regsvr32 when we pass it to a shell.

I can think of a couple of ways around this and am testing one now...

 

by: RAMCITPosted on 2007-01-05 at 14:09:22ID: 18255257

Yea I figured as much but as I said I'm not very proficient with VBS so I would think having "" around the path would have done it...

 

by: sirbountyPosted on 2007-01-05 at 14:18:24ID: 18255324

Try this and let me know...

Dim objFSO, oShell, oEnv 'Declarations
Set oShell = CreateObject("WScript.shell")  'connect to shell
Set oEnv = oShell.Environment("Process") 'connect to environment
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Grab the short path name for Downloaded Program Files
If objFSO.FolderExists(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files") Then
  Set objFolder = objFSO.GetFolder(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files")
  strDPF = objFolder.ShortPath
End If

strReg = strDPF & "\phone.ocx" 'path to ocx
strAdmin = "domain\admin" 'Admin logon name
strPW = "password" 'Admin password

'Unregister file
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to unregister the file

'Copy file
oShell.Run "cmd /c copy \\10.168.0.62\activex\phone.ocx " & strDPF & " /y"
wscript.sleep 10000 'wait 10 seconds for the file to be copied

'Register file
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 " & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to register the file

Set oEnv = Nothing
Set oShell = Nothing
Set objFSO=Nothing

 

by: RAMCITPosted on 2007-01-05 at 14:26:43ID: 18255383

very nice, now it executes without errors on a PC where I am local admin

On a limited user's PC it gives me the error

Line 17
Char 1
Error: 0xFFFFFFFF
Code: FFFFFFFF

 

by: sirbountyPosted on 2007-01-05 at 14:40:39ID: 18255460

Confirm that line 17 is
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strReg & Chr(34)

and that strAdmin is set to Domain\User
where Domain is the domain name and User is a user with the necessary rights...

 

by: RAMCITPosted on 2007-01-06 at 09:35:23ID: 18258670

this is the script in its entirety as I have it:

_________________________________
Dim objFSO, oShell, oEnv 'Declarations
Set oShell = CreateObject("WScript.shell")  'connect to shell
Set oEnv = oShell.Environment("Process") 'connect to environment
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Grab the short path name for Downloaded Program Files
If objFSO.FolderExists(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files") Then
  Set objFolder = objFSO.GetFolder(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files")
  strDPF = objFolder.ShortPath
End If

strReg = strDPF & "\phone.ocx" 'path to ocx
strAdmin = "DINT000\PHONEM" 'Admin logon name
strPW = "adm*Cnm#" 'Admin password

'Unregister file
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to unregister the file

'Copy file
oShell.Run "cmd /c copy \\10.168.0.62\activex\phone.ocx " & strDPF & " /y"
wscript.sleep 10000 'wait 10 seconds for the file to be copied

'Register file
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 " & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to register the file

Set oEnv = Nothing
Set oShell = Nothing
Set objFSO=Nothing

 

by: sirbountyPosted on 2007-01-06 at 09:52:00ID: 18258733

Replace it for this...

Dim objFSO, oShell, oEnv 'Declarations
Set oShell = CreateObject("WScript.shell")  'connect to shell
Set oEnv = oShell.Environment("Process") 'connect to environment
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Grab the short path name for Downloaded Program Files
If objFSO.FolderExists(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files") Then
  Set objFolder = objFSO.GetFolder(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files")
  strDPF = objFolder.ShortPath
  msgbox "strDPF=" & strDPF
End If

strReg = strDPF & "\phone.ocx" 'path to ocx
strAdmin = "DINT000\PHONEM" 'Admin logon name
strPW = "adm*Cnm#" 'Admin password

'Unregister file
wscript.echo "Unregistering with:  " & "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strReg & Chr(34)
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to unregister the file

'Copy file
oShell.Run "cmd /c copy \\10.168.0.62\activex\phone.ocx " & strDPF & " /y"
wscript.sleep 10000 'wait 10 seconds for the file to be copied

'Register file
wscript.echo "Registering file with:  " & "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 " & strReg & Chr(34)
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 " & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to register the file

Set oEnv = Nothing
Set oShell = Nothing
Set objFSO=Nothing



You'll get a few pop-ups - I need to know the text in those popups please..

 

by: RAMCITPosted on 2007-01-06 at 10:12:49ID: 18258790

ok, with this one I get two popups on the limited user login:

1:
strDPF=C:\WINDOWS\DOWNLO~1

2:
strDPF=C:\WINDOWS\DOWNLO~1

 

by: RAMCITPosted on 2007-01-06 at 10:14:47ID: 18258799

Then after hitting ok on both I get:

Unregistering with: cmd /k runas /user:DOMAIN\USER "regsvr32 -u strDPF=C:\WINDOWS\DOWNLO~1\phone.ocx

when I hit ok I get:

Windows Script Host

Error
Line 19
Char 1
Error: 0xFFFFFFFF
Code: FFFFFFFF

 

by: RAMCITPosted on 2007-01-06 at 10:15:15ID: 18258802

then hit ok and I get

Error
Line 19
Char 1
Error: 0xFFFFFFFF
Code: FFFFFFFF

again

 

by: sirbountyPosted on 2007-01-06 at 10:25:13ID: 18258834

This is the output you 'should' see...

Unregistering with:  cmd /k runas /user:Domain\Admin "regsvr32 -u C:\Windows\Downlo~1\phone.ocx"

When you posted

Unegistering with: cmd /k runas /user:DOMAIN\USER "regsvr32 -u strDPF=C:\WINDOWS\DOWNLO~1\phone.ocx

Presumably you didn't change Domain\User ?

Something's amiss, because it's passing the variable 'and' it's value...plus it's not placing the last quote mark on that line...
That's the problem - why it's occurring is a mystery...

 

by: RAMCITPosted on 2007-01-06 at 10:30:04ID: 18258850

Well I did change the domain\user. Yea from what I can see it should work

On a PC where I have admin rights I do get Unegistering with: cmd /k runas /user:DOMAIN\USER "regsvr32 -u strDPF=C:\WINDOWS\DOWNLO~1\phone.ocx and it does succeed (after the two popups that saystrDPF=C:\WINDOWS\DOWNLO~1).

after that, I do get the command that it is trying to register the file, and that too succeeds.

 

by: RAMCITPosted on 2007-01-06 at 10:33:36ID: 18258856

so the problem still persists as

Error
Line 19
Char 1
Error: 0xFFFFFFFF
Code: FFFFFFFF

when the command tries to register or unregister the ocx

 

by: sirbountyPosted on 2007-01-06 at 10:34:40ID: 18258865

"On a PC where I have admin rights I do get Unegistering with: cmd /k runas /user:DOMAIN\USER "regsvr32 -u strDPF=C:\WINDOWS\DOWNLO~1\phone.ocx and it does succeed (after the two popups that saystrDPF=C:\WINDOWS\DOWNLO~1)."

You shouldn't even see that though...it's not working like that on my PC...and I'm stumped as to why it would work on yours...

the strDP= shouldn't even be there at all... :(



 

by: sirbountyPosted on 2007-01-06 at 10:36:20ID: 18258870

Try it with this...

Dim objFSO, oShell, oEnv 'Declarations
Set oShell = CreateObject("WScript.shell")  'connect to shell
Set oEnv = oShell.Environment("Process") 'connect to environment
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Grab the short path name for Downloaded Program Files
If objFSO.FolderExists(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files") Then
  Set objFolder = objFSO.GetFolder(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files")
  strDPF = objFolder.ShortPath
End If

strReg = "\phone.ocx" 'path to ocx
strAdmin = "DINT000\PHONEM" 'Admin logon name
strPW = "adm*Cnm#" 'Admin password

'Unregister file
wscript.echo "Unregistering with:  " & "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strDPF & strReg & Chr(34)
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strDPF & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to unregister the file

'Copy file
oShell.Run "cmd /c copy \\10.168.0.62\activex\phone.ocx " & strDPF & " /y"
wscript.sleep 10000 'wait 10 seconds for the file to be copied

'Register file
wscript.echo "Registering file with:  " & "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 " & strDPF &  strReg & Chr(34)
oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 " & strDPF & strReg & Chr(34)
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter
wscript.sleep 30000 'wait 30 seconds before proceeding to give the system time to register the file

Set oEnv = Nothing
Set oShell = Nothing
Set objFSO=Nothing

 

by: RAMCITPosted on 2007-01-06 at 10:42:49ID: 18258891

you think there's any other way to get this bad boy replaced and registered?

im so out of luck on this and we need it baad

 

by: sirbountyPosted on 2007-01-06 at 10:43:53ID: 18258893

Did you try the last post?

 

by: sirbountyPosted on 2007-01-06 at 10:45:14ID: 18258901

I'd offer you a quick dos batch, but I've never been able to successfully pass the password to a runas - thus the reason for initially suggesting schtasks.  The sendkeys method above is the only method I've gotten to work against runas...

 

by: RAMCITPosted on 2007-01-06 at 10:47:50ID: 18258907

wit hthe last one I get:

Error
Line 18
Char 1
Error: 0xFFFFFFFF
Code: FFFFFFFF
source: (null)

 

by: sirbountyPosted on 2007-01-06 at 10:52:28ID: 18258925

This is line 18...

oShell.Run "cmd /k runas /user:" & strAdmin & " " & Chr(34) & "regsvr32 -u " & strDPF & strReg & Chr(34)

and it works fine here. :(

Sure would be easier to trouble shoot this if I were on site! lol

I've thought of another idea - hate to keep posting 'non-working' code for you...Give me a bit and I'll come up with something else...

 

by: RAMCITPosted on 2007-01-06 at 10:55:13ID: 18258938

lol come on over!

haha

either way, you've been a trooper. The whole reason we are doing this is when we release a new version of this phone.ocx we need to be able to push it out immediately to users.

I wish I could use the scheduler and just be done with it.

 

by: sirbountyPosted on 2007-01-06 at 11:47:23ID: 18259141

Well, at least it's shorter... :^)

Let me know!

Dim objFSO, oShell, oEnv 'Declarations
Set oShell = CreateObject("WScript.shell")  'connect to shell
Set oEnv = oShell.Environment("Process") 'connect to environment
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Grab the short path name for Downloaded Program Files
If objFSO.FolderExists(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files") Then
  Set objFolder = objFSO.GetFolder(oShell.ExpandEnvironmentStrings("%SystemRoot%") & "\Downloaded Program Files")
  strDPF = objFolder.ShortPath
End If

strReg = "\phone.ocx" 'path to ocx
strAdmin = "DINT000\PHONEM" 'Admin logon name
strPW = "adm*Cnm#" 'Admin password

'Unregister file
Set objOutput = objFSO.CreateTextFile(oEnv("TEMP") & "\RegisterPhone.bat")
objOutput.WriteLine "regsvr32 -u " & strDPF & strReg
objOutput.WriteLine "copy \\10.168.0.62\activex\phone.ocx " & strDPF & " /y"
objOutput.WriteLine "regsvr32 " & strDPF & strReg
objOutput.Close
wscript.sleep 1000 'wait
oShell.Run "cmd /k runas /user:" & strAdmin & " " & oEnv("TEMP") & "\RegisterPhone.bat"
wscript.sleep 1000 'wait
oShell.AppActivate oEnv("SystemRoot") & "\system32\runas.exe" 'find runas
wscript.sleep 2000 'wait
oShell.SendKeys strPW & "~" 'send password and Enter

Set oEnv = Nothing
Set oShell = Nothing
Set objFSO = Nothing

This version leaves the cmd window open - so that you can view any errors, if any...
If there are none, you can switch the /k to a /c to have it close afterwards...and if it works, we can hide the window altogether...

 

by: RAMCITPosted on 2007-01-06 at 12:00:39ID: 18259189

I have a feeling it has to do with the vast limitations I have set on this user through group policy. I have just consulted with the programmer in charge of this phone.ocx and he stated that it would not be a bad idea if we use the scheduler. He sayd we could time the scheduler with the release. It would be a pain, but its a way to do it.

So how would I use the scheduler with group policy to push out to everyone?

 

by: RAMCITPosted on 2007-01-06 at 12:01:35ID: 18259196

still getting errors, this time on 23...

bah, lets do the scheduler lol

 

by: sirbountyPosted on 2007-01-06 at 12:04:13ID: 18259202

Can't see it being permissions, since we're passing the password...

This line,
oShell.Run "cmd /k runas /user:" & strAdmin & " " & oEnv("TEMP") & "\RegisterPhone.bat"

should've left a window open - did you note what was displayed in it?

 

by: RAMCITPosted on 2007-01-06 at 12:17:36ID: 18259258

I have the CMD windows running hidden on this user (or the test user copy of it)

we can do the scheduler with no problem says the programmer in charge, I dont wanna waste any more of your time man, you already got the points... %*# I wish I could give you more lol

 

by: sirbountyPosted on 2007-01-06 at 12:30:59ID: 18259311

Not wasting my time - it's just a bit aggrivating that it's not working on your end...if you're up for it, I'm more than willing to get it working.

Unfortunately, I'm not too good with GPOs....our org deparmentalizes those functions and even though I'm "the server guy", we don't really do a lot of AD administration.

 

by: RAMCITPosted on 2007-01-06 at 12:38:02ID: 18259332

hmm, I'm not sure it's possible to use group policy to use the schedule, gonna have to research.

I will also look at the actual GPO and see if theres something preventing that line from running

 

by: sirbountyPosted on 2007-01-06 at 12:40:42ID: 18259339

You don't have Remote Assistance capability there do you? :^)

As for the scheduled solution - if you can deploy the bat file in your netlogon share, you can schedule it via the login script with

schtasks /create /ru Domain\Admin /rp Password /sc onstart /tn NewPhone /tr "cmd /c \\server\netlogon\newphone.bat"

sc can also be /sc onlogon

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...