Check the state of the OS and proceed accordingly.

Page 4 of 7 FirstFirst ... 23456 ... LastLast
  1. Try3's Avatar
    Posts : 7,379
    Windows 10 Home x64 Version 20H2 Build 19042.868
       #31

    Kyhi said:
    Thank You Matt for sharing that code...
    @Try3 Several members have set me code to adjust "Image Health" to work with relocated Personal folders - Your code is the only one found to work...
    Thank You
    The original version contained explanations for the two stages being used.

    Code:
    :: Extract the Registry entry for the Desktop folder [Current user]
    For /F "usebackq tokens=3 " %%X in (`Reg Query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) Do Set DesktopFolderRaw=%%X
    :: Resolve a result that contains a variable such as %UserProfile%
    For /F "usebackq delims=" %%Y in (`Echo %DesktopFolderRaw%`) Do Set DesktopFolder=%%Y

    Denis
      My Computer

  2. Kyhi's Avatar
    Posts : 3,539
    Windows 3.1 to Windows 10
       #32

    Code:
    :: Resolve a result that contains a variable such as %UserProfile%
    That was the issue - others would find the redirected Folder - but would fail with a default %UserProfile% folder

    Again Thank You...
      My Computer

  3. Paul Black's Avatar
    Posts : 12,132
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #33

    Hello @Kyhi, I have PM'd you the updated code.
      My Computer

  4. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #34

    I have not used Try3's code. I use VBScript, which can find the correct desktop.
      My Computer

  5. Try3's Avatar
    Posts : 7,379
    Windows 10 Home x64 Version 20H2 Build 19042.868
       #35

    If I ever want vbs to find the desktop I run
    FindDesktop.vbs
    Code:
    UserDesktop = WScript.CreateObject("WScript.Shell").SpecialFolders("Desktop")
    ' The following MsgBox line is just there to make this a demonstrator version
    MsgBox UserDesktop
    But I hardly ever use vbs for this job.

    I also have a PS method for finding the Desktop. All three methods are in my post Find the user Desktop folder path - PS, vbs, batch methods - TenForums

    Denis
      My Computer

  6. Paul Black's Avatar
    Posts : 12,132
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #36

    Just an observation!

    When using . . .

    (net session >nul 2>&1)||(PowerShell start """%~0""" -verb runas & exit /b)

    . . . the title bar shows as C:\Windows\System32\cmd.exe, instead of Administrator:!
      My Computer

  7. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #37

    The title bar shows "Administrator:" in the screenshot below:

    Create Elevated Shortcut without UAC prompt in Windows 10

    My code has been used in my script there.
      My Computer

  8. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #38

    Kyhi said:
    our test results vary - as I just tested > "Test$ Admin.cmd" and > "Test Admin.cmd"
    ie with space and a special character - also tested as .bat
    The file path is E:\A folder\ImageHealth.cmd
    The result is shown below:

    Check the state of the OS and proceed accordingly.-name-has-space.jpg

    I am running an en-us version of Windows 10, version 1903.
      My Computer

  9. Kyhi's Avatar
    Posts : 3,539
    Windows 3.1 to Windows 10
       #39

    if you are starting from a command prompt - then you need to use path with "Quote's" due to space
      My Computer

  10. Matthew Wai's Avatar
    Posts : 4,998
    Windows 10 Home 20H2
       #40

    1. I double-clicked on your script.
    2. I selected "Yes" on the UAC prompt.
    3. The Command Prompt appeared, showing the error message.
      My Computer


 
Page 4 of 7 FirstFirst ... 23456 ... LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 17:40.
Find Us




Windows 10 Forums