Solved

open folder in powershell

Posted on 2010-09-01
6
1,448 Views
Last Modified: 2012-06-22
hi, id like a powershell script to open a location

eg

when run the folder c:\data\test\%hostname%\tools    opens  much like if there was a shortcut to it


power shell preffered VB ok
0
Comment
Question by:mhamer
[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
  • 4
  • 2
6 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 33576449
use Invoke-item:invoke-item c:\data\test\%hostname%\tools
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 33576477
to get %hostname% (envirnemtn variable) use the following:$hostname = $Env:hostnameinvoke-item c:\data\test\%hostname%\tools
0
 

Author Comment

by:mhamer
ID: 33576597
Great works perfectly thank you

what would be the vb equivilant?  just out of interest?  you get the points anyway
0
Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

 
LVL 42

Expert Comment

by:sedgwick
ID: 33576703
in vb script:


Set objShell = CreateObject("WScript.Shell")
hostname = objShell.ExpandEnvironmentStrings("%hostname%")
objShell.Run "explorer c:\data\test\" & hostname & "\tools

Open in new window

0
 

Author Comment

by:mhamer
ID: 33577013
unterminated string constant  when i use that
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 33577119
i forgot the " in line 3:

Set objShell = CreateObject("WScript.Shell")
hostname = objShell.ExpandEnvironmentStrings("%hostname%")
objShell.Run "explorer c:\data\test\" & hostname & "\tools"
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

687 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