Sign in to follow this  
Followers 0
armoros

[ SOLVED ] C:\WINDOWS\system32 - what if it isn't ( C:\ )

10 posts in this topic

#1 ·  Posted (edited)

Hello community.

I am on winxp and my drive letter is C:\ so i call something like this ie.

Global $Init_Dir = "C:\"

OR

If WinActive("C:\WINDOWS\system32\regedit.exe") Then

But if a user has some other drive letter ie. (E:\) how to make the script run correctly if i make it on my pc that has (C:\).

stupid or not quest. i appreciate your advice.

Thank you

Edited by armoros

[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Change WinTitleMatchMode() to accept a StringInStr type searching, and just omit the drive letter?

Scratch that... stupid hackaround.

@SystemDir returns "C:\Windows\System32\"

@WindowsDir returns "C:WINDOWS"

It should report the drive correctly if windows is installed on another drive letter.

If WinActive(@SystemDir & "regedit.exe") Then [...]
Edited by mechaflash213

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I'm only new to AutoIt, but I do know that running %systemroot% in windows opens the Windows folder regardless of drive letter...

Perhaps there's an equivalent, then you'd just need to do & "system32"

Edit: Ah, sorry, didn't see the edit.

Edited by BlueLED

Share this post


Link to post
Share on other sites

Thank you Mechanflash123 i appreciate your help. That makes sense.

you too BlueLED.


[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites

This will only work if you are running from the host OS. If you are trying to look at another drive, from say WinPE or another OS, you'll end up getting that host OS environment variables instead.

Share this post


Link to post
Share on other sites

Thank you Tripredacus..

I appreciate your advices


[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites

I thought we had something like @SystemDrive in AutoIt?


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

@MKISH

Thank you my friend.

or something like this

$drive = EnvGet("systemdrive")

[font="verdana, geneva, sans-serif"] [/font]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

It's all been said already, but for completeness sake.

; Changes how literal strings and % symbols are interpreted. By default strings are treated literally,
; this option allows you to use %environment% variables inside strings, e.g., "The temp directory is: %temp%".
Opt("ExpandEnvStrings", 1) ; 1 = expand environment variables

; If the system is located on drive D: the results are as stated in the comment.
ConsoleWrite(@SystemDir & @LF) ; D:WINDOWSsystem32
ConsoleWrite(@HomeDrive & @LF) ; D:
ConsoleWrite(EnvGet("systemdrive") & @LF) ; D:
ConsoleWrite("%systemdrive%" & @LF) ; D:
ConsoleWrite("%homedrive%" & @LF) ; D:

Edit: added use of ExpandEnvStrings.

Edited by Robjong

Share this post


Link to post
Share on other sites

@ Robjong

Yes you are correct ;) so time to put a Solved in the title.

Thank you all.


[font="verdana, geneva, sans-serif"] [/font]

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  
Followers 0