?
Solved

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

Posted on 2014-04-30
1
Medium Priority
?
814 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
[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
1 Comment
 
LVL 65

Accepted Solution

by:
RobSampson earned 1500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

801 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