• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1482
  • Last Modified:

open folder in powershell

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
mhamer
Asked:
mhamer
  • 4
  • 2
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
use Invoke-item:invoke-item c:\data\test\%hostname%\tools
0
 
Meir RivkinFull stack Software EngineerCommented:
to get %hostname% (envirnemtn variable) use the following:$hostname = $Env:hostnameinvoke-item c:\data\test\%hostname%\tools
0
 
mhamerAuthor Commented:
Great works perfectly thank you

what would be the vb equivilant?  just out of interest?  you get the points anyway
0
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
Meir RivkinFull stack Software EngineerCommented:
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
 
mhamerAuthor Commented:
unterminated string constant  when i use that
0
 
Meir RivkinFull stack Software EngineerCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now