Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.ServiceProcess.ServiceController.dll [SOLVED] Pin
jochance13-Feb-24 12:46
jochance13-Feb-24 12:46 
Questionwhy cant I run powershell script from current directory Pin
Sherzaad132913251-Feb-24 22:04
Sherzaad132913251-Feb-24 22:04 
AnswerRe: why cant I run powershell script from current directory Pin
Richard Deeming1-Feb-24 22:23
mveRichard Deeming1-Feb-24 22:23 
GeneralRe: why cant I run powershell script from current directory Pin
Sherzaad132913252-Feb-24 1:39
Sherzaad132913252-Feb-24 1:39 
AnswerRe: why cant I run powershell script from current directory Pin
jschell2-Feb-24 6:00
jschell2-Feb-24 6:00 
AnswerRe: why cant I run powershell script from current directory Pin
Sherzaad132913252-Feb-24 11:44
Sherzaad132913252-Feb-24 11:44 
GeneralRe: why cant I run powershell script from current directory Pin
Dave Kreskowiak5-Feb-24 7:05
mveDave Kreskowiak5-Feb-24 7:05 
GeneralRe: why cant I run powershell script from current directory Pin
trønderen7-Feb-24 4:49
trønderen7-Feb-24 4:49 
You are right that the OP has not provided enough info for us to certainly conclude that it was a path length problem. But we certainly cannot reject it.

Then file name of his script, "enableTouchScreen.ps1", is 21 chars. He reports that when it is moved to "the 'currentDirectory' (ie the Project debug folder)", it won't work. If the length of 'cd' exceeds 238 chars, the full script file name would exceed 260 chars.

I certainly have seen project directory paths exceeding 238 chars; in my last job, the naming rules made it more or less the standard. What surprises me more is that the OP does not run into this problem with other files in his project as well. Maybe it is set up will all relative naming (and no tools expand it to an absolute path), or all files are located in other directories with shorter paths, or all the other tools are prepared for long file paths.

260 chars was the old DOS/FAT limit. As long as you use new Windows file system APIs that can handle longer NTFS paths, they can be up to approx. 32 Ki characters. The 260 length is not really in NTFS or Windows, but in individual programs using old APIs. These APIs have not been extended to long file names because lots of old program have allocated 261 chars for a file path buffer, frequently with no overrun check as that is the maximum length. If an old API used to return names limited by MAX_PATH after a minor update starts returning names of several hundred or thousand characters, then you would have a buffer overrun.

It is a pity that the myth of Windows being limited to 260 chars are still living. It makes lots of programmers continue making 261 char allocations, and the old APIs that should have been marked as deprecated 20 years ago and removed 10 years ago. Backwards compatibility is great (and Windows is far better at it than competing OSes!) but sometimes it goes too far.

Religious freedom is the freedom to say that two plus two make five.

GeneralRe: why cant I run powershell script from current directory Pin
Dave Kreskowiak7-Feb-24 5:58
mveDave Kreskowiak7-Feb-24 5:58 
GeneralRe: why cant I run powershell script from current directory Pin
trønderen7-Feb-24 17:18
trønderen7-Feb-24 17:18 
GeneralRe: why cant I run powershell script from current directory Pin
Dave Kreskowiak7-Feb-24 19:15
mveDave Kreskowiak7-Feb-24 19:15 
GeneralRe: why cant I run powershell script from current directory Pin
Richard MacCutchan7-Feb-24 21:35
mveRichard MacCutchan7-Feb-24 21:35 
GeneralRe: why cant I run powershell script from current directory Pin
trønderen8-Feb-24 6:21
trønderen8-Feb-24 6:21 
GeneralRe: why cant I run powershell script from current directory Pin
jschell7-Feb-24 5:31
jschell7-Feb-24 5:31 
QuestionShould 0.5 round up or down? Pin
Gerry Schmitz26-Jan-24 8:33
mveGerry Schmitz26-Jan-24 8:33 
AnswerRe: Should 0.5 round up or down? Pin
trønderen26-Jan-24 9:14
trønderen26-Jan-24 9:14 
AnswerRe: Should 0.5 round up or down? Pin
Dave Kreskowiak26-Jan-24 10:59
mveDave Kreskowiak26-Jan-24 10:59 
AnswerRe: Should 0.5 round up or down? Pin
Kenneth Haugland27-Jan-24 2:30
mvaKenneth Haugland27-Jan-24 2:30 
AnswerRe: Should 0.5 round up or down? Pin
jschell29-Jan-24 4:41
jschell29-Jan-24 4:41 
GeneralRe: Should 0.5 round up or down? Pin
Gerry Schmitz29-Jan-24 8:51
mveGerry Schmitz29-Jan-24 8:51 
GeneralRe: Should 0.5 round up or down? Pin
jschell30-Jan-24 4:49
jschell30-Jan-24 4:49 
GeneralRe: Should 0.5 round up or down? Pin
Gerry Schmitz30-Jan-24 8:03
mveGerry Schmitz30-Jan-24 8:03 
AnswerRe: Should 0.5 round up or down? Pin
Richard MacCutchan30-Jan-24 5:23
mveRichard MacCutchan30-Jan-24 5:23 
GeneralRe: Should 0.5 round up or down? Pin
Gerry Schmitz30-Jan-24 8:09
mveGerry Schmitz30-Jan-24 8:09 
GeneralRe: Should 0.5 round up or down? Pin
Richard MacCutchan30-Jan-24 8:20
mveRichard MacCutchan30-Jan-24 8:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.