Windows 10 - Username with whitespace and PATH [closed] - path

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Upon installing Windows 10 I created my admin user as Miha Šušteršič. Now when I install programs that need to modify the environment variable PATH, most of them don't get added. For instance this happens with MongoDB and Git, but npm got added normally.
I think this is an issue with the whitespace in the path to the variables. I tried renaming my username to M.Sustersic, but the system folder Users\Miha Šušteršič\ did not get updated.
Is there a way for me to change this folder name automatically (so the rest of the app dependencies on \Users\Miha Šušteršič\AppData don't get bugged) or do I need to reinstall windows?
Is there something else I am missing here? I tried adding the dependencies on my own, but nothing worked so far.

You can actually change the folder name. It's a bit tedious but it's worth it. Make sure you know of the edition of your Windows 10 you're using first - Professional, Enterprise or Home - before carrying out these steps, cos of step 5:
Right click on Windows Start Menu option and click Command Prompt (Admin)
(If you can't find Command Prompt (Admin) when you right-click on the Start Menu or search for it, you can simply go to C:/Users/Default/AppData/Local/Microsoft/Windows/WinX/Group3 on your pc. There, you'll find two shortcuts both named "Command Prompt"; one is for Command Prompt, and the other is for Command Prompt (Admin).Try out both shortcuts to know which is which, and then click on the one for Command Prompt (Admin))
In the Command Prompt (Admin), create a new/temporary admin account by entering this command: net user Administrator /active:yes (Notice the space between Administrator and /) and close the cmd
Next, click on the start menu and sign out of your current admin account
(four icons above the shut down button)
Sign in with the new Administrator account you just created
(Skip this step only if you use the Windows Home Edition) Right click on the Start Menu and click Computer Management and open Local Users and Groups > Users. Right-click on the username you wish to change and select Rename and close the window.
Open Local Disk (C) > Users and right-click and rename the corresponding folder with the name you wish, just as in Step 5, and close the window.
Next, search for regedit in the search box and click on it. Now, inside the regedit (i.e. Registry Editor), go to HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows NT > Current Version > Profile List.
In the list of identifiers under Profile List, find the ProfileImagePath that corresponds to the account name you wish to change. Yours should look something like this:
ProfileImagePath REG_EXPAND_SZ c:\Users\Miha Šušteršič.
Double click on the value and rename it to what you want.
Still in the regedit, scroll up to the top of the window and make sure the highlight is on Computer, then click Edit in the menu options just above it; then click Find; then enter C:\Users\<your old username>. In your case, that would be:
C:\Users\Miha Šušteršič
And search.
If the search brings out any result (i.e. any folder bearing your old account user name,) click on it and rename it, and then go back to Edit in the menu option and this time, click Find Next or f3. Keep on "Finding Next" this until there are no files are left to rename, then close regedit.
Finally, sign out of your Administrator account and sign in with your now-renamed account, and then, go on to disable the Administrator account you just signed out from. You do this by going to Command Prompt (Admin) and this time, you enter the command:
net user Administrator /active:no
(Once again, notice the space between Administrator and /)
...and close the command.
And that's it! Long and tedious, but it works. You can check also out this video to have a better understanding of everything I just described.
_Note: Make sure to follow every step to the letter so you don't run into more serious problems.
If you run into any issues renaming at Step 6, simply shut down your computer and restart and try again.
Also, certain files may/will not allow for renaming. It's alright; just leave them as they are and "Find Next" until there's no more file to rename._

See this KB article to change the name of the User Profile directory.
After you do this, you may want to make a link just in case any of your apps keep local path configuration.
cd C:\Users
mklink /D "Miha Šušteršič" M.Sustersic

Related

How to disable Notepad++ Auto-open previous files without opening Notepad++?

How do I stop Notepad++ from loading all files from the past session?
I know how to do that settings in Notepad++, but the problem is that I once opened a very large file (>10GB) and made the Notepad++ hang up. Notepad++ has already marked that big file in the session and therefore hang up everytime I start the Notepad++. Is there a way I can stop it from loading the past session so it won't hang up every time?
P.S. I have received a report on possible duplicate with this question. This is obviously a different case. At least in that question the notepad++ still starts up normally while in my case I cannot even change the settings normally because the notepad++ just hang while loading the stored version. The answer to this question also provide a good way to change the settings without starting Notepad++, which will be useful in fixing problems caused by settings when the Notepad++ cannot starts normally.
Yes, you can change that setting by modifying the config file.
go to %appdata%\Notepad++
and open config.xml
You should find the following line in there:
<GUIConfig name="RememberLastSession">yes</GUIConfig>
just change it to no and that should do the trick.
Start from command line:
notepad++ -nosession
"Auto-open previous files" then should be disabled
This is for those who do not want to modify the XML config filess, and this will also work without having the Notepad++ in PATH.
As I do not have enough reputation to comment on other answers, I'll add on Jacques Hubart's comment, all credits should still be for him.
Open Windows Run (Windows + R)
Type in the full path to the Notepad++ EXE.
This would normally be C:\Program Files\Notepad++\notepad++.exe
Add the nosession parameter
Run
Preview:
If, like me, you left a huge file in the last session, you can also remove just the offending file from the session and keep the rest.
go to %appdata%\Notepad++ and open session.xml
Scroll to the right to see the filename. Be careful to keep the integrety of the XML by removing the entire "file" node. It should be on a single line.
There is also another way from GUI
In Settings/Preferences/Backup uncheck the "Remember current session for next launch"
As suggested use notepad++ -nosession from run to open notepad++. Then go to preferences --> Backup --> Uncheck Remember current session before next launch
Close notepadd++ and open it normally without run. It worked for me.
another possibility is that the window is on an other screen not visible anymore due to starting it in a new multimonitor setup.
in that case, you have to bring the windows in the visible area by:
select the window by Alt+Tab
Alt+Space opens a small menu in the top left corner
Arrow-Down and Enter selects ' Move'
Arrows brings it back

Granting "Local System" permissions the installation folder in Advanced Installer

I have an "Advanced Installer" project that I am trying to use to install my "TopShelf" windows service that I have built.
I found the spot in Advanced Installer to grant permissions to the installation folder, but I don't see a way to grant permissions to the "Local System" account.
Manually, this is done by going to the security option in the properties of the folder and adding a user with the same name as the computer name but ending with a $. For Example MyNiceComputer$. (Oh, and you have to select the "Computers" option in the types area.)
But there is no way to do all this in Advanced Installer. If I do make one like MyNiceComputer$, it just makes an empty entry in the security tab. (No Permissions on it, even though I setup for full control.)
Has anyone ever needed to do this with Advanced Installer?
Additional Details:
I am installing an app that runs as a windows service. (It is a console app built with TopShelf).
Our company policy is to install all our applications into a folder that looks like this:
C:\OurCompanyApps\MyApp
When I create the installer, it runs fine, but then I when I start up the Windows Service, I get the following error:
Windows could not start the MyApp service on Local Computer
Error 5: Access is denied.
But when I grant access to Local System (by giving Full Control rights to myNiceComputer$ on the MyApp folder), then this error goes away and the app runs fine. From what I read, this is because the application is running as Local System.
It seems odd that it needs full control but it does not work without it. (But as far as I can see, the contents of the folder are un-altered).
#Bogdan Mitrache seems to indicate that granting permissions to Local System is not possible via Advanced Installer. This is good to know (so I don't waste more time looking). I will probably ask my System Admins for a dedicated system account to run my service as. Not ideal, but it will serve as a work around.
So, in one of my "less finer" moments of debugging, I mixed up two different things.
There was also a file missing, (my config file). I restored that and changed the permissions at the same time. But then I forgot to go back and verify which one was the actual fix. (I know, not good debugging.)
So, the Access is denied error was due to a missing file.

Window Services start-stop permission to Remote Desktop users

I want to give MS SQL service start/stop permission to Remote Desktop users (not admin user). Can anyone have idea about this?
Step 1 – Create the Console
We need to open a hidden console snap-in
Click Start > Run (or press WIN + R) and type “mmc.exe”
This opens an empty Microsoft Management Console. Click File > Add/Remove Snap-in… (Ctrl + M)
Scroll down the list of available Snap-ins and select Security Configuration and Analysis
Click Add
Next select Security Templates
Click Add
Click OK
Step 2 – Create a blank Security Template
In Windows Server 2003 and below you can store these files anywhere but later versions have tougher restrictions so we will be creating everything in D:\Securtiy\
Right-click Security Templates from the console tree and select New Template Search Path …
Browse to D:\Security, or other local path, and click OK
Right-click D:\Security from the console tree and select New Template …
Give the new template a name, e.g. Custom Services. It doesn’t matter what you use.
The Description is optional but may be useful if you want to re-use it
Click OK and you will see the new template appear in the console
Step 3 – Create a Security Database
Right-click Security Configuration and Analysis from the console tree and select Open Database…
Browse to D:\Security, or other local path, and type a name in the File name: box e.gSecurity
Click OK. This creates an Security.sdb file that is used to apply the changes
An Import Template window appears. Browse to C:\Security/Custom Services.inf and selectOpen. This applies the template with all the local services to the database
If you get the error “The database you are attempting to open does not exist.” then you need to choose a different path i.e. on a local disk
Right-click Security Configuration and Analysis from the console tree and select Analyze Computer …
Click OK to accept the default log file path
You will then be presented with something that looks very similar to the Group Policy Editor or Local Security Policy Console
Step 4 Change Service Permissions
Double-Click System Services
Scroll down to find the service you need to change, MSSQLSERVER ,MSSQLAGENT
Double-Click the above mentioned services.
Tick the box Define this policy in the database:
Click the Edit Security … button
Click Add
Type in the user name of the Service account e.g. Remote Desktop User, and click OK
With the Remote Desktop User account selected, check the Allow permissions for Start, stop and pause
Click OK
Click OK on the Service Properties to bring you back to the console
You’ll notice the Service now has an ‘x’ on it and Investigate message on the Permission column. This is because the new permissions we’ve chosen conflict with what is on the local computer
Step 5 – Apply new Security Permissions
Right-click Security Configuration and Analysis from the console tree and select Configure Computer …
Click OK to accept the default log file path
This will apply the new custom permissions to the local computer
You can now test it out on the server with the Remote Desktop User account and test it works..

using NSIS to install and run every time

Im doing a little research into installers, and right now at my company we are having some issues deploying from jenkins using click once. We have a test certificate(these programs are all internal) and for some reason are having some issues with the certifcate being incompatiable with certain msbuilds/.net frameworks. So im looking into alternatives.
But in that i want to keep the same architecture. How it works right now is someone clicks on a button in our task bar, clicks on the application they want, and then click once installs the updates(or installs) without further user input and starts the application. Ive heard a lot of good things about NSIS.
So far ive only seen generic application installers like you expect when you download anything from the internet. Could I do something like i described above using NSIS?
A very basic no interaction installer might look like this:
Name foo
OutFile foo_setup.exe
AutoCloseWindow true
RequestExecutionLevel user
InstallDir "$LocalAppData\Programs\MyApp"
Page InstFiles
Section
SetOutPath "$InstDir"
WriteUninstaller "$InstDir\uninst.exe"
; TODO: Add registry entry for Add/Remove Programs
File "MyApp.exe"
File "Data.xml" ; Support files etc
Exec '"$InstDir\MyApp.exe" -firstrun "c:\some path\file.ext"'
SectionEnd
Section Uninstall
Delete "$InstDir\MyApp.exe"
Delete "$InstDir\Data.xml"
Delete "$InstDir\uninst.exe"
RMDir "$InstDir"
SectionEnd
If you want to install for all users in %ProgramFiles% you can run into issues with Exec because the app can end up running as the wrong user if a non-administrator used some other account in the UAC dialog.

How do I restart a service on a remote machine in Windows? [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 9 years ago.
Improve this question
Sometimes while debugging, I need to restart a service on a remote machine. Currently, I'm doing this via Remote Desktop. How can it be done from the command line on my local machine?
You can use the services console, clicking on the left hand side and then selecting the "Connect to another computer" option in the Action menu.
If you wish to use the command line only, you can use
sc \\machine stop <service>
You can use mmc:
Start / Run. Type "mmc".
File / Add/Remove Snap-in... Click "Add..."
Find "Services" and click "Add"
Select "Another computer:" and type the host name / IP address of the remote machine. Click Finish, Close, etc.
At that point you will be able to manage services as if they were on your local machine.
You can use System Internals PSEXEC command to remotely execute a net stop yourservice, then net start yourservice
Using command line, you can do this:
AT \\computername time "NET STOP servicename"
AT \\computername time "NET START servicename"
I would suggest you to have a look at RSHD
You do not need to bother for a client, Windows has it by default.
Well, if you have Visual Studio (I know it's in 2005, not sure about earlier versions though), you can add the remote machine to your "Server Explorer" tag. At that point, you'll have access to the SERVICES that are running, or can be ran, from that machine (as well as event logs, and queues, and a couple other interesting things).
One way would be to enable telnet server on the machin you want to control services on (add/remove windows components)
Open dos prompt
Type telnet yourmachineip/name
Log on
type net start &serviceName* e.g. w3svc
This will start IIS or you can use net stop to stop a service.
Depending on your setup you need to look at a way of securing the telnet connection as I think its unencrypted.
Several good solutions here. If you're still on Win2K and can't install anything on the remote computer, this also works:
Open the Computer Management Console (right click My Computer, choose Manage; open from Administrative Tools in the Start Menu; or open from the MMC using the snap-in).
Right click on your computer name and choose "Connect to Remote Computer"
Put in the computer name and credentials and you have full access to many admin functions including the services control panel.

Resources