Windows batch file starting directory when ‘run as admin’

Try to access the batch files path like this: echo %~dp0 For more information see the following quote from the command for /? that describes how the above command works: You can now use the following optional syntax: %~I – expands %I removing any surrounding quotes (“) %~fI – expands %I to a fully qualified … Read more

how to list all sub directories in a directory

Use Directory.GetDirectories to get the subdirectories of the directory specified by “your_directory_path”. The result is an array of strings. var directories = Directory.GetDirectories(“your_directory_path”); By default, that only returns subdirectories one level deep. There are options to return all recursively and to filter the results, documented here, and shown in Clive’s answer. Avoiding an UnauthorizedAccessException It’s … Read more

Getting a list of folders in a directory

I’ve found this more useful and easy to use: Dir.chdir(‘/destination_directory’) Dir.glob(‘*’).select {|f| File.directory? f} it gets all folders in the current directory, excluded . and … To recurse folders simply use ** in place of *. The Dir.glob line can also be passed to Dir.chdir as a block: Dir.chdir(‘/destination directory’) do Dir.glob(‘*’).select { |f| File.directory? … Read more

How to convert the PathBuf to String

As mcarton has already said it is not so simple as not all paths are UTF-8 encoded. But you can use: p.into_os_string().into_string() In order to have a fine control of it utilize ? to send error to upper level or simply ignore it by calling unwrap(): let my_str = cwd.into_os_string().into_string().unwrap(); A nice thing about into_string() … Read more

How to go back 1 folder level with __dirname?

TL;DR Use path.join(__dirname, ‘..’, ‘test’, ‘karma.conf.js’). Prevent use of slashes. Long Answer As a lot of answers have pointed out, using path module is probably the best way. However, most of the solutions here have gone back to using slashes like: path.join(__dirname+’../test/karma.conf.js’) However, by doing this, you’re beating the purpose of using path. One uses … Read more

Shell script current directory?

As already mentioned, the location will be where the script was called from. If you wish to have the script reference it’s installed location, it’s quite simple. Below is a snippet that will print the PWD and the installed directory: #!/bin/bash echo “Script executed from: ${PWD}” BASEDIR=$(dirname $0) echo “Script location: ${BASEDIR}”

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)