Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

12 Experts available now in Live!

Get 1:1 Help Now