how to use WinCommander on a dual booted system?

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
Dalai
Power Member
Power Member
Posts: 9366
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Hacker wrote:Well then perhaps [face=courier]subst[/face], as I mentioned before?
That would certainly work - provided that brian uses only the substed drives, not the regular ones.

@brian:
Just in case you don't know what substed drives are, take a look at this Wikipedia article, the Limitations are also worth taking a look at, especially the one about deleting files. Note that a substed drives requires a free drive letter. You could place a batch script in your startup folder with something like this:

Code: Select all

@echo off

ver | find /i "6.3." > NUL && (
    REM --- Paths valid for Win8.1
    subst M: C:\Music
    subst N: D:\Movies
) ELSE (
    REM --- Paths valid for Win10
    subst M: G:\Music
    subst N: C:\Movies
)
Change drive letters and paths as needed. Then you can make the search-and-replace in your wincmd.ini, which is only required once. And, as I said: only use the substed drives.

If something is unclear, feel free to ask.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

eeehm, right now, I do it via a macro, in an editor. This solves all my problems. However, I was looking for something BETTER, and faster. What you're suggesting seems more work than that, and it's also limited, in the sense that I am then confined to use a limited set of drives.

so, yes, I've got questions:

What is kind of unclear, or mystifying, is why you don't suggest how to write that script I mentioned? Or why you dont do it, since it seems to me, it would be a piece of cake for you.
We call it WindowsCommander because it commands Windows, not "Total".
even though it'd be cool to command a 7 trillion dollar oil company
It won Best Alternative File Manager
http://polldaddy.com/poll/810222/
First comment = my girl! ;)
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

Dalai wrote:Well, of course it is possible to write a script that changes the paths in wincmd.ini accordingly, something that makes use of sed.exe, AHK or AutoIt or similar,

Regards
Dalai
Can't it be done in DOS and Edit.com or something?
We call it WindowsCommander because it commands Windows, not "Total".
even though it'd be cool to command a 7 trillion dollar oil company
It won Best Alternative File Manager
http://polldaddy.com/poll/810222/
First comment = my girl! ;)
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

brian,
Well, what is being suggested is to make all paths universal for both systems, not only both TC's. If you do not want that, OK.
But I don't know how:
1. the specific commands to make this script. for example how does the script detect on which OS it's running? Can it detect the labels of the logical drives? Because I've labeled them "WinTan" and "WinAte"
2. to make this script run before WinCmd runs, which is in my Startup
1. As far as I understood you only need to exchange C:\ and D:\, regardless of what OS you are on. Using AutoHotkey, run this script from the Button Bar (or from elsewhere inside TC):

Code: Select all

#NoEnv

ReplaceString1 = C:\
ReplaceString2 = D:\
TemporaryString = ######TempString######

EnvGet, TcIni, COMMANDER_INI
EnvGet, TcExe, COMMANDER_EXE
SplitPath, TcExe, TcProcessName

PostMessage, 1075, 24340, , , ahk_class TTOTAL_CMD
Process, WaitClose, %TcProcessName%
FileRead, FileContents, %TcIni%
StringReplace, FileContents, FileContents, %ReplaceString1%, %TemporaryString%, All
StringReplace, FileContents, FileContents, %ReplaceString2%, %ReplaceString1%, All
StringReplace, FileContents, FileContents, %TemporaryString%, %ReplaceString2%, All
FileRecycle, %TcIni%
FileAppend, %FileContents%, %TcIni%

Run, %TcExe%
Why would you need the script to detect drive labels?

2. Could be done but you don't want to exchange C:\ and D:\ on each Windows start, only when you switch from one boot system to the other.

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Dalai
Power Member
Power Member
Posts: 9366
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

brian wrote:What is kind of unclear, or mystifying, is why you don't suggest how to write that script I mentioned? Or why you dont do it, since it seems to me, it would be a piece of cake for you.
Seems like I didn't explain good enough which problems could arise when using such a script. Of course it's possible and quite easy to write it, but to make it reliable is the hard part. Just replacing all occurances of string X with string Y may work at first, until there's some string that you don't want to have replaced. That might not be the case at once, but may at some point in time in the future.

@Hacker:
The replacement you make in your code only works in one direction, but both directions are needed. As I understand brian, the Win10 system partition is C: when Win10 is running (obviously). This is, if I understood that correctly, where his files are stored. This partition will be D: when running Win8. Your script covers the case when booting from Win10 into Win8. So far so good.

But when Win8 is rebooted into Win10, the replacement needs to go from D: to C: again. So, yes, some kind of detection is required. This may be the Windows version, a marker in wincmd.ini itself (e.g. key in an unused section) or something else.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

