weirddave Posted July 17, 2019 Share Posted July 17, 2019 Is there a way to determine via a script (running on say, "PC1") the windows install folder on a networked machine (for example, "PC2"), without running a script on it which could report the information? I know it will always be c:\windows for the PCs I want to use this with but it would be nice to do it the right way... Link to comment Share on other sites More sharing options...
Subz Posted July 17, 2019 Share Posted July 17, 2019 Just use \\PC2\C$\Windows or \\PC2\Admin$ both requires admin privileges on PC2, otherwise map the drive and use credentials. Link to comment Share on other sites More sharing options...
weirddave Posted July 18, 2019 Author Share Posted July 18, 2019 Yes, I could do that as I am pretty sure all the PCs will be configured that way, I was just wondering is there was a 'proper' way to determine the current windows folder remotely (I I have seen systems where it isn't c:\windows). Link to comment Share on other sites More sharing options...
Network_Guy Posted July 18, 2019 Share Posted July 18, 2019 u can use cmd commend like : echo %windir% to get winpath , then use any remote cmd execution method to run it remotly for any pc in domain like PSexec remote WMIC weirddave 1 Link to comment Share on other sites More sharing options...
weirddave Posted July 18, 2019 Author Share Posted July 18, 2019 OK, PSexec looks pretty amazing! Link to comment Share on other sites More sharing options...
orbs Posted July 18, 2019 Share Posted July 18, 2019 the Windows installation path, as well as other important paths, is stored in the registry. look here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion reading the remote registry is a one-liner in AutoIt with the RegRead() function. (of course, admin rights on the target are assumed.) Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Subz Posted July 18, 2019 Share Posted July 18, 2019 Only issue with registry is that you require RemoteRegistry service enabled, which by default for Windows 7 and above is disabled. Another option is to use WMI MsgBox(4096, "Remote Windows Dir", _GetRemoteWindowsDir("RemotePCName")) Func _GetRemoteWindowsDir($_sComputerName = @ComputerName) Local $sRemoteWinDir = "" Local $oWMIService = ObjGet("winmgmts:\\" & $_sComputerName & "\root\CIMV2") Local $oColItems = $oWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", 0x30) If IsObj($oColItems) then For $oColItem In $oColItems $sRemoteWinDir = $oColItem.WindowsDirectory Next EndIf Return $sRemoteWinDir EndFunc Link to comment Share on other sites More sharing options...
orbs Posted July 18, 2019 Share Posted July 18, 2019 to my best understanding, the Remote Registry service is required for modifying the registry on the target pc, whereas reading the registry requires no more than administrative rights (and sometimes even lesser rights, but that's a rare occasion). i did not extensively test remote WMI operation, however i did encounter this interesting article about remote WMI, including security concerns. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
weirddave Posted July 18, 2019 Author Share Posted July 18, 2019 That looks a neater solution since it's all autoit, no need to install anything Link to comment Share on other sites More sharing options...
weirddave Posted July 18, 2019 Author Share Posted July 18, 2019 Security for the scenario I have in mind isn't a problem, it's more likely to be stolen than hacked Link to comment Share on other sites More sharing options...
Nine Posted July 18, 2019 Share Posted July 18, 2019 23 minutes ago, orbs said: to my best understanding, the Remote Registry service is required for modifying the registry on the target pc, whereas reading the registry requires no more than administrative rights (and sometimes even lesser rights, but that's a rare occasion). "The RemoteRegistry Windows Service must be enabled on the remote computer you wish to view or edit the registry on." Tested on my home network, it needs to be started on the remote computer even if it is just reading... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
orbs Posted July 18, 2019 Share Posted July 18, 2019 thanks @Nine, nice to know! Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
Subz Posted July 18, 2019 Share Posted July 18, 2019 Just for reference you can enable RemoteRegistry service via command prompt or script, here are instructions I've written for our helpdesk staff, where some old machines don't have RemoteRegistry already configured.: Quote To enable RemoteRegistry service remotely you can use SC a command line program for communicating with the Service Control Manager and services: To Enable and Start the Remote Registry Service on the computer named "RemotePC" you would use the following steps: • Open: Administrative Command Prompt Nb: The logon account requires Administrative privileges on the remote system, so use Run-As Other User if required. • Type: SC \\RemotePC CONFIG RemoteRegistry START= AUTOImportant: A space is required between the equal sign and the value i.e. "= AUTO" • Type: SC \\RemotePC START RemoteRegistry Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now