Jump to content
Sign in to follow this  
Klexen

Need to check if program is running in a specified directory

Recommended Posts

Klexen

I want to check to see if my program is being run in a certain directory if it is I want it to MsgBox then Exit. I tried making this up.. But doesnt work.

Can someone help me out please?

if @ScriptFullPath = "The directory" Then
    MsgBox(0,"YOU CAN NOT RUN THIS PROGRAM FROM THIS DIRECTORY!")
    Exit
EndIf

If @ScriptDir =  "The directory" Then
    MsgBox(0,"YOU CAN NOT RUN THIS PROGRAM FROM THIS DIRECTORY!")
    Exit
EndIf

Share this post


Link to post
Share on other sites
Pakku

Hi,

I don't know dude, but according to the help file (and my thoughts)

@ScriptDir
returns a path and
"The directory"
isn't.

So read the helpfile before you post your questions.

Arjan

Share this post


Link to post
Share on other sites
Klexen

I figured it out.. Thanks!

$CurrentDir = @ScriptDir
If $CurrentDir = "C:\Users\klexen\Desktop\SuperLaunch" Then
    MsgBox(0,"!","You are running this from an invalid location Copy to you U:\ Drive")
    Exit
Else
    MsgBox(0,"","You are running this from a valid dir.")
    EndIf
Edited by Klexen

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×