Hacker wrote: 1. As far as I understood you only need to exchange C:\ and D:\, regardless of what OS you are on. Using AutoHotkey, run this script from the Button Bar (or from elsewhere inside TC):
I only need it for wincmd yes, and only for some buttons and directory preferences.

AutoHotkey has 3 virus warnings:
https://www.virustotal.com/#/file/64d391b2e42b022d5adc1bb5b342f5b631e347cce1bbe027945a6f0a6a664af2/detection


Hacker wrote:Why would you need the script to detect drive labels?
because they don't change upon re-boot? So, then we can add the conditional "IF" to the script, like

Code: Select all

 IF C:\ = WinTan do this
and IF C:\= WinAte do that.
Hacker wrote: 2. Could be done but you don't want to exchange C:\ and D:\ on each Windows start, only when you switch from one boot system to the other.
True. hence a button, which at its end restarts WinCmd.
We call it WindowsCommander because it commands Windows, not "Total".
even though it'd be cool to command a 7 trillion dollar oil company
It won Best Alternative File Manager
http://polldaddy.com/poll/810222/
First comment = my girl! ;)
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

Dalai wrote:Just replacing all occurances of string X with string Y may work at first, until there's some string that you don't want to have replaced.
But that is exactly what I do now, and it's working fine. So... Dr. Strangelove and all that.

Dalai wrote:@Hacker:
The replacement you make in your code only works in one direction, but both directions are needed. As I understand brian,
You understood me fine. Now, the 2nd directions is no biggie, look below.

[face=courier]IF winver ="[Version 10.0.14393]"
THEN
[/face]

Code: Select all

#NoEnv

ReplaceString1 = C:\
ReplaceString2 = D:\
TemporaryString = ######TempString######

EnvGet, TcIni, COMMANDER_INI
EnvGet, TcExe, COMMANDER_EXE
SplitPath, TcExe, TcProcessName

PostMessage, 1075, 24340, , , ahk_class TTOTAL_CMD
Process, WaitClose, %TcProcessName%
FileRead, FileContents, %TcIni%
StringReplace, FileContents, FileContents, %ReplaceString1%, %TemporaryString%, All
StringReplace, FileContents, FileContents, %ReplaceString2%, %ReplaceString1%, All
StringReplace, FileContents, FileContents, %TemporaryString%, %ReplaceString2%, All
FileRecycle, %TcIni%
FileAppend, %FileContents%, %TcIni%

Run, %TcExe%
[face=courier]ELSE[/face]

Code: Select all

#NoEnv

ReplaceString1 = C:\
ReplaceString2 = D:\
TemporaryString = ######TempString######

EnvGet, TcIni, COMMANDER_INI
EnvGet, TcExe, COMMANDER_EXE
SplitPath, TcExe, TcProcessName

PostMessage, 1075, 24340, , , ahk_class TTOTAL_CMD
Process, WaitClose, %TcProcessName%
FileRead, FileContents, %TcIni%
StringReplace, FileContents, FileContents, %ReplaceString2%, %TemporaryString%, All
StringReplace, FileContents, FileContents, %ReplaceString1%, %ReplaceString2%, All
StringReplace, FileContents, FileContents, %TemporaryString%, %ReplaceString1%, All
FileRecycle, %TcIni%
FileAppend, %FileContents%, %TcIni%

Run, %TcExe%
[face=courier]ENDIF[/face]

Of course, the big thing missing is running a dos command VER from inside the script, and comparing the output with a string.
The string can be coded with something like:

Code: Select all

VersionString = [Version 10.0.14393]
perhaps?
How do I get to run the dos command?
We call it WindowsCommander because it commands Windows, not "Total".
even though it'd be cool to command a 7 trillion dollar oil company
It won Best Alternative File Manager
http://polldaddy.com/poll/810222/
First comment = my girl! ;)
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

We call it WindowsCommander because it commands Windows, not "Total".
even though it'd be cool to command a 7 trillion dollar oil company
It won Best Alternative File Manager
http://polldaddy.com/poll/810222/
First comment = my girl! ;)
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Dalai,
The replacement you make in your code only works in one direction, but both directions are needed. As I understand brian, the Win10 system partition is C: when Win10 is running (obviously). This is, if I understood that correctly, where his files are stored. This partition will be D: when running Win8. Your script covers the case when booting from Win10 into Win8. So far so good.

But when Win8 is rebooted into Win10, the replacement needs to go from D: to C: again. So, yes, some kind of detection is required. This may be the Windows version, a marker in wincmd.ini itself (e.g. key in an unused section) or something else.
As far as I understand the situation regardless of if you boot into W8 (after having used W10) or W10 (after having used W8), all you need to do is exchange C:\ to D:\ and D:\ to C:\. In both cases. The same.

