%USERPROFILE%/Desktop no longer valid after relocating Desktop folder to OneDrive [closed] - windows

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I've moved my Windows 10's /Desktop folder to a different location.
As a result, my batch and Powershell scripts that were pointing to %USERPROFILE%/Desktop no longer worked. Is there another way to get the location of my desktop without hardcoding the new path in?

In PowerShell you can use this
[Environment]::GetFolderPath([Environment+SpecialFolder]::Desktop)
To use it from a batch file you can call powershell to get the path
powershell -C "[Environment]::GetFolderPath([Environment+SpecialFolder]::Desktop)"
and then save the result to a variable using for /f

Related

After changing my $PATH on Mac, how can I change it back? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I tried to change my $PATH on my Mac computer.
I tried to add a line at the end of the .bash_profile:
export $PATH=${PATH}:$"/Applications/CMake.app/Contents/bin"$
After that, I executed source ./.bash_profile, and the $PATH has changed.
When I change the file back by deleting that export line, saving it, and then executed source ./.bash_profile, the $PATH is changed and it does not change back.
It is recombining the envvar PATH when you run it again. You'll likely have to restart your shell after making the change.

How to make the path generic (RUBY)? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
This is how I am changing the directory path to the download folder.
Dir.chdir("C:/Users/abcd/Downloads/")
But this specific to a user. Is there is any way to make it more general?
Use home method for Dir
Dir.chdir(Dir.home + '/Downloads')
The "C:/Users/abcd/Downloads/" looks like the user directory for user abcd on windows. So I think this is a windows related question.
The Dir.home on my Windows-PC is U:/, not the user-directory.
But you can make use of ENV:
Dir.chdir(File.join(ENV['USERPROFILE'], 'Downloads'))
Just to be aware of: This changes the directory for the rest of your script. There is also a block-version of Dir.chdir.

Removing windows aliases [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Recently, I gave some folders an alias for web sharing. The folders got cut and pasted out of their original location and then restored. The aliases were lost in the process yet when I try to reassign them the same alias it complains that the alias is taken. No other folder has these aliases only they did but that was lost in the cut and paste. Is there a system file somewhere or a registry I can edit to remove them so I can reapply them? The alias names are sensitive. The OS is Windows Server 2003.
I deleted the websites from IIS, refreshed and I was able to make the alias again.

How to determine whether a drive is TrueCrypt mounted? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is it possible, in a Windows batch file, to test if a certain drive letter was mounted by TrueCrypt?
I think this is not possible. You could get much information with wmic logicaldisk but nothing will indicate that Truecrypt assigned the drive letter.
As an Idea: (for anyone still finding this post)
You could make this C# Script over at the post #18021118 (which accesses truecrypt to retrive mount information) (there is also a VeraCrypt version over there.) ...
into a commandline tool to be used from your windows batch (added a simple example here: http://github.com/BananaAcid/VeraCrypt-Cmd - replace the get mounts file with the one from the readme within)
or use it directly with powershell
or with an additional binary wich executes scripts on the windows NET Framework without compiling: cs-script.

running bat file using windows scheduler [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 13 years ago.
Improve this question
i wanted to run a .bat file in windows task scheduler, so i opened it, added a new task, browsed to the bat file, and... nothing happened. so i changed the timing to see if it'll run, and it didn't. next i right-clicked on the task and chose "run"- it didn't run. the file itself is only one line, basically backups a folder to a another location. it runs fine when not in the scheduler.
what can be done?
thank you
You should not give batch file directly as a task. Instead you should use
"C:\Windows\system32\cmd.exe" /C <completepathtobatchfile> <argstobatchfileifany>
the complete path to cmd.exe may vary in your case depending on which drive you installed OS and which version you are using.

Resources