Solved

Trying to run Internet Explorer using runas with /env switch using vbscript

Posted on 2014-04-30
1
773 Views
Last Modified: 2014-05-19
I am trying to run IE under a different user with the /env switch but it keeps erroring out saying invalid directory. It works fine without /env.


Set objShell = WScript.CreateObject("WScript.Shell")
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
'MsgBox "runas " & "/env " & "/noprofile /user:" & strComputer & "\permits " & """c:\Program Files\Internet Explorer\iexplore.exe"""
'objShell.Run("runas /env /noprofile /user:" & strComputer & "\permits " & Chr(34) & "c:\Program Files\Internet Explorer\iexplore.exe" & Chr(34)), 8
objShell.Run("runas " & "/env " & "/noprofile /user:" & strComputer & "\permits " & """c:\Program Files\Internet Explorer\iexplore.exe"""), 8
WScript.Sleep 1900
objShell.Sendkeys "password~"

Open in new window

0
Comment
Question by:ats2012
1 Comment
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 40033844
You will need to run the script from an elevated command prompt, using:
cscript C:\Scripts\RunIE.vbs"

Since you are using /noprofile to not load the profile for "permit", and are using the /env switch to use the current environment, you will need to have full system access, and "pemits" must be an admin account.  Without using an elevated command prompt, UAC would block "permits" from accessing the current user profile.

Regards,

Rob.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now