brian,
AutoHotkey has 3 virus warnings
Cool. Ignore them.
So, then we can add the conditional "IF" to the script, like
Why would you need an IF condition?
[face=courier]IF winver ="[Version 10.0.14393]"
THEN

[...]
ELSE
[...]
ENDIF[/face]
The two examples do exactly the same for both situations (W8 and W10). It does not matter if you first exchange C to D and then D to C or vice versa. What you get as a result is an exchange of C <--> D.
It's the same as in your example where the result is the same under both W8 and W10.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Dalai
Power Member
Power Member
Posts: 9366
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Hacker wrote:[...] all you need to do is exchange C:\ to D:\ and D:\ to C:\. In both cases. The same.
Yes, you're right. I overlooked that your code is replacing C: to TEMP to D: and D: to C: at the same time. That way it toggles the drives every time it runs. Sorry, my bad.

Still, a trigger would be nice, a way to automate it, in other words when to start such a script. System startup is only suitable when it's rebooted from one system into the other but not when the same system is rebooted... And the replacement needs to be applied to button bar and maybe other files as well.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

I will do this in CMD and Powershell. Because it works.

I have some questions, still.

If you type VER in DOS, the output is Microsoft Windows Version 10
I wanna use that, which is why I want to put that value in a variable called %Version%. How do I fill this variable with this value, or how do I declare the variable to contain that value? I don't know the jargon, sorry.


I then wanna ask:
IF %Version% equals Microsoft Windows Version 10
THEN replace string1 with string2
ELSE
go out of this loop

How do I do that in the correct manner in the CMD shell?
Why would you need an IF condition?
Because I wanna do this in ONE go, so a button on the button bar.
We call it WindowsCommander because it commands Windows, not "Total".
even though it'd be cool to command a 7 trillion dollar oil company
It won Best Alternative File Manager
http://polldaddy.com/poll/810222/
First comment = my girl! ;)
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

brian,
Because I wanna do this in ONE go, so a button on the button bar.
Not sure if this sentence is supposed to make sense as an answer to my question :?:

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

This is my solution, you can test it yourself with REM and changing the USERDOMAIN variable to yours.

Code: Select all

taskkill /im TOTALCMD64.EXE
IF %USERDOMAIN% == UserB goto Win10
echo win8
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'D\:\\', 'QzQ' } | Set-Content f:\totalcmd852\wincmd.ini"    
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'C\:\\', 'D:\' } | Set-Content f:\totalcmd852\wincmd.ini"    
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'QzQ', 'C:\' } | Set-Content f:\totalcmd852\wincmd.ini"    
    powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace '\\',  '\'   } | Set-Content f:\totalcmd852\wincmd.ini"    
goto ProgStart
:Win10
echo win10
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'C\:\\', 'QzQ' } | Set-Content f:\totalcmd852\wincmd.ini"
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'D\:\\', 'C:\' } | Set-Content f:\totalcmd852\wincmd.ini"
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'QzQ', 'D:\' } | Set-Content f:\totalcmd852\wincmd.ini"
     powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace '\\',  '\'   } | Set-Content f:\totalcmd852\wincmd.ini"
:ProgStart
@echo %myvar%
rem IF %USERDOMAIN%== gwen goto Win10
    f:\totalcmd852\TOTALCMD64.EXE 

rem VER > tmpFile
rem set /p myvar= < tmpFile
rem del tmpFile
Roman, I would wonder if your question made sense, I would, but it's not really relevant now. I'd love your take how to improve my batch file, though, schaefts Du das? ;)
We call it WindowsCommander because it commands Windows, not "Total".
even though it'd be cool to command a 7 trillion dollar oil company
It won Best Alternative File Manager
http://polldaddy.com/poll/810222/
First comment = my girl! ;)
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

brian,
I'd love your take how to improve my batch file, though, schaefts Du das?
Easily. ;)

Code: Select all

taskkill /im TOTALCMD64.EXE
powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'D\:\\', 'QzQ' } | Set-Content f:\totalcmd852\wincmd.ini"   
powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'C\:\\', 'D:\' } | Set-Content f:\totalcmd852\wincmd.ini"   
powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace 'QzQ', 'C:\' } | Set-Content f:\totalcmd852\wincmd.ini"   
powershell -Command "(Get-Content f:\totalcmd852\wincmd.ini) | ForEach-Object { $_ -replace '\\',  '\'   } | Set-Content f:\totalcmd852\wincmd.ini"   
f:\totalcmd852\TOTALCMD64.EXE
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
brian
Junior Member
Junior Member
Posts: 61
Joined: 2003-09-25, 01:14 UTC
Contact:

Post by *brian »

zxcvb
Last edited by brian on 2017-09-20, 14:42 UTC, edited 1 time in total.
Post Reply