Solved

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

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

728 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