Solved

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

Posted on 2014-04-30
1
799 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

696